Files
Investidor-V2/outputs/investmoz-legado-ativacao-20261015/deliver-three-sources.py
T
nala 6a76aac80f
tests / ci (push) Canceled after 0s
versao compilada 1
2026-10-16 09:17:28 +02:00

25 lines
1.9 KiB
Python

from pathlib import Path
import json,hashlib,subprocess,datetime
r=Path.cwd();o=r/'outputs/investmoz-legado-ativacao-20261015';q=r/'outputs/investmoz-legado-importador-delta-QA-20261015';sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
b=json.loads((o/'FRESH-BACKUP.json').read_text());assert b['restore_verified'] and b['files_verified'] and b['restored_table_hashes_equal'];private=Path(b['private_directory']);before=json.loads((private/'backup-proof-private.json').read_text());m=json.loads((q/'MAPA-TRES-FICHEIROS.json').read_text());assert len(m['source_operations'])==3
assert sha(r/'outputs/investmoz-legado-importador-delta-QA-20261015.zip')=='a09b15ee6b9e5d1be46f832295840e103043617ae29848780eedcf92df5c217c'
for x in m['source_operations']:assert sha(r/x['path'])==x['active_before_sha256'] and sha(q/'fonte-QA'/x['path'])==x['candidate_sha256']
assert sha(r/'.env')==before['file_hashes']['.env']
for n,h in before['file_hashes'].items():
if n.startswith('public/build/'):assert sha(r/n)==h
php='C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64/php.exe'
def artisan(*args):subprocess.run([php,'artisan',*args],cwd=r,capture_output=True,check=True)
def put(p,b):
with p.open('r+b')as f:f.write(b);f.truncate()
v={'at':datetime.datetime.now(datetime.timezone.utc).isoformat(),'source_files':3,'sources':{},'reader_enabled':False,'build_unchanged':True,'B_preserved':True}
try:
artisan('down','--retry=60')
for x in m['source_operations']:
n=x['path'];put(r/n,(q/'fonte-QA'/n).read_bytes());assert sha(r/n)==x['candidate_sha256'];v['sources'][n]=sha(r/n)
assert sha(r/'.env')==before['file_hashes']['.env']
artisan('up');v['maintenance_ended']=True;v['result']='Three authorized sources delivered; import/publication/reader still pending'
except Exception:
for x in m['source_operations']:put(r/x['path'],(private/'files'/x['path']).read_bytes())
artisan('up');raise
(o/'SOURCE-DELIVERY.json').write_text(json.dumps(v,indent=2)+'\n');print(json.dumps(v))