Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__pycache__/
*.pyc
work/
docs/screenshots/build/
docs/screenshots/.darkroom/
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
52 changes: 52 additions & 0 deletions docs/screenshots/media.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
84 changes: 84 additions & 0 deletions docs/screenshots/render.py
Original file line number Diff line number Diff line change
@@ -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 = """<!doctype html><html><head><meta charset="utf-8"><title>{title}</title><style>
body{{margin:0;padding:24px;background:#eef1f5;font:14px/1.5 -apple-system,"Segoe UI",Helvetica,Arial,sans-serif}}
.shot{{display:inline-flex;flex-direction:column;gap:20px;max-width:1180px}}
.term{{background:#0d1117;color:#c9d1d9;border-radius:10px;box-shadow:0 6px 20px rgba(0,0,0,.25);overflow:hidden}}
.bar{{background:#21262d;padding:8px 12px;display:flex;gap:7px;align-items:center;color:#8b949e;font-size:12px}}
.dot{{width:11px;height:11px;border-radius:50%;background:#484f58}}
.bar span.t{{margin-left:10px}}
pre{{margin:0;padding:14px 18px 16px;font:13px/1.55 "DejaVu Sans Mono",Menlo,Consolas,monospace;white-space:pre-wrap;word-break:break-all}}
.cmd{{color:#79c0ff}} .pass{{color:#3fb950;font-weight:bold}} .fail{{color:#f85149;font-weight:bold}} .dim{{color:#8b949e}}
.sum{{background:#fff;border:1px solid #d0d7de;border-radius:8px;padding:6px 20px 16px;color:#1f2328}}
.sum h2{{font-size:20px;border-bottom:1px solid #d8dee4;padding-bottom:6px}}
.sum code{{background:#eff1f3;padding:2px 5px;border-radius:5px;font:12px "DejaVu Sans Mono",monospace}}
.sum table{{border-collapse:collapse}} .sum th,.sum td{{border:1px solid #d0d7de;padding:5px 12px;text-align:left}}
.sum th{{background:#f6f8fa}}
</style></head><body><div class="shot">{body}</div></body></html>"""


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'<span class="cmd">{line}</span>'
elif raw.startswith("PASS "):
line = re.sub(r"^PASS (\S+:)", r'<span class="pass">PASS</span> <b>\1</b>', line)
elif raw.startswith("FAIL "):
line = re.sub(r"^FAIL (\S+:)", r'<span class="fail">FAIL</span> <b>\1</b>', line)
else:
line = f'<span class="dim">{line}</span>'
lines.append(line)
bar = '<div class="bar"><i class="dot"></i><i class="dot"></i><i class="dot"></i>' \
f'<span class="t">{html.escape(path.stem)}</span></div>'
return f'<div class="term">{bar}<pre>{chr(10).join(lines)}</pre></div>'


def inline(text: str) -> str:
return re.sub(r"`([^`]*)`", r"<code>\1</code>", 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"<h2>{inline(raw[3:])}</h2>")
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"<p>{inline(raw)}</p>")
if rows:
head = "".join(f"<th>{inline(c)}</th>" for c in rows[0])
body = "".join("<tr>" + "".join(f"<td>{inline(c)}</td>" for c in r) + "</tr>" for r in rows[1:])
out.append(f"<table><tr>{head}</tr>{body}</table>")
return f'<div class="sum">{"".join(out)}</div>'


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)])
Binary file added docs/screenshots/run-summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/save-compat-tak-pass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions docs/screenshots/src/save-compat-tak-pass.txt
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions docs/screenshots/src/tests-gate-fail.summary.md
Original file line number Diff line number Diff line change
@@ -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 |
9 changes: 9 additions & 0 deletions docs/screenshots/src/tests-gate-fail.txt
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions docs/screenshots/src/tests-gate-pass.summary.md
Original file line number Diff line number Diff line change
@@ -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) |
10 changes: 10 additions & 0 deletions docs/screenshots/src/tests-gate-pass.txt
Original file line number Diff line number Diff line change
@@ -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
Binary file added docs/screenshots/tests-gate-pass-fail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading