75 lines
2.9 KiB
Python
75 lines
2.9 KiB
Python
"""Offline byte, release, Git, citation and independent pointer inventory checks."""
|
|
|
|
import hashlib
|
|
import json
|
|
import zipfile
|
|
|
|
from build_definition import OUT, REF, REPO, build
|
|
|
|
|
|
def main():
|
|
b = build()
|
|
identities = {e["id"]: e["commit"] for e in json.loads((REF / "identities.json").read_bytes())}
|
|
for e in b["sources"]:
|
|
raw = (OUT / e["local_file"]).read_bytes()
|
|
assert hashlib.sha256(raw).hexdigest() == e["sha256"]
|
|
assert 1 <= e["lines"][0] <= e["lines"][1] <= len(raw.decode().splitlines()), e
|
|
if "package_sha256" in e:
|
|
archive = REF / (e["id"] + "-source.zip")
|
|
assert hashlib.sha256(archive.read_bytes()).hexdigest() == e["package_sha256"]
|
|
assert e["git_commit_binding"] == "unknown"
|
|
with zipfile.ZipFile(archive) as z:
|
|
assert z.read(e["file"]) == raw
|
|
else:
|
|
root = REF.parent / "seedvr2-reference" if e["id"] == "frontend" else REF
|
|
tree = json.loads((root / (e["id"] + "-tree.json")).read_bytes())
|
|
assert tree["sha"] == e["commit"] and not tree["truncated"]
|
|
assert (
|
|
hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest()
|
|
== e["git_blob_sha1"]
|
|
== next(x["sha"] for x in tree["tree"] if x["path"] == e["file"])
|
|
)
|
|
tag = root / (e["id"] + "-tag.json")
|
|
if tag.exists():
|
|
obj = json.loads(tag.read_bytes())["object"]
|
|
assert obj["type"] == "commit" and obj["sha"] == e["commit"]
|
|
g = json.loads((REPO / b["source_path"]).read_bytes())
|
|
expected = [
|
|
f"/nodes/{i}/widgets_values/{j}"
|
|
for i, n in enumerate(g["nodes"])
|
|
for j in range(len(n["widgets_values"]))
|
|
]
|
|
assert expected == [f["pointer"] for f in b["fields"]] and len(expected) == 35
|
|
assert len(g["nodes"]) == 17 and len(g["links"]) == 20 and "definitions" not in g
|
|
assert all(n["mode"] == 0 and "widgets_values_named" not in n for n in g["nodes"])
|
|
assert "frontendVersion" not in g["extra"] and not b["comments"]
|
|
(OUT / "source-check.json").write_text(
|
|
json.dumps(
|
|
dict(
|
|
all_pass=True,
|
|
commits=identities,
|
|
citations=len(b["sources"]),
|
|
texts=len({e["local_file"] for e in b["sources"]}),
|
|
saved_positions=35,
|
|
source_notes=0,
|
|
local_file_base=str(OUT.relative_to(REPO)),
|
|
package_git_binding="unknown",
|
|
frontend="1.45.20 reference hypothesis only; source/host unknown",
|
|
upstream_executed=False,
|
|
),
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
print(
|
|
(
|
|
"PASS exact bytes, source identities, release has"
|
|
"hes, Git blobs, citations and 35/0 inventory"
|
|
)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|