8000 ci: run each macOS role job only when its role or shared files change by inkatze · Pull Request #235 · inkatze/dotfiles · GitHub
[go: up one dir, main page]

Skip to content

ci: run each macOS role job only when its role or shared files change - #235

Merged
inkatze merged 7 commits into
mainfrom
planwright/flight/mc-dotfiles-ad-hoc-d871d0b8
Nov 10, 2026
Merged

inkatze merged 7 commits into
mainfrom
planwright/flight/mc-dotfiles-ad-hoc-d871d0b8

Conversation

@inkatze
@inkatze inkatze commented Nov 10, 2026 •
Copy link
Copy Markdown
Owner

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 Ubuntu changes job now picks which role jobs a pull request needs: those whose roles/<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), the changes/test jobs in .github/workflows/test.yml, and the matrix checks in scripts/services-declaration-test.sh.

  • Shared (start every job): the workflow, the selector, main.yml, hosts, ansible.cfg, group_vars/, become_plugins/, mise.toml, scripts/playbook.sh, every role's defaults/ vars/ meta/ handlers/ (loaded into every play), and the task files holding tags: [always] tasks (they run under any tag). These were found by reading the tags and {{ ansible_facts.env.PWD }}/scripts/ references, not guessed.
  • Per role: its own roles/<role>/, plus the scripts its tasks run and what those source. osx and upgrade also take the Brewfiles. upgrade takes every role holding upgrade-tagged tasks.
  • Fail-safe: a push, a missing merge parent, a failed diff, or a git-quoted path selects every job.
  • Guards: the suite fails when a role's task runs a script that would not start its job, when a task file carrying a job's tag (or always) would not start it, or when a task's tags are not written as an inline list it can read.
  • Lint, skill-contracts and services (linux) are unchanged.
  • Pending sign-off: PS-1 to PS-6 (review fixes); see the collapsed checklist.

Required checks

Main's ruleset (default) has a required_status_checks rule with an empty list, so no check is required. A pull request that selects no role skips the test job, which reports as skipped rather than pending, and the PR stays mergeable. If a test (<role>) leg is ever made required, a skipped matrix never creates that leg and the check would wait: require changes or lint instead.

Before / after

  • Before (measured): the 6 most recent successful PR runs, 54 macOS role jobs: median queue wait 16.0 min (p90 57.2), median run 3.8 min, about 46 macOS job-minutes per PR.
  • After (dry run of the selector over the last 40 merges on main): 137 role jobs instead of 360 (62% fewer). 21 of the 40 would have started no macOS role job at all.
  • This PR: it edits the workflow and the selector, which are shared, so its own CI runs all nine. That is expected.

Verification

  • specs-only PR starts no role job: the changes job runs scripts/ci-role-matrix-test.sh first, so this PR's own CI log shows the specs-only case (specs/ and docs/ paths → no role job) and claude-only. Dry run: specs/ matches no role pattern, no shared pattern and no play-scoped role dir, so include is [], test is skipped, and a skipped job blocks nothing under the ruleset above.
  • roles/git/ PR starts only test (git): the git-only case (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 to roles/git/defaults/ would start all nine, since role defaults load into every play.

Open items for the operator

  • lefthook entry not added: the worker profile denies lefthook edits, so the new suite runs in CI only. Proposed entry, under pre-commit.commands:
        ci-role-matrix:
          # The suite is what notices a role's tasks running a script that no
          # longer starts its CI job; the selector alone still prints valid JSON.
          glob: "{scripts/ci-role-matrix{.sh,-test.sh},roles/*/tasks/*.yml}"
          run: scripts/ci-role-matrix-test.sh
  • Workflow comment on the skipped job says it "never blocks a merge". That holds under today's ruleset (above). The panel review flagged it as unconditional. It was not edited, because the review loop does not change CI config on a backend's recommendation. A wording that names the condition would be: "GitHub reports it as skipped, not pending; main requires no status check, so it blocks no merge."
  • Fixture suite gates the role jobs on main too: a broken ci-role-matrix-test.sh on main fails changes and skips the role jobs there. That failure shows as a red check, and the PR run catches it before a merge. Declined.
  • services-declaration-test: its REQ-E1.4 check forbade any removed workflow line against 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 from changes. 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)

Lens Findings Notes
Correctness, logic, edge cases 1 git-quoted paths matched no trigger (PS-1)
Security none event name passed through env; matrix values come from the tracked table
Error handling and failure modes 1 suite failure on main skips role jobs (declined)
Performance none Ubuntu job runs beside lint; no macOS runner for selection
Concurrency / state none no shared state; concurrency group unchanged
Naming, readability, structure none new files only
Documentation 2 falsified prose: copilot-instructions pointed at the workflow for strict_idempotency; documentation guard: a count in a new comment (PS-3)
Tests / verification 1 no guard for tag-carrying or always task files (PS-2)
Cross-file consistency none services-declaration-test adapted in the main commit

Auto-applicable

# Finding Tool + rule cited Fix Commit
none

Agent-resolvable

# Finding Test (path + name) Before → after output CI result Brief alignment Commit
none no kickoff brief (flight), bucket unavailable

Needs sign-off

# Finding Fix applied Route reason Commit Checklist ID
1 a path git quotes (non-ASCII) started no role job quoted path selects every job; quoted-path fixture behaviour change, unambiguous fix f86dadc PS-1
2 nothing guarded tag-carrying or always task files suite fails when such a file would not start its job multi-step, unambiguous e7a18fe PS-2
3 copilot-instructions said the workflow declares strict_idempotency points at scripts/ci-role-matrix.sh meaning-class prose, pre-existing surface f91b9b5 PS-3
4 the selector comment counted the always-task files and restated upgrade's roles count and list dropped; tag guard named documentation guard (no fragile filler) f91b9b5 PS-3
5 tag guard read inline lists only (panel, gemini) other tag forms fail the suite behaviour change in test 120f056 PS-4
6 selector usage errors untested (panel, gemini) usage cases assert non-zero exit test addition d5b8b10 PS-5
7 sourced-script read missed source and indented forms (panel, gemini) broadened the match behaviour change in test 85abe9c PS-6

Needs human judgment

# Fork Ladder record Outcome Options
none

Declined log

# Finding Validation summary Rationale Where re-raisable
1 fixture suite in changes gates role jobs on main real but visible as a red check; the PR run catches it first the fix is CI config, and the failure is loud PR review
2 workflow comment "never blocks a merge" is unconditional (gemini, raised twice) holds under today's ruleset (no required checks) CI config is not edited on a backend's recommendation; wording offered above PR review
3 grep noise if a role has no tasks/ (gemini) every listed role has tasks/ unreachable PR review
4 --all accepts extra args (gemini) every caller passes one arg no consequence PR review
5 exact-JSON assertions are brittle (gemini, two rows) the emitter is this repo's printf a format change should fail the suite PR review
6 python reads e["role"] without .get (gemini) a KeyError fails the test loudly loud failure already PR review
7 no shape check on json.loads output (gemini) a bad shape raises and fails the test loud failure already PR review
8 no argv length check (gemini) argv is fixed by the caller unreachable PR review
9 JSON values unescaped (gemini, two rows) the values come from the static table, with no quotes unreachable; a malformed row fails fromJSON and the suite PR review

Pending sign-off

Approve every item below by approving this PR's merge; reject one before that with its recipe.

  • PS-1 a git-quoted path selects every role job · commit f86dadc
    • Route reason: behaviour change, unambiguous fix
    • Reject with: git revert f86dadc
  • PS-2 suite guards tag-carrying and always task files · commit e7a18fe
    • Route reason: multi-step, unambiguous
    • Reject with: git revert e7a18fe
  • PS-3 2 prose fixes · commit f91b9b5
    • Route reason: falsified prose on a pre-existing surface; documentation guard on a new comment
    • .github/copilot-instructions.md — before: .github/workflows/test.yml declares strict_idempotency · after: scripts/ci-role-matrix.sh declares it
    • scripts/ci-role-matrix.sh header — before: "the four task files", upgrade's roles listed · after: no count or list; the tag guard named
    • Reject with: git revert f91b9b5; rejecting one sub-item is a hand edit the manifest guides
  • PS-4 tags in any form but an inline list fail the suite · commit 120f056
    • Route reason: behaviour change in test
    • Reject with: git revert 120f056
  • PS-5 selector usage errors must exit non-zero · commit d5b8b10
    • Route reason: test addition
    • Reject with: git revert d5b8b10
  • PS-6 sourced-script read covers source and indented forms · commit 85abe9c
    • Route reason: behaviour change in test
    • Reject with: git revert 85abe9c

Pass summary

  • Mode: /polish --nested (2 iterations, converged), then /panel-review --nested with gemini (3 discovery passes; mission control closed it as converged on 85abe9c). Both ran in-session; the brief forbids extra sessions.
  • Base: origin/main at e296c92.
  • Tooling: shellcheck clean; yamllint clean; actionlint clean except the pre-existing ubuntu-26.04 label note; ansible-lint passed in the pre-commit hook; ci-role-matrix-test.sh green, with mutation checks confirming each guard fails on planted drift; the matrix block of services-declaration-test.sh run alone, green.
  • Not run locally: the full suites (host under load, per the run's rules); CI runs them.
  • .claude/polish-audit.md not written: this run's rules forbid writes into the worktree's .claude/. The record lives here.
  • Bot review: skipped. Cubic monthly quota reached (40,041 of 40,000 lines; resumes 2 December 2026); dotfiles has no PR-Agent workflow yet.

Cadence step records

Steps at pre-implementation (run 000001)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on e296c923581c.

Steps at pre-ci (run 000001)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on c9a98c8d8243.

Steps at convergence (run 000001)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 polish skill polish in-session in-session c9a98c8 to f91b9b5 2026-11-09T23:14:04Z 2026-11-09T23:25:27Z passed polish --nested converged in 2 iterations (inline, in-session: brief forbids extra sessions). PS-1 quoted-path fail-safe f86dadc; PS-2 tag/always coverage guard e7a18fe; PS-3 prose batch f91b9b5; declined 1 (fixture suite in changes job gates role jobs on main too). Audit file not written: standing rule forbids writes into the worktree .claude/.
2 panel-review skill panel-review in-session in-session f91b9b5 to 85abe9c 2026-11-09T23:26:52Z 2026-11-09T23:59:41Z passed panel-review --nested (gemini), inline in-session; 3 discovery passes, closed as converged on this head by mission control (no 4th pass). Applied: PS-4 tag-form fail-closed 120f056, PS-5 usage-error tests d5b8b10, PS-6 sourced-script regex 85abe9c. Declined 9 (no reachable effect or loud failure already); workflow-comment claim declined (holds under current ruleset; CI config not edited on a backend recommendation), surfaced in PR body. Full local suite not run (host load rule); targeted suite and shellcheck green.

Ended on 85abe9cb7390.

Steps at pre-pr (run 000001)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on 85abe9cb7390.

Steps at post-pr (run 000001)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 bot-review skill bot-review in-session in-session 85abe9c 2026-11-10T00:05:41Z 2026-11-10T00:05:41Z skipped: answered (cubic monthly quota reached (40,041 of 40,000 lines; resumes 2 December 2026); dotfiles has no PR-Agent workflow yet)

Ended on 85abe9cb7390.

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
@inkatze
inkatze marked this pull request as ready for review November 10, 2026 03:01
@inkatze
inkatze merged commit 9edc955 into main Nov 10, 2026
13 checks passed
@inkatze
inkatze deleted the planwright/flight/mc-dotfiles-ad-hoc-d871d0b8 branch November 10, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0