From 4156f10b7f4faf17e3c8896e3e4eee8fb4be87ec Mon Sep 17 00:00:00 2001 From: homelabforge Date: Tue, 6 Oct 2026 17:57:41 -0500 Subject: [PATCH 1/2] fix: review follow-ups for v1.7.0 ($/ action inputs, lockstep quoting, report retention) Co-Authored-By: Claude Opus 5.5 --- .github/scripts/check_suite.py | 26 ++++++- .github/scripts/test_check_suite.py | 83 +++++++++++++++++++++++ .github/workflows/_python-react-tests.yml | 5 +- .github/workflows/lint.yml | 2 + .github/workflows/python-react-ci.yml | 5 +- .github/workflows/release.yml | 5 +- CHANGELOG.md | 5 ++ README.md | 5 +- 8 files changed, 127 insertions(+), 9 deletions(-) create mode 100644 .github/scripts/test_check_suite.py diff --git a/.github/scripts/check_suite.py b/.github/scripts/check_suite.py index af02f19..304baaf 100644 --- a/.github/scripts/check_suite.py +++ b/.github/scripts/check_suite.py @@ -8,6 +8,8 @@ uses those names. A skipped job reports Success to branch protection. 3. Steps call this repo's own actions through `$/`. A consumer that requires SHA-pinned actions refuses a tag ref, and `./` means the consumer's checkout. + The action has to exist and get exactly the inputs it takes, since actionlint + can't check a `$/` ref. """ import sys @@ -115,8 +117,30 @@ def check_action_refs() -> list[str]: steps += doc.get("runs", {}).get("steps", []) for step in steps: uses = str(step.get("uses", "")) - if ".github/actions/" in uses and not uses.startswith("$/"): + if ".github/actions/" not in uses: + continue + if not uses.startswith("$/"): problems.append(f"{path}: {uses} has to be $/.github/actions/...") + continue + # actionlint can't follow `$/` and we mute it there, so check the + # action exists and gets the inputs it takes here instead. + action = Path(uses[2:]) / "action.yml" + if not action.is_file(): + problems.append(f"{path}: {uses} has no {action}") + continue + doc_inputs = yaml.safe_load(action.read_text(encoding="utf-8")) + inputs = doc_inputs.get("inputs") or {} + passed = set(step.get("with") or {}) + for name in sorted(passed - set(inputs)): + problems.append(f"{path}: {uses} doesn't take input {name}") + for name, spec in inputs.items(): + spec = spec or {} + if ( + spec.get("required") + and "default" not in spec + and name not in passed + ): + problems.append(f"{path}: {uses} needs input {name}") return problems diff --git a/.github/scripts/test_check_suite.py b/.github/scripts/test_check_suite.py new file mode 100644 index 0000000..d7f1a70 --- /dev/null +++ b/.github/scripts/test_check_suite.py @@ -0,0 +1,83 @@ +"""Tests for check_suite.py's own-action check, against a throwaway repo layout.""" + +import os +import tempfile +import textwrap +import unittest +from pathlib import Path + +import check_suite + +ACTION = """\ +name: A +inputs: + reports-dir: + required: true + count: + required: true + note: + required: false +runs: + using: composite + steps: [] +""" + + +def workflow(uses: str, with_: str) -> str: + head = "on: push\njobs:\n j:\n runs-on: ubuntu-latest\n steps:\n" + step = f" - uses: {uses}\n with:\n" + return head + step + textwrap.indent(with_, " " * 10) + "\n" + + +class ActionRefs(unittest.TestCase): + def setUp(self) -> None: + self.cwd = Path.cwd() + self.tmp = tempfile.TemporaryDirectory() + os.chdir(self.tmp.name) + Path(".github/workflows").mkdir(parents=True) + Path(".github/actions/a").mkdir(parents=True) + Path(".github/actions/a/action.yml").write_text(ACTION, encoding="utf-8") + + def tearDown(self) -> None: + os.chdir(self.cwd) + self.tmp.cleanup() + + def problems(self, uses: str, with_: str) -> list[str]: + Path(".github/workflows/w.yml").write_text( + workflow(uses, with_), encoding="utf-8" + ) + return check_suite.check_action_refs() + + def test_dollar_slash_with_its_inputs_passes(self) -> None: + self.assertEqual( + self.problems("$/.github/actions/a", "reports-dir: r\ncount: 2"), [] + ) + + def test_tag_ref_is_refused(self) -> None: + found = self.problems( + "homelabforge/shared-workflows/.github/actions/a@v1.7.0", + "reports-dir: r\ncount: 2", + ) + self.assertEqual(len(found), 1) + self.assertIn("has to be $/", found[0]) + + def test_misspelled_action_path(self) -> None: + found = self.problems("$/.github/actions/b", "reports-dir: r\ncount: 2") + self.assertEqual(len(found), 1) + self.assertIn("no .github/actions/b/action.yml", found[0]) + + def test_input_the_action_does_not_take(self) -> None: + found = self.problems( + "$/.github/actions/a", "reports-dir: r\ncount: 2\nreport-dir: r" + ) + self.assertEqual(len(found), 1) + self.assertIn("report-dir", found[0]) + + def test_required_input_left_out(self) -> None: + found = self.problems("$/.github/actions/a", "reports-dir: r") + self.assertEqual(len(found), 1) + self.assertIn("count", found[0]) + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/workflows/_python-react-tests.yml b/.github/workflows/_python-react-tests.yml index ba35739..beb65ef 100644 --- a/.github/workflows/_python-react-tests.yml +++ b/.github/workflows/_python-react-tests.yml @@ -161,9 +161,10 @@ jobs: name: pytest-shard-report-backend-${{ matrix.shard }} path: backend/pytest-shard-report.json if-no-files-found: error - # A "re-run failed jobs" shard uploads the same name again. + # A "re-run failed jobs" shard uploads the same name again. The + # shards that passed don't, so theirs has to last past a weekend. overwrite: true - retention-days: 1 + retention-days: 7 test-backend: name: Backend Tests diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f22ef77..33df4bb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -40,3 +40,5 @@ jobs: run: | python -m pip install --quiet 'pyyaml==6.0.3' python .github/scripts/check_suite.py + - name: Suite structure selftests + run: python -m unittest discover -s .github/scripts -p 'test_*.py' -v diff --git a/.github/workflows/python-react-ci.yml b/.github/workflows/python-react-ci.yml index b69442e..9d60e28 100644 --- a/.github/workflows/python-react-ci.yml +++ b/.github/workflows/python-react-ci.yml @@ -245,9 +245,10 @@ jobs: name: pytest-shard-report-pg-${{ matrix.shard }} path: backend/pytest-shard-report.json if-no-files-found: error - # A "re-run failed jobs" shard uploads the same name again. + # A "re-run failed jobs" shard uploads the same name again. The + # shards that passed don't, so theirs has to last past a weekend. overwrite: true - retention-days: 1 + retention-days: 7 - name: Tear down stack if: always() diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7435a3..2090645 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,8 +42,9 @@ jobs: .github/workflows/_python-react-tests.yml; do # Every `uses:` back into this repo has to name the tag being cut. # Anchored on real `uses:` lines so a comment can't satisfy it. - refs=$(grep -E '^[[:space:]-]*uses:[[:space:]]*homelabforge/shared-workflows/' "$f" \ - | grep -oE '@[^[:space:]]+' | sed 's/^@//' || true) + # Quoted or differently cased refs count too, GitHub resolves those. + refs=$(grep -iE "^[[:space:]-]*uses:[[:space:]]*[\"']?homelabforge/shared-workflows/" "$f" \ + | grep -oE "@[^[:space:]\"']+" | sed 's/^@//' || true) # The suite calls nothing back here today; the callers always do. if [ -z "$refs" ] && [ "$f" = .github/workflows/_python-react-tests.yml ]; then continue diff --git a/CHANGELOG.md b/CHANGELOG.md index c2dce09..01ade63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Pytest shard reports are kept 7 days, not 1, so "re-run failed jobs" a day later still finds the ones that passed. +- `check_suite.py` checks a `$/` action exists and gets the inputs it takes, which actionlint can't. +- `release.yml`'s ref-lockstep also catches quoted and differently cased internal refs. + ## [1.7.0] - 2026-10-06 Promotes 1.7.0-rc2, canaried on mygarage #214: its CI went from 12m23s to 3m47s and 4m37s on two measured runs. diff --git a/README.md b/README.md index 7acb73e..2132ea6 100644 --- a/README.md +++ b/README.md @@ -121,8 +121,9 @@ the consumer's `ci.yml`. reads the env below, keeps its share of whole test modules and writes a report. The keeper then fails the run unless the reports cover every collected module exactly once (`.github/actions/verify-pytest-shards`). A consumer without the - hook works at 1 shard; above 1 the verify step fails ("expected N shard - reports, found 0"). mygarage's `backend/tests/_shard.py` is the reference hook. + hook works at 1 shard; above 1 every shard runs the whole suite, then fails + its "Upload shard report" step (no `pytest-shard-report.json`), so the keeper + goes red. mygarage's `backend/tests/_shard.py` is the reference hook. The pytest contract, set on every pytest run in a sharded job (backend and PG): From 754b6b3646af48d5c9267fef967523a30e2523a0 Mon Sep 17 00:00:00 2001 From: homelabforge Date: Tue, 6 Oct 2026 18:04:05 -0500 Subject: [PATCH 2/2] fix: check_suite knows action.yaml and .yaml workflows too Co-Authored-By: Claude Opus 5.5 --- .github/scripts/check_suite.py | 19 +++++++++++++---- .github/scripts/test_check_suite.py | 32 ++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/.github/scripts/check_suite.py b/.github/scripts/check_suite.py index 304baaf..728b311 100644 --- a/.github/scripts/check_suite.py +++ b/.github/scripts/check_suite.py @@ -108,7 +108,10 @@ def check_keepers() -> list[str]: def check_action_refs() -> list[str]: problems: list[str] = [] - files = sorted(WORKFLOWS.glob("*.yml")) + sorted(ACTIONS.glob("*/action.yml")) + # GitHub takes both spellings, for workflows and for action metadata. + files = sorted([*WORKFLOWS.glob("*.yml"), *WORKFLOWS.glob("*.yaml")]) + sorted( + [*ACTIONS.glob("*/action.yml"), *ACTIONS.glob("*/action.yaml")] + ) for path in files: doc = yaml.safe_load(path.read_text(encoding="utf-8")) steps = [ @@ -124,10 +127,18 @@ def check_action_refs() -> list[str]: continue # actionlint can't follow `$/` and we mute it there, so check the # action exists and gets the inputs it takes here instead. - action = Path(uses[2:]) / "action.yml" - if not action.is_file(): - problems.append(f"{path}: {uses} has no {action}") + folder = Path(uses[2:]) + found = [ + folder / n + for n in ("action.yml", "action.yaml") + if (folder / n).is_file() + ] + if not found: + problems.append( + f"{path}: {uses} has no action.yml or action.yaml in {folder}" + ) continue + action = found[0] doc_inputs = yaml.safe_load(action.read_text(encoding="utf-8")) inputs = doc_inputs.get("inputs") or {} passed = set(step.get("with") or {}) diff --git a/.github/scripts/test_check_suite.py b/.github/scripts/test_check_suite.py index d7f1a70..395e7c1 100644 --- a/.github/scripts/test_check_suite.py +++ b/.github/scripts/test_check_suite.py @@ -64,7 +64,37 @@ def test_tag_ref_is_refused(self) -> None: def test_misspelled_action_path(self) -> None: found = self.problems("$/.github/actions/b", "reports-dir: r\ncount: 2") self.assertEqual(len(found), 1) - self.assertIn("no .github/actions/b/action.yml", found[0]) + self.assertIn("no action.yml or action.yaml in .github/actions/b", found[0]) + + def test_action_yaml_filename_resolves(self) -> None: + Path(".github/actions/c").mkdir() + Path(".github/actions/c/action.yaml").write_text(ACTION, encoding="utf-8") + self.assertEqual( + self.problems("$/.github/actions/c", "reports-dir: r\ncount: 2"), [] + ) + + def test_steps_inside_an_action_yaml_are_scanned(self) -> None: + Path(".github/actions/c").mkdir() + Path(".github/actions/c/action.yaml").write_text( + "name: C\nruns:\n using: composite\n steps:\n" + " - uses: homelabforge/shared-workflows/.github/actions/a@v1.7.0\n", + encoding="utf-8", + ) + found = self.problems("$/.github/actions/a", "reports-dir: r\ncount: 2") + self.assertEqual(len(found), 1) + self.assertIn("action.yaml", found[0]) + + def test_yaml_workflows_are_scanned(self) -> None: + Path(".github/workflows/v.yaml").write_text( + workflow( + "homelabforge/shared-workflows/.github/actions/a@v1.7.0", + "reports-dir: r\ncount: 2", + ), + encoding="utf-8", + ) + found = self.problems("$/.github/actions/a", "reports-dir: r\ncount: 2") + self.assertEqual(len(found), 1) + self.assertIn("v.yaml", found[0]) def test_input_the_action_does_not_take(self) -> None: found = self.problems(