informed-decision/tools/service_image/installed_manifest.py

14 lines
681 B
Python
Raw Normal View History

"""Print `sha256 ./relative/path` for the installed informed_decision modules (C-sorted).
Run inside the service image (`docker run -i --entrypoint python IMAGE - < this file`). CI compares
the output with `sha256sum` over the pushed commit's informed_decision/*.py: the image must carry
exactly the source it was built from. Opens no database and no network.
"""
import hashlib
from pathlib import Path
ROOT = Path('/opt/venv/lib/python3.12/site-packages/informed_decision')
rows = sorted('./' + str(p.relative_to(ROOT)) for p in ROOT.rglob('*.py') if '__pycache__' not in p.parts)
for rel in rows:
print(hashlib.sha256((ROOT / rel).read_bytes()).hexdigest() + ' ' + rel)