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. + + +*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. + + + +**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. + + + +### 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 = """
{chr(10).join(lines)}\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)}
") + if rows: + head = "".join(f"