Files
Investidor-V2/outputs/investmoz-navegacao-QA-20261016/verify-package.py
T
nala cef6e201c7
tests / ci (push) Canceled after 0s
versao nrgocios 2
2026-10-16 20:11:05 +02:00

37 lines
3.8 KiB
Python

from pathlib import Path
import json,hashlib,shutil,difflib
out=Path(__file__).resolve().parent;root=out.parents[1];qa=Path('C:/Users/macbook/.config/investmoz/navegacao-QA-20261016/source');base=qa.parent/'baseline-source'
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
prior=json.loads((out/'ATIVO-ANTES.json').read_text('utf-8'));changed=[]
for group in ['files','protected']:
for name,h in prior[group].items():
if not(root/name).exists() or sha(root/name)!=h:changed.append(name)
assert not changed,changed
files=['resources/js/lib/portal-navigation.ts','resources/js/components/portal-grouped-menu.tsx','resources/js/layouts/portal-navigation.tsx','resources/js/pages/investment/catalogue.tsx','resources/js/app.tsx','resources/js/layouts/app/app-sidebar-layout.tsx','routes/web.php','resources/js/components/navigation-context.tsx','resources/js/components/catalogue-navigation.tsx','resources/js/pages/qa/navigation.tsx']
doc=out/'DOC01';doc.mkdir(exist_ok=True);manifest=[];patches=[]
build_target=(doc/'files/public/build').resolve();assert build_target.is_relative_to(out.resolve()) and build_target==out.resolve()/'DOC01/files/public/build'
if build_target.exists():shutil.rmtree(build_target)
for name in files:
p=qa/name;b=base/name;dst=doc/'files'/name;dst.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(p,dst)
manifest.append({'path':name,'sha256':sha(p),'bytes':p.stat().st_size,'action':'replace' if b.exists() else 'new','before_sha256':sha(b) if b.exists() else None})
if b.exists():
dst=doc/'rollback'/name;dst.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(b,dst)
patches.extend(difflib.unified_diff(b.read_text('utf-8').splitlines(True) if b.exists() else [],p.read_text('utf-8').splitlines(True),fromfile='base/'+name,tofile='QA/'+name))
(doc/'DELTA.patch').write_text(''.join(patches),'utf-8')
build=[]
for p in sorted((qa/'public/build').rglob('*')):
if not p.is_file():continue
name=p.relative_to(qa).as_posix();dst=doc/'files'/name;dst.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(p,dst);build.append({'path':name,'sha256':sha(p),'bytes':p.stat().st_size})
for p in sorted((base/'public/build').rglob('*')):
if not p.is_file():continue
dst=doc/'rollback'/p.relative_to(base);dst.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(p,dst)
identifier='navegacao-prototipo-QA-'+hashlib.sha256(json.dumps(manifest,sort_keys=True).encode()).hexdigest()[:12]
(doc/'MANIFESTO.json').write_text(json.dumps({'candidate':identifier,'status':'prototype QA for visible organization review; not active deployment candidate','sources':manifest,'build':build,'migrations':[],'business_write_endpoints_added':[],'remove_on_rollback':[x['path'] for x in manifest if x['action']=='new'],'active_changes_authorized':False},ensure_ascii=False,indent=2),'utf-8')
qa_final=json.loads((out/'FINAL-QA.json').read_text('utf-8'));assert qa_final['changed_tables']==[]
verification={'candidate':identifier,'active_runtime_files_unchanged':len(prior['files']),'active_protected_files_unchanged':len(prior['protected']),'active_database_not_connected':True,'qa_tables_unchanged':qa_final['table_count'],'new_business_records':0,'migrations_executed':0,'sources':len(manifest),'replacements':sum(x['action']=='replace' for x in manifest),'new_sources':sum(x['action']=='new' for x in manifest),'build_files':len(build),'definition_unchanged':[]}
for p in (root/'app').rglob('*InvestorPathDefinition*.php'):
if 'vendor' not in p.parts and 'storage' not in p.parts and 'outputs' not in p.parts:
rel=p.relative_to(root).as_posix();assert sha(p)==sha(qa/rel);verification['definition_unchanged'].append({'path':rel,'sha256':sha(p)})
(out/'VERIFICACAO-INTEGRIDADE-LOCAL.json').write_text(json.dumps(verification,ensure_ascii=False,indent=2),'utf-8')
print(json.dumps(verification,ensure_ascii=True))