NAS 정식 스택과 배포 파이프라인 도구를 고정
This commit is contained in:
parent
f1b80676c1
commit
d6d9dc5f61
8 changed files with 812 additions and 1 deletions
39
scripts/dist-snap.py
Normal file
39
scripts/dist-snap.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
"""dist 결정성 스냅샷 — sha256 파일 지도를 만들고 두 빌드를 비교한다.
|
||||
|
||||
사용: python -X utf8 dist-snap.py snap1 | python -X utf8 dist-snap.py compare dist-snap1.json
|
||||
"""
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def snap(root: str) -> dict:
|
||||
out = {}
|
||||
for dp, _, fns in os.walk(root):
|
||||
for fn in fns:
|
||||
p = os.path.join(dp, fn)
|
||||
rel = os.path.relpath(p, root).replace(os.sep, "/")
|
||||
with open(p, "rb") as fh:
|
||||
out[rel] = hashlib.sha256(fh.read()).hexdigest()
|
||||
return out
|
||||
|
||||
|
||||
if sys.argv[1] == "snap":
|
||||
s = snap("dist")
|
||||
name = sys.argv[2]
|
||||
with open(name, "w", encoding="utf-8") as fh:
|
||||
json.dump(s, fh)
|
||||
print("files:", len(s))
|
||||
elif sys.argv[1] == "compare":
|
||||
with open(sys.argv[2], encoding="utf-8") as fh:
|
||||
s1 = json.load(fh)
|
||||
s2 = snap("dist")
|
||||
only1 = sorted(set(s1) - set(s2))
|
||||
only2 = sorted(set(s2) - set(s1))
|
||||
diff = sorted(k for k in set(s1) & set(s2) if s1[k] != s2[k])
|
||||
print("build1 files:", len(s1), "build2 files:", len(s2))
|
||||
print("only_in_build1:", only1[:10])
|
||||
print("only_in_build2:", only2[:10])
|
||||
print("content_diff:", diff[:10])
|
||||
print("DETERMINISTIC" if not (only1 or only2 or diff) else "NON_DETERMINISTIC")
|
||||
Loading…
Add table
Add a link
Reference in a new issue