Files
ARCADIA-Studio/harness/experiments/runtime-notices-20260913/proposal/confirm-build-chain.py
T

16 lines
1.1 KiB
Python

from pathlib import Path
import hashlib,json,urllib.request
O=Path(__file__).resolve().parent
records=[]
def get(url,name):
with urllib.request.urlopen(urllib.request.Request(url,headers={'User-Agent':'Arcadia-runtime-provenance/1'}),timeout=45) as r:b=r.read()
with (O/name).open('xb') as f:f.write(b)
records.append({'url':url,'file':name,'bytes':len(b),'sha256':hashlib.sha256(b).hexdigest()})
return b
commit='030097eeee87fcfd0f3bfe536b21cbd6e5d3b324'
get(f'https://raw.githubusercontent.com/mstorsjo/llvm-mingw/{commit}/prepare-cross-toolchain.sh','prepare-cross-toolchain.sh')
r=json.loads(get(f'https://api.github.com/repos/mstorsjo/llvm-mingw/actions/workflows/build.yml/runs?head_sha={commit}&event=push&per_page=10','official-push-build-runs.json'))
selected=[{k:a.get(k) for k in ['id','head_sha','event','status','conclusion','html_url','created_at','updated_at']} for a in r['workflow_runs']]
with (O/'build-chain-evidence.json').open('x',encoding='utf-8') as f:json.dump({'records':records,'official_push_runs':selected},f,indent=2)
print(json.dumps(selected,indent=2))