diff --git a/.gitignore b/.gitignore index 5c347b4..de52a09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ __pycache__/ *.pyc work/ +docs/screenshots/build/ +docs/screenshots/.darkroom/ diff --git a/README.md b/README.md index 1263be6..d8f5d8c 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,58 @@ evidence. The policy that decides what to do with that evidence lives elsewhere. These workflows publish nothing and hold no secrets. Their token is read-only. +![Two terminal windows: the tests gate on tak prints five green PASS lines and exits 0; run again expecting 0.6.0 it prints PASS checkout, FAIL version and exits 1](docs/screenshots/tests-gate-pass-fail.png) + +*The tests gate run locally against tak 0.5.0: every assertion passes, then the same commit stops at `version` when 0.6.0 is expected. See [Screenshots](#screenshots).* + The first library covered is [tak](https://github.com/Stephenson-Software/tak), the text-adventure kit that FishE, Tidewater and Overwinter are built on. From `v2` the save-compatibility gate also covers applications that are run from a checkout rather than installed with pip. The first is [roam](https://github.com/Preponderous-Software/roam). +## Screenshots + +Every image here is real output, captured by running the gate scripts locally the way the +workflows run them (see [Run a gate locally](#run-a-gate-locally)), against +[tak](https://github.com/Stephenson-Software/tak) at `v0.5.0` +(`2bb6938ed2a1aed644f3e96163adc489e067eb10`). + +**Pass and fail.** With `EXPECTED_VERSION=0.5.0` every assertion passes and the script exits 0 +(the PASS/FAIL lines are filtered out of the full log with `grep`). With +`EXPECTED_VERSION=0.6.0` the gate stops at the first failing assertion, `version`, and exits 1; +that run is shown whole. Both are in the image at the top of this page. + +**Run summary.** What [`gates/summarize.py`](gates/summarize.py) printed for those two runs' +`result.json`, the Markdown each workflow appends to `$GITHUB_STEP_SUMMARY`, rendered locally. + +![Two run-summary tables: Tests gate PASSED with five ticked assertions, and Tests gate FAILED with checkout ticked and version crossed](docs/screenshots/run-summary.png) + +**Save compatibility.** The save-compatibility gate with `scenarios/tak_slots.py`: tak `v0.2.0` +writes the saves, and tak `v0.5.0` reads them twice, appends a save and reads again, with every +baseline file left byte-identical. The PASS/FAIL lines are cut at 112 characters, since +`baseline-read` quotes the whole save view. + +![A terminal: the save-compatibility gate on tak exits 0 and its eleven assertions, from baseline-install to read-3, all print PASS](docs/screenshots/save-compat-tak-pass.png) + +### Run a gate locally + +Each gate is a plain script driven by environment variables. The tests gate expects the +candidate checked out at `$WORK/src`, as the workflow does: + +``` +git clone https://github.com/Stephenson-Software/tak /tmp/prg-work/src +git -C /tmp/prg-work/src checkout 2bb6938ed2a1aed644f3e96163adc489e067eb10 +REPOSITORY=Stephenson-Software/tak SHA=2bb6938ed2a1aed644f3e96163adc489e067eb10 \ + PACKAGE=tak EXPECTED_VERSION=0.5.0 PYTHON_VERSIONS=3.12 WORK=/tmp/prg-work \ + python3.12 gates/tests_gate.py +python3.12 gates/summarize.py /tmp/prg-work/result.json "Tests gate" +``` + +**Regenerating screenshots.** The captured output is kept in +[`docs/screenshots/src/`](docs/screenshots/src); `python3 docs/screenshots/render.py` turns it +into pages and `darkroom shoot docs/screenshots/media.json` (with +[darkroom](https://github.com/Preponderous-Software/darkroom)) captures them. + ## Gates | Workflow | Checks | Artifact | diff --git a/docs/screenshots/media.json b/docs/screenshots/media.json new file mode 100644 index 0000000..aabb0f4 --- /dev/null +++ b/docs/screenshots/media.json @@ -0,0 +1,52 @@ +{ + "out": ".", + "devices": { + "doc": { + "width": 1240, + "height": 900, + "dpr": 1 + } + }, + "defaults": { + "device": "doc", + "format": "png", + "crop": { + "of": ".shot", + "pad": 0 + } + }, + "shots": [ + { + "name": "tests-gate-pass-fail", + "url": "file://{manifest_dir}/build/terminal-pass-fail.html", + "inputs": [ + "src/tests-gate-pass.txt", + "src/tests-gate-fail.txt", + "render.py" + ], + "caption": "The tests gate run on tak 0.5.0: every assertion passes, then the same commit stops at `version` when 0.6.0 is expected.", + "alt": "Two terminal windows: the tests gate on tak prints five green PASS lines and exits 0; run again expecting 0.6.0 it prints PASS checkout, FAIL version and exits 1" + }, + { + "name": "run-summary", + "url": "file://{manifest_dir}/build/run-summary.html", + "inputs": [ + "src/tests-gate-pass.summary.md", + "src/tests-gate-fail.summary.md", + "render.py" + ], + "caption": "What gates/summarize.py writes to the run summary for those two runs.", + "alt": "Two run-summary tables: Tests gate PASSED with five ticked assertions, and Tests gate FAILED with checkout ticked and version crossed" + }, + { + "name": "save-compat-tak-pass", + "url": "file://{manifest_dir}/build/save-compat-tak-pass.html", + "inputs": [ + "src/save-compat-tak-pass.txt", + "render.py" + ], + "caption": "The save-compatibility gate: saves written by tak v0.2.0 are read, kept byte-identical and appended to by tak 0.5.0.", + "alt": "A terminal: the save-compatibility gate on tak exits 0 and its eleven assertions, from baseline-install to read-3, all print PASS" + } + ] +} diff --git a/docs/screenshots/render.py b/docs/screenshots/render.py new file mode 100644 index 0000000..9c147a2 --- /dev/null +++ b/docs/screenshots/render.py @@ -0,0 +1,84 @@ +"""Turn the captured gate output in src/ into HTML pages that media.json screenshots. + + python3 docs/screenshots/render.py # writes docs/screenshots/build/*.html + +src/*.txt is a terminal transcript, exactly as the commands printed it (lines starting `$ ` +are the commands). src/*.summary.md is what gates/summarize.py printed for that run's +result.json, the Markdown the workflows write to the run summary. Standard library only. +""" + +import html +import re +from pathlib import Path + +HERE = Path(__file__).resolve().parent +SRC, OUT = HERE / "src", HERE / "build" + +PAGE = """{title}
{body}
""" + + +def terminal(path: Path) -> str: + lines, continued = [], False + for raw in path.read_text().splitlines(): + line = html.escape(raw) + if raw.startswith("$ ") or continued: + continued = raw.endswith("\\") + line = f'{line}' + elif raw.startswith("PASS "): + line = re.sub(r"^PASS (\S+:)", r'PASS \1', line) + elif raw.startswith("FAIL "): + line = re.sub(r"^FAIL (\S+:)", r'FAIL \1', line) + else: + line = f'{line}' + lines.append(line) + bar = '
' \ + f'{html.escape(path.stem)}
' + return f'
{bar}
{chr(10).join(lines)}
' + + +def inline(text: str) -> str: + return re.sub(r"`([^`]*)`", r"\1", html.escape(text)) + + +def summary(path: Path) -> str: + """The small Markdown subset summarize.py writes: a heading, a line, one table.""" + out, rows = [], [] + for raw in path.read_text().splitlines(): + if raw.startswith("## "): + out.append(f"

{inline(raw[3:])}

") + elif raw.startswith("|"): + cells = [c.strip().replace("\\|", "|") for c in raw.strip("|").split(" | ")] + if not set("".join(cells)) <= set("-| "): + rows.append(cells) + elif raw.strip(): + out.append(f"

{inline(raw)}

") + if rows: + head = "".join(f"{inline(c)}" for c in rows[0]) + body = "".join("" + "".join(f"{inline(c)}" for c in r) + "" for r in rows[1:]) + out.append(f"{head}{body}
") + return f'
{"".join(out)}
' + + +def page(name: str, parts: list) -> None: + OUT.mkdir(exist_ok=True) + (OUT / f"{name}.html").write_text(PAGE.format(title=name, body="".join(parts))) + + +page("terminal-pass-fail", [terminal(SRC / "tests-gate-pass.txt"), terminal(SRC / "tests-gate-fail.txt")]) +page("run-summary", [summary(SRC / "tests-gate-pass.summary.md"), summary(SRC / "tests-gate-fail.summary.md")]) +for txt in sorted(SRC.glob("save-compat-*.txt")): + page(txt.stem, [terminal(txt)]) diff --git a/docs/screenshots/run-summary.png b/docs/screenshots/run-summary.png new file mode 100644 index 0000000..94924f8 Binary files /dev/null and b/docs/screenshots/run-summary.png differ diff --git a/docs/screenshots/save-compat-tak-pass.png b/docs/screenshots/save-compat-tak-pass.png new file mode 100644 index 0000000..63cf59c Binary files /dev/null and b/docs/screenshots/save-compat-tak-pass.png differ diff --git a/docs/screenshots/src/save-compat-tak-pass.txt b/docs/screenshots/src/save-compat-tak-pass.txt new file mode 100644 index 0000000..6348344 --- /dev/null +++ b/docs/screenshots/src/save-compat-tak-pass.txt @@ -0,0 +1,16 @@ +$ REPOSITORY=Stephenson-Software/tak SHA=2bb6938ed2a1aed644f3e96163adc489e067eb10 \ + BASELINE_REF=v0.2.0 SCENARIO=scenarios/tak_slots.py DISTRIBUTION=tak WORK=/tmp/prg-sc \ + python3.12 gates/save_compat.py > save-compat.log 2>&1; echo "exit $?" +exit 0 +$ grep -E '^(PASS|FAIL) ' save-compat.log | cut -c1-112 +PASS baseline-install: tak v0.2.0 installed at 5aa490b46102a9a5ceb63c077058ce446bfc75a5 +PASS candidate-install: tak installed at 2bb6938ed2a1aed644f3e96163adc489e067eb10 +PASS baseline-write: 13 file(s) written by v0.2.0 +PASS baseline-read: reference view: {"next_slot": 3, "saves": [{"metadata": {"day": 3, "last_modified": "2026-11 +PASS read-1: candidate view equals the baseline view +PASS files-kept-1: 13 file(s) byte-identical +PASS read-2: candidate view equals the baseline view +PASS files-kept-2: 13 file(s) byte-identical +PASS append: candidate added a save beside the baseline's +PASS files-kept-3: every baseline file byte-identical; added 2 path(s) +PASS read-3: 6 save(s) listed: every baseline save unchanged + 1 added diff --git a/docs/screenshots/src/tests-gate-fail.summary.md b/docs/screenshots/src/tests-gate-fail.summary.md new file mode 100644 index 0000000..21a744f --- /dev/null +++ b/docs/screenshots/src/tests-gate-fail.summary.md @@ -0,0 +1,7 @@ +## Tests gate — FAILED +`Stephenson-Software/tak` @ `2bb6938ed2a1aed644f3e96163adc489e067eb10` + +| assertion | result | detail | +|---|---|---| +| checkout | ✅ | checked out 2bb6938ed2a1aed644f3e96163adc489e067eb10 | +| version | ❌ | pyproject.toml declares 0.5.0; expected 0.6.0 | diff --git a/docs/screenshots/src/tests-gate-fail.txt b/docs/screenshots/src/tests-gate-fail.txt new file mode 100644 index 0000000..1099890 --- /dev/null +++ b/docs/screenshots/src/tests-gate-fail.txt @@ -0,0 +1,9 @@ +$ REPOSITORY=Stephenson-Software/tak SHA=2bb6938ed2a1aed644f3e96163adc489e067eb10 \ + PACKAGE=tak EXPECTED_VERSION=0.6.0 PYTHON_VERSIONS=3.12 WORK=/tmp/prg-work \ + python3.12 gates/tests_gate.py 2>&1 +$ git -C /tmp/prg-work/src rev-parse HEAD +2bb6938ed2a1aed644f3e96163adc489e067eb10 +PASS checkout: checked out 2bb6938ed2a1aed644f3e96163adc489e067eb10 +FAIL version: pyproject.toml declares 0.5.0; expected 0.6.0 +$ echo "exit $?" +exit 1 diff --git a/docs/screenshots/src/tests-gate-pass.summary.md b/docs/screenshots/src/tests-gate-pass.summary.md new file mode 100644 index 0000000..0a75a17 --- /dev/null +++ b/docs/screenshots/src/tests-gate-pass.summary.md @@ -0,0 +1,10 @@ +## Tests gate — PASSED +`Stephenson-Software/tak` @ `2bb6938ed2a1aed644f3e96163adc489e067eb10` + +| assertion | result | detail | +|---|---|---| +| checkout | ✅ | checked out 2bb6938ed2a1aed644f3e96163adc489e067eb10 | +| version | ✅ | pyproject.toml declares 0.5.0; expected 0.5.0 | +| install-3.12 | ✅ | pip install .[dev] | +| import-3.12 | ✅ | tak 0.5.0 from /tmp/prg-work/venv-3.12/lib/python3.12/site-packages/tak | +| tests-3.12 | ✅ | 383 passed in 111.21s (0:01:51) | diff --git a/docs/screenshots/src/tests-gate-pass.txt b/docs/screenshots/src/tests-gate-pass.txt new file mode 100644 index 0000000..89edf7b --- /dev/null +++ b/docs/screenshots/src/tests-gate-pass.txt @@ -0,0 +1,10 @@ +$ REPOSITORY=Stephenson-Software/tak SHA=2bb6938ed2a1aed644f3e96163adc489e067eb10 \ + PACKAGE=tak EXPECTED_VERSION=0.5.0 PYTHON_VERSIONS=3.12 WORK=/tmp/prg-work \ + python3.12 gates/tests_gate.py 2>&1 | grep -E '^(PASS|FAIL) ' +PASS checkout: checked out 2bb6938ed2a1aed644f3e96163adc489e067eb10 +PASS version: pyproject.toml declares 0.5.0; expected 0.5.0 +PASS install-3.12: pip install .[dev] +PASS import-3.12: tak 0.5.0 from /tmp/prg-work/venv-3.12/lib/python3.12/site-packages/tak +PASS tests-3.12: 383 passed in 111.21s (0:01:51) +$ echo "exit ${PIPESTATUS[0]}" +exit 0 diff --git a/docs/screenshots/tests-gate-pass-fail.png b/docs/screenshots/tests-gate-pass-fail.png new file mode 100644 index 0000000..50951b1 Binary files /dev/null and b/docs/screenshots/tests-gate-pass-fail.png differ