Skip to content

infra: Port the check-changes changed-file gate to Python and clear its GEN-005 exception #2683

Closed

Description

@zackees

Gap

ci-lint precheck reports one GEN-005 finding on .github/actions/check-changes/action.yaml:

[GEN-005] APPROVED EXCEPTION .github/actions/check-changes/action.yaml
    what:  runs.steps[0]: run: step violates the shell budget (more than one line)
    fix:   replace runs.steps[0] with a single call to a Python script, e.g. 'run: uv run --no-project --script ...'

That step is 50 lines of bash that resolve a base reference and diff it:

  • an explicit baseRef is used as given; when it is not an object in the checkout a ::warning:: is printed and, with useFallback: true (the default), the comparison falls back to HEAD~1;
  • with no baseRef, the event decides: pull_request → origin/<base branch>, push → github.event.before unless the push was forced, everything else (workflow_dispatch, schedule, merge queue) → the merge base with the default branch (chore: fix small issues found during the grind run and CI speed-up #13);
  • a push whose before is not in the checkout compares against the empty tree;
  • the result is written to $GITHUB_OUTPUT as hasChangedFiles and a compact JSON changedFiles list.

This gate is on the path of every PR and push, and it is the decision point for the two data validators, the docs job and the Qt XML check — a shell block that had no test of its own.

Call sites (coverage map)

Caller Inputs used
ci.yml validate-data (× 2) baseRef: origin/<base_ref>, glob on the compat / rtmp-services JSON
ci.yml update-documentation baseRef: origin/<base_ref>, glob docs/sphinx
push.yaml (× 3) baseRef: github.event.before, globs incl. !(cmake*)
scheduled.yaml baseRef: steps.nightly-checks.outputs.lastNightly, glob **/en-US.ini
qt-xml-validator, run-swift-format (composite actions) checkGlob on frontend/forms/**/*.ui

None of those jobs install Python before the step — validate-data is a bare ubuntu-latest with only actions/checkout — so the action has to bring uv itself, exactly as .github/actions/generate-docs does after #2681.

Work

  • ci/check_changes.py (uv run --no-project --script, standard library only) does the resolution and the diff; the action's step becomes one line and gains a pinned astral-sh/setup-uv step (with the save-cache expression and the CACHE-013 pr-<N> cache-suffix).
  • ci/test_check_changes.py pins the module against a real git fixture: explicit baseRef, no-match, empty glob, push before, forced push, dispatch merge base, invalid baseRef with and without useFallback, the diff filter, both caller globs, and a file name with a space.
  • The GEN-005 [[exceptions]] block for the action is deleted with the port.

Two deliberate differences, both in the callers' favour: the glob is passed to git diff as one argument, so a path with a space stays one entry (the shell word-split it), and the one extglob call site, !(cmake*) in push.yaml, becomes git's own :(exclude,top)cmake* — the same "everything except the top-level cmake* entries" that bash expanded to, without needing a shell.

Evidence

Before the change the module and the fixture test were run against the old bash step (bash -e -o pipefail, same env contract) over 12 base-reference/glob cases; the outputs agree on all 12, including the !(cmake*) expansion and the fatal: bad revision exit when useFallback is false.

  • ci-lint precheck before: 11 violation(s), 490 approved exception(s), 10 needs_review
  • ci-lint precheck after: 11 violation(s), 489 approved exception(s), 10 needs_review, with no check-changes finding left
  • ci/test_ci_toml.py 41 tests OK, ci/test_uv_run.py 5 tests OK, ruff check clean

RED 306b97572 (test only: 17 tests, 3 failures + 14 errors — module missing, step still a run: | block, exception still present), GREEN 12b07d4c5. No docs/features.md line: build tooling only.

Activity

  1. added
    infra
    ready
    on Oct 27, 2026
  2. zackees commented on Oct 27, 2026

    @zackees
    MemberAuthor

    Claiming: the check-changes shell-budget port.

    Plan (one PR, two commits, local RED evidence):

    1. RED 306b97572: ci/test_check_changes.py pins the action's base-reference rules against a real git fixture (17 tests; 3 failures + 14 errors on master — the module does not exist, the step is still a run: | block, and the GEN-005 block is still in ci.toml).
    2. GREEN 12b07d4c5: ci/check_changes.py does the work, the action's step is one uv run --no-project --script line with a pinned setup-uv step (its callers install nothing), and the ci.toml GEN-005 block is deleted. ci-lint precheck 490 -> 489 approved exceptions, same 11 violations, no new finding.

    Already verified locally: the old bash step and the new module were diffed over 12 base-reference/glob cases (both agree, including the !(cmake*) expansion and the bad revision exit), plus ci/test_ci_toml.py, ci/test_uv_run.py and ruff check. PR opens now.

  3. zackees commented on Oct 27, 2026

    @zackees
    MemberAuthor

    Opened #2684 (branch infra/check-changes-python, base master, 2 commits): RED 306b97572 (17 tests: 3 failures + 14 errors on master), GREEN 12b07d4c5 (17 tests OK, ci-lint precheck 490 -> 489 approved exceptions with no new finding). Watching it through PR CI.

  4. zackees commented on Oct 27, 2026

    @zackees
    MemberAuthor

    Landed: #2684 merged into master as 190d3098e (2026-10-27 20:13Z, merge-queue run green).

    What changed: .github/actions/check-changes/action.yaml's 50-line run: | block is now one uv run --no-project --script ci/check_changes.py --check-glob … call; the action brings its own pinned astral-sh/setup-uv step; ci/check_changes.py keeps the base-reference rules (explicit baseRef + useFallback warning, push before, pull_request origin/<base>, dispatch/schedule merge base, empty-tree fallback, diffFilter); ci/test_check_changes.py pins them against a real git fixture; the GEN-005 exception for the action is gone from ci.toml.

    Verified on the queued head before merge: Validate Data 🕵️ (both check-changes calls, 19 s) and Format 🔍 / checks (qt-xml-validator → check-changes) passed, CI Gate ✅. ci-lint precheck on master now reads 11 violation(s), 489 approved exception(s), 10 needs_review — the burn-down moves 490 → 489. Nothing outstanding on this issue.

  5. zackees commented on Oct 27, 2026

    @zackees
    MemberAuthor

    Landed: #2684 merged as 190d3098e (merge-queue run green) — .github/actions/check-changes/action.yaml's inline run: | block is now ci/check_changes.py, and its GEN-005 exception is gone (ci-lint precheck 490 -> 489). Nothing left on the issue; closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

infraready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions