Files
Investidor-V2/outputs/investmoz-referencias-economicas-QA-20261016/final-local-checks.py
T
nala 2d23157e40
tests / ci (push) Canceled after 0s
versao nrgocios
2026-10-16 13:06:58 +02:00

23 lines
2.6 KiB
Python

from pathlib import Path
import json,hashlib,subprocess,datetime
out=Path(__file__).resolve().parent;root=out.parents[1];private=Path('C:/Users/macbook/.config/investmoz/referencias-economicas-QA-20261016');source=private/'source';sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
baseline=json.loads((out/'ATIVO-ANTES.json').read_text('utf-8'));actual={p.relative_to(root).as_posix():sha(p) for folder in ['app','config','routes','database','resources','public/build'] for p in (root/folder).rglob('*') if p.is_file()}
assert actual==baseline['files'],'Active sources or build changed'
assert all(sha(root/n)==h for n,h in baseline['protected'].items()),'Protected active config/locks changed'
state=json.loads((out/'CANDIDATE-STATE.json').read_text('utf-8'));assert state['publication']=='published'
php='C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64/php.exe';lint=[]
for name in state['files']:
if name.endswith('.php'):
r=subprocess.run([php,'-l',str(source/name)],capture_output=True,text=True);assert r.returncode==0,name;lint.append(name)
assert 'error TS' not in (out/'TYPES-CHECK.log').read_text('utf-16')
buildlog=(out/'BUILD.log').read_text('utf-16');assert 'built in' in buildlog
build=source/'public/build';manifest=json.loads((build/'manifest.json').read_text('utf-8'));refs=[]
for k,v in manifest.items():
for name in [v['file'],*v.get('css',[]),*v.get('assets',[])]:assert (build/name).is_file(),name;refs.append(name)
assert any('economic-references' in k for k in manifest)
entry=next(v['file'] for k,v in manifest.items() if k=='resources/js/app.tsx');assert 'InvesteMoz' in (build/entry).read_text('utf-8')
counts={'application_artifacts':len(state['files']),'sources':len(state['files'])-2,'substitutions':sum((root/n).exists() for n in state['files']),'new_files':sum(not(root/n).exists() for n in state['files']),'compiled_files':sum(p.is_file()for p in build.rglob('*')),'php_linted':len(lint),'active_files_compared':len(actual),'protected_files_compared':len(baseline['protected'])}
assert counts['application_artifacts']==13 and counts['substitutions']==7 and counts['new_files']==6
result={'verified_at':datetime.datetime.now(datetime.timezone.utc).isoformat(),'counts':counts,'types_check':'passed','build':'passed; existing optional fontaine/chunk-size notices only','build_asset_references_checked':len(refs),'active_sources_config_build_unchanged':True,'active_database_connections':0,'QA_target':state['target'],'candidate':'referencias-economicas-QA-'+state['code_hash'][:12],'code_hash':state['code_hash']}
(out/'VERIFICACAO-LOCAL.json').write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n','utf-8');print(json.dumps(result,ensure_ascii=False))