Files
gridcraft/.github/workflows/windows-settle-probe.yml
T

61 lines
2.6 KiB
YAML

name: windows stat settling probe (throwaway)
# Throwaway diagnostic: does a freshly written or copied file's stat settle? Not a release path.
on:
workflow_dispatch:
push:
branches: [diag/**]
permissions:
contents: read
jobs:
probe:
runs-on: windows-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Does a freshly written file settle?
shell: bash
run: |
python -I -B - <<'EOF'
import json, os, time
fields = ("st_dev", "st_ino", "st_size", "st_mtime_ns", "st_ctime_ns")
p = os.path.abspath("probe-producer.json")
with open(p, "w") as stream:
stream.write(json.dumps({"a": 1}))
with open(p, "wb") as stream:
stream.write(json.dumps({"a": 1}).encode())
t0 = time.time()
out = []
for _ in range(40):
handle = os.open(p, os.O_RDONLY)
f = os.fstat(handle); os.close(handle)
e = os.lstat(p)
diff = {k: (getattr(e, k), getattr(f, k)) for k in fields if getattr(e, k) != getattr(f, k)}
out.append({"ms": round((time.time() - t0) * 1000), "diff": diff})
time.sleep(0.05)
print("written:", json.dumps([o for o in out if o["diff"]][:10]))
print("samples that differed:", sum(1 for o in out if o["diff"]), "of", len(out))
print("first agreeing sample (ms):", next((o["ms"] for o in out if not o["diff"]), None))
EOF
- name: Same, for a file copied out
shell: bash
run: |
python -I -B - <<'EOF'
import json, os, shutil, time
fields = ("st_ctime_ns", "st_mtime_ns", "st_size")
shutil.copyfile("probe-producer.json", "probe-copied.json")
t0 = time.time()
out = []
for _ in range(40):
handle = os.open("probe-copied.json", os.O_RDONLY)
f = os.fstat(handle); os.close(handle)
e = os.lstat("probe-copied.json")
d = {k: (getattr(e, k), getattr(f, k)) for k in fields if getattr(e, k) != getattr(f, k)}
out.append({"ms": round((time.time() - t0) * 1000), "diff": d})
time.sleep(0.05)
print("copied: samples that differed:", sum(1 for o in out if o["diff"]), "of", len(out),
"first agreeing (ms):", next((o["ms"] for o in out if not o["diff"]), None))
print("copied: first differing samples:", [o for o in out if o["diff"]][:3])
EOF