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
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ scenarios/ Per-library save scenarios: `write DIR`, `read DIR` (o
trace_client_install_id.py trace-client-python install-ID file (install_id_from_file)
gardener_state.py gardener's per-device state dir (run history, lists, cursor, hub store)
usd_recorder_recordings.py usd-recorder's .usda/.usdc recordings and usd-replay/1 replays
darkroom_state.py darkroom's .darkroom/state.json and takes (nothing reshot on upgrade)
menu_bot.py a seeded bot standing in for a menu-driven game's front-end (used by the game scenarios)
tak_game_saves.py Tidewater / Overwinter / Night Ferry saves, played through the game (checkout mode)
fishe_saves.py FishE saves, flat (2.x) and slotted layouts, played through the game (checkout mode)
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Each gate adds its own keys beside these, set as far as the run got:
| `python_versions` | `3.12` | comma-separated interpreters |
| `install_extras` | `dev` | extras installed with the package |
| `test_command` | `python -m pytest -q` | run in the checkout; a leading `python` or `python3` is the gate's virtualenv |
| `expected_version` | `""` | the `[project] version` pyproject.toml must declare |
| `expected_version` | `""` | the `[project] version` pyproject.toml must declare. When pyproject.toml's version is dynamic (`dynamic = ["version"]`, read from the package at build time; `v7`), `package` must be set and its installed `__version__` must equal this on every interpreter |

Assertions: `checkout`, `version` (only when `expected_version` is set), then for each
interpreter `install-<py>`, `import-<py>` (only when `package` is set), `tests-<py>`.
Expand Down Expand Up @@ -192,6 +192,17 @@ readers report: `inspect_stage`, `has_clips`, every attribute and computed visib
at every tick for a stage, and `validate_replay`, `replay_info` and `read_replay` for a
replay.

[`scenarios/darkroom_state.py`](scenarios/darkroom_state.py) covers darkroom's per-project
state: `.darkroom/state.json` and the takes under `.darkroom/takes/`, beside a shot list. The
baseline shoots two projects with the `command` backend and a standard-library stand-in for a
capture program (stills, a clip with GIF, poster and contact sheet, a still under two tags, a
prep and the still that depends on it, and a shot recorded by `shoot --adopt`). darkroom
promises that upgrading does not by itself make a shot stale, so each version's view of a
project is what its own `shoot` does to it: every shot `kept` (state entry, take and outputs
byte-identical) or `rewritten`, plus whether the recorded hashes equal that version's own and
the outputs it expects. darkroom's capture hash includes the project's absolute path, so that
shoot runs in place and the project is restored byte for byte from a copy afterwards.

### Game scenarios (checkout mode)

Four scenarios cover games that are run from a checkout. Each one **plays** the baseline: the
Expand Down Expand Up @@ -255,6 +266,12 @@ gh workflow run save-compat.yml --repo Stephenson-Software/python-release-gates
-f scenario=scenarios/usd_recorder_recordings.py -f distribution=usd-recorder
```

```
gh workflow run save-compat.yml --repo Stephenson-Software/python-release-gates --ref v7 \
-f repository=Preponderous-Software/darkroom -f sha=<commit> -f baseline_ref=v0.7.1 \
-f scenario=scenarios/darkroom_state.py -f distribution=darkroom
```

Reference a tag, never a branch, so that a change here cannot alter a check already in
progress.

Expand All @@ -272,6 +289,7 @@ it fails as `harness`. Each tag holds everything in the tags before it.
| `v4` | `tak_game_saves.py`, `fishe_saves.py`, `cave_saves.py`, `ophidian_saves.py`, `menu_bot.py`; an unknown `pin_sources` fails as `harness` with a `result.json` (before, the gate exited with none) |
| `v5` | `SAVE_MIGRATIONS`, declared by `fishe_saves.py` |
| `v6` | `complete` in `result.json` and the summary's `DID NOT FINISH`; a package without `__version__` passes `import-<py>` (in `v5` and earlier it fails); stderr after a scenario's JSON line no longer fails the read (in `v5` and earlier it does); a view must be a JSON object (in `v5` and earlier any JSON on the last line is taken as the view); a URL pin must name the repository whole, so `owner/tak-client` no longer pins `owner/tak` (in `v5` and earlier the consumer is tested, not skipped); a baseline write or fixture that leaves only directories fails `baseline-write` or `fixture` (in `v5` and earlier it passes with `0 file(s)`); an indented `version` key, or a comment after the `[project]` header, is read by the `version` check (in `v5` and earlier it reads as none, so `version` fails); the gate jobs run on `ubuntu-24.04`, where Python 3.8 and 3.9 can be set up (in `v5` and earlier they run on `ubuntu-latest`, which no longer has them) |
| `v7` | `darkroom_state.py`; a dynamic version (`dynamic = ["version"]` in pyproject.toml) is checked through the installed package's `__version__`, which every `import-<py>` must report as `expected_version` (in `v6` and earlier `version` fails, since pyproject.toml declares none) |

## License

Expand Down
35 changes: 29 additions & 6 deletions gates/tests_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
Assertions, in order — the run stops at the first failure:

checkout the candidate commit is checked out (infrastructure if not)
version the version the build file declares equals EXPECTED_VERSION (when given)
version the version the build file declares equals EXPECTED_VERSION (when given);
when pyproject.toml's version is dynamic (v7), PACKAGE must be set, and
the import-<py> checks hold its `__version__` to EXPECTED_VERSION instead
install-<py> `pip install <install spec>` succeeds on interpreter <py>
import-<py> the package imports from the installed copy and, when it defines
`__version__`, reports EXPECTED_VERSION
`__version__`, reports EXPECTED_VERSION (with a dynamic version it must
define it)
tests-<py> TEST_COMMAND exits 0 (pytest's summary line is quoted)

Environment (set by the workflow from its inputs): REPOSITORY, SHA, PACKAGE, PYTHON_VERSIONS,
Expand Down Expand Up @@ -38,6 +41,17 @@ def declared_version(src: Path) -> str:
return v.group(1) if v else ""


def version_is_dynamic(src: Path) -> bool:
"""pyproject.toml's `[project]` lists `version` in `dynamic` (the build reads it from the
package, e.g. setuptools' `version = {attr = "pkg._version.__version__"}`)."""
text = (src / "pyproject.toml").read_text() if (src / "pyproject.toml").exists() else ""
m = re.search(r"^\[project\][ \t]*(?:#[^\n]*)?$(.*?)(?=^\[|\Z)", text, re.M | re.S)
if not m:
return False
d = re.search(r"^[ \t]*dynamic\s*=\s*\[([^\]]*)\]", m.group(1), re.M)
return bool(d) and re.search(r"""["']version["']""", d.group(1)) is not None


PROBE_TAG = "prg-import-probe "


Expand Down Expand Up @@ -78,8 +92,16 @@ def main() -> int:
head = run(["git", "-C", str(src), "rev-parse", "HEAD"])[1].strip()
result.check("checkout", head == sha, f"checked out {head}")
declared = declared_version(src)
dynamic = not declared and version_is_dynamic(src)
result.doc["version"] = declared
if expected:
result.doc["versionDynamic"] = dynamic
if expected and dynamic:
# Nothing to read in pyproject.toml: the version is the package's own __version__,
# which every import-<py> check below must then report exactly.
result.check("version", bool(package),
f"pyproject.toml's version is dynamic; each import-<py> check holds {package}.__version__ to {expected}"
if package else f"pyproject.toml's version is dynamic and no package was given to read it from; expected {expected}")
elif expected:
result.check("version", declared == expected, f"pyproject.toml declares {declared or '(none)'}; expected {expected}")
for py in pythons:
interp = make_venv(work / f"venv-{py}", f"python{py}")
Expand All @@ -89,11 +111,12 @@ def main() -> int:
if package:
code, out = run([str(interp), "-c", import_probe(package)], cwd=work)
where, ver = parse_probe(out)
ok = code == 0 and "site-packages" in where and (not expected or not ver or ver == expected)
ok = (code == 0 and "site-packages" in where
and (not expected or ver == expected or (not ver and not dynamic)))
detail = (f"{package} {ver or '(no __version__)'} from {where}" if code == 0
else f"import failed: {tail(out)}")
if code == 0 and expected and ver and ver != expected:
detail += f"; expected {expected}"
if code == 0 and expected and ver != expected and (ver or dynamic):
detail += f"; expected {expected}" + (" (pyproject.toml's version is dynamic)" if dynamic else "")
result.check(f"import-{py}", ok, detail)
# The suite runs against the INSTALLED copy where the project allows it; a
# `pythonpath = ["src"]` pytest setting points it back at the checkout, which is
Expand Down
Loading
Loading