Repository navigation
ci: run each macOS role job only when its role or shared files change - #235
Merged
Merged
Conversation
A new Ubuntu `changes` job diffs a pull request's merge commit against its base and selects the role jobs whose files it touches, through scripts/ci-role-matrix.sh, which now holds the matrix table. Shared files (the workflow, the playbook entry points, play-scoped role dirs and the task files carrying `always` tasks) select every job, as does a push to main or any failure to compute the diff. A pull request selecting none skips the macOS test job outright. scripts/ci-role-matrix-test.sh pins the selection and fails when a role's tasks run a script that would not start its job. services-declaration-test reads the matrix from the selector and pins the pre-existing entries instead of forbidding any removed workflow line.
git diff quotes a path holding a non-ASCII or special byte, and the quoted form matched no trigger, so such a change started none of its role jobs. Planwright-Sign-Off: PS-1
A task file carrying a role job's tag runs in that job, and one carrying `always` runs in every job; the suite now fails when editing either would start none of them, so a new tag or always task cannot slip past the filter. Planwright-Sign-Off: PS-2
- .github/copilot-instructions.md — before: `.github/workflows/test.yml` declares strict_idempotency per role · after: `scripts/ci-role-matrix.sh` declares it - scripts/ci-role-matrix.sh header — before: "the four task files" holding always tasks, and upgrade's roles listed by name · after: no count or restated list; the suite's tag guard is named instead Planwright-Sign-Off: PS-3
The tag guard reads inline lists only, so a task tagged `tags: always` or with a block sequence would have passed unread; any such form now fails the suite with the file and line to rewrite. Planwright-Sign-Off: PS-4
The workflow relies on a 8000 bad invocation exiting non-zero, so its selection step fails visibly instead of handing the test job an empty matrix; the suite now holds the selector to that. Planwright-Sign-Off: PS-5
The guard only saw a column-0 `. "$script_dir/..."`, so a script sourced with `source`, braces or indentation would have dropped out of its role job's triggers unnoticed. Planwright-Sign-Off: PS-6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every pull request started all nine macOS role jobs (
test (<role>)) whatever it touched, and macOS runner queueing now dominates CI time. A new Ubuntuchangesjob now picks which role jobs a pull request needs: those whoseroles/<role>/files, or the scripts their tasks run, it changes. Shared files start every job. Pushes to main still run all nine.How to review:
scripts/ci-role-matrix.sh(the matrix table, trigger paths and shared set),scripts/ci-role-matrix-test.sh(fixtures and drift guards), thechanges/testjobs in.github/workflows/test.yml, and the matrix checks inscripts/services-declaration-test.sh.main.yml,hosts,ansible.cfg,group_vars/,become_plugins/,mise.toml,scripts/playbook.sh, every role'sdefaults/ vars/ meta/ handlers/(loaded into every play), and the task files holdingtags: [always]tasks (they run under any tag). These were found by reading the tags and{{ ansible_facts.env.PWD }}/scripts/references, not guessed.roles/<role>/, plus the scripts its tasks run and what those source.osxandupgradealso take the Brewfiles.upgradetakes every role holding upgrade-tagged tasks.always) would not start it, or when a task's tags are not written as an inline list it can read.Required checks
Main's ruleset (
default) has arequired_status_checksrule with an empty list, so no check is required. A pull request that selects no role skips thetestjob, which reports as skipped rather than pending, and the PR stays mergeable. If atest (<role>)leg is ever made required, a skipped matrix never creates that leg and the check would wait: requirechangesorlintinstead.Before / after
Verification
changesjob runsscripts/ci-role-matrix-test.shfirst, so this PR's own CI log shows thespecs-onlycase (specs/ and docs/ paths →no role job) andclaude-only. Dry run:specs/matches no role pattern, no shared pattern and no play-scoped role dir, soincludeis[],testis skipped, and a skipped job blocks nothing under the ruleset above.test (git): thegit-onlycase (roles/git/files/gitconfig,roles/git/tasks/main.yml→git) in the same log. Dry run:roles/git/*is in git's triggers only, and neither path is shared or play-scoped. A change toroles/git/defaults/would start all nine, since role defaults load into every play.Open items for the operator
pre-commit.commands:ci-role-matrix-test.shon main failschangesand skips the role jobs there. That failure shows as a red check, and the PR run catches it before a merge. Declined.origin/main. Moving the matrix out of the workflow makes that impossible. It now pins the pre-existing entries with their values in the selector's output, and checks that the test job still reads its matrix fromchanges. REQ-E1.4 is scoped to the dev-services bundle, whose diff is long merged.Audit record
Lens coverage (polish, final pass; inline walk, small diff)
Auto-applicable
Agent-resolvable
Needs sign-off
quoted-pathfixturef86dadcalwaystask filese7a18fescripts/ci-role-matrix.shf91b9b5f91b9b5120f056d5b8b10sourceand indented forms (panel, gemini)85abe9cNeeds human judgment
Declined log
changesgates role jobs on main--allaccepts extra args (gemini)e["role"]without.get(gemini)json.loadsoutput (gemini)fromJSONand the suitePending sign-off
Approve every item below by approving this PR's merge; reject one before that with its recipe.
f86dadcgit revert f86dadcalwaystask files · commite7a18fegit revert e7a18fef91b9b5.github/copilot-instructions.md— before:.github/workflows/test.ymldeclares strict_idempotency · after:scripts/ci-role-matrix.shdeclares itscripts/ci-role-matrix.shheader — before: "the four task files", upgrade's roles listed · after: no count or list; the tag guard namedgit revert f91b9b5; rejecting one sub-item is a hand edit the manifest guides120f056git revert 120f056d5b8b10git revert d5b8b10sourceand indented forms · commit85abe9cgit revert 85abe9cPass summary
/polish --nested(2 iterations, converged), then/panel-review --nestedwith gemini (3 discovery passes; mission control closed it as converged on85abe9c). Both ran in-session; the brief forbids extra sessions.origin/mainate296c92.ubuntu-26.04label note; ansible-lint passed in the pre-commit hook;ci-role-matrix-test.shgreen, with mutation checks confirming each guard fails on planted drift; the matrix block ofservices-declaration-test.shrun alone, green..claude/polish-audit.mdnot written: this run's rules forbid writes into the worktree's.claude/. The record lives here.Cadence step records
Steps at
pre-implementation(run000001)Ended on
e296c923581c.Steps at
pre-ci(run000001)Ended on
c9a98c8d8243.Steps at
convergence(run000001)Ended on
85abe9cb7390.Steps at
pre-pr(run000001)Ended on
85abe9cb7390.Steps at
post-pr(run000001)Ended on
85abe9cb7390.