Repository navigation
ci: fan flake checks out into a parallel matrix - #1293
Conversation
The single `nix flake check` built ~13 check derivations on one contended 4-core runner. Replace it with a matrix: enumerate the checks via `nix eval .#checks.x86_64-linux --apply builtins.attrNames` and run each as its own parallel job (`nix build .#checks.x86_64-linux.<name>`), pulling the shared compile cache from Cachix. Wall-clock collapses to slowest-single-check + nix setup instead of the sum under core contention. Coverage moves to a dedicated `coverage` job (needs: checks) that merges the per-cohort profiles and uploads to Codecov. The shared build job sets run_flake_check: false so it only builds/pushes the OCI image. TEMP: caller pinned to the gh-actions feature branch to validate before kalbasit/gh-actions#9 merges; revert to @main before merging. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
This change is part of the following stack: Change managed by git-spice. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR disables the upstream monolithic ChangesCI fan-out workflow and topology
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Code Review
This pull request proposes and documents a transition from a monolithic nix flake check to a fanned-out parallel CI matrix to improve wall-clock times. The review feedback identifies that nix eval does not realize derivations and thus cannot warm Cachix as intended, suggesting an explicit build instead. Additionally, the reviewer noted multiple instances in the documentation and specifications where the --json flag was omitted from the nix eval command, which is required for GitHub Actions to parse the output.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)
75-78: ⚡ Quick winFail fast if
nix evalerrors instead of emitting an empty matrix.
echo "checks=$(nix eval ...)"swallows a failingnix eval(the failure is inside a command substitution used as an argument, soset -ewon't trip). On failure you getchecks=empty, and thechecksjob then fails opaquely atfromJson. Capture into a variable first so the step fails at the real cause.♻️ Proposed fix
- name: Enumerate checks id: list run: | - echo "checks=$(nix eval .#checks.x86_64-linux --apply builtins.attrNames --json)" >> "$GITHUB_OUTPUT" + checks="$(nix eval .#checks.x86_64-linux --apply builtins.attrNames --json)" + echo "checks=$checks" >> "$GITHUB_OUTPUT"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/ci.yml around lines 75 - 78, The step "Enumerate checks" (id: list) currently uses command substitution directly in echo which hides nix eval failures; instead run the nix eval command and capture its output into a shell variable (e.g., result=$(nix eval ... --json 2>&1)), check the command exit status and fail the step if non-zero, then write the successful JSON to GITHUB_OUTPUT with echo "checks=$result" >> "$GITHUB_OUTPUT"; update the step's run block to perform the capture, explicit exit-on-error check, and only emit to GITHUB_OUTPUT when the eval succeeded so failures surface at the real cause instead of producing an empty matrix consumed by fromJson.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 23-26: The workflow is pinned to a mutable branch ref in the uses
line ("uses:
kalbasit/gh-actions/.github/workflows/ci.yml@user/wnasreddine/further-improvement")
which triggers the unpinned-uses warning; change that ref back to `@main` or a
specific immutable tag/SHA and update the header comment that currently reads
"Pinned to `@main`" so it accurately reflects the chosen ref, and ensure this
revert is applied before merging.
- Around line 95-96: The workflow is vulnerable because it expands ${{
matrix.check }} directly into the shell; change the step that runs `nix build
".#checks.x86_64-linux.${{ matrix.check }}" -L` to pass the matrix value through
an environment variable (e.g., set env CHECK: ${{ matrix.check }}) and then
reference that variable quoted in the run command (use the string
".#checks.x86_64-linux.${CHECK}" or equivalent) so the matrix value is treated
as data, not as shell code; update the step that currently uses `matrix.check`
in the `run:` line to use the env var (CHECK) instead and keep the build
argument quoted.
---
Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 75-78: The step "Enumerate checks" (id: list) currently uses
command substitution directly in echo which hides nix eval failures; instead run
the nix eval command and capture its output into a shell variable (e.g.,
result=$(nix eval ... --json 2>&1)), check the command exit status and fail the
step if non-zero, then write the successful JSON to GITHUB_OUTPUT with echo
"checks=$result" >> "$GITHUB_OUTPUT"; update the step's run block to perform the
capture, explicit exit-on-error check, and only emit to GITHUB_OUTPUT when the
eval succeeded so failures surface at the real cause instead of producing an
empty matrix consumed by fromJson.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ce9577b8-31b5-4280-a78f-176f5c0dc6b2
📒 Files selected for processing (7)
.github/workflows/ci.ymlopenspec/changes/archive/2026-05-29-fan-out-flake-check/.openspec.yamlopenspec/changes/archive/2026-05-29-fan-out-flake-check/design.mdopenspec/changes/archive/2026-05-29-fan-out-flake-check/proposal.mdopenspec/changes/archive/2026-05-29-fan-out-flake-check/specs/flake-check-topology/spec.mdopenspec/changes/archive/2026-05-29-fan-out-flake-check/tasks.mdopenspec/specs/flake-check-topology/spec.md
run_flake_check is on @main; drop the temporary gh-actions feature-branch pin used to validate the fan-out end-to-end (validated: CI green at 5.1m). Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/workflows/ci.yml (1)
92-93:⚠️ Potential issue | 🟠 Major | ⚡ Quick winTemplate injection:
${{ matrix.check }}is still expanded directly into the shell.The matrix values come from
builtins.attrNamesover the PR-head flake, which is attacker-controlled on fork PRs. The previously proposed fix (pass the value via anenvvar and reference it quoted) has not been applied.🔒 Proposed fix
- name: Build check - run: nix build ".#checks.x86_64-linux.${{ matrix.check }}" -L + env: + CHECK: ${{ matrix.check }} + run: nix build ".#checks.x86_64-linux.$CHECK" -L🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/ci.yml around lines 92 - 93, The workflow step named "Build check" currently expands the template value `${{ matrix.check }}` directly into the shell command (run: nix build ".#checks.x86_64-linux.${{ matrix.check }}" -L), which allows template injection; change the step to pass the matrix value via an environment variable (e.g. set env: CHECK: ${{ matrix.check }}) and update the run line to reference the env var instead (use the shell-safe quoted variable, e.g. nix build ".#checks.x86_64-linux.$CHECK" -L), ensuring the matrix value is not directly injected into the run string but read from $CHECK at runtime and properly quoted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In @.github/workflows/ci.yml:
- Around line 92-93: The workflow step named "Build check" currently expands the
template value `${{ matrix.check }}` directly into the shell command (run: nix
build ".#checks.x86_64-linux.${{ matrix.check }}" -L), which allows template
injection; change the step to pass the matrix value via an environment variable
(e.g. set env: CHECK: ${{ matrix.check }}) and update the run line to reference
the env var instead (use the shell-safe quoted variable, e.g. nix build
".#checks.x86_64-linux.$CHECK" -L), ensuring the matrix value is not directly
injected into the run string but read from $CHECK at runtime and properly
quoted.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6a5e8ecf-8ad2-414a-b227-687fbac09c91
📒 Files selected for processing (2)
.github/workflows/ci.ymlopenspec/changes/archive/2026-05-29-fan-out-flake-check/tasks.md
✅ Files skipped from review due to trivial changes (1)
- openspec/changes/archive/2026-05-29-fan-out-flake-check/tasks.md
Address review feedback on #1293: - Security (CodeRabbit/zizmor): pass matrix.check via an env var and reference it quoted in `run:`, instead of expanding `${{ matrix.check }}` directly into the shell. On fork PRs the check names come from builtins.attrNames over the attacker-controlled flake, so direct interpolation was a template-injection vector. - Docs (Gemini): add the required `--json` flag to the prose `nix eval` references in the proposal/spec (the workflow already used it). - Docs: correct the design.md cold-cache note — `nix eval` does NOT realize derivations, so check-matrix doesn't warm Cachix; warm Cachix is the steady state from prior merged runs. Co-Authored-By: Claude Opus 4.8 <[email protected]>
## Summary The release workflow (`v*.*.*` tag builds) called `build.yml` **without** `test_systems`, so it re-ran the full `nix flake check` + coverage on **both** x86_64 and aarch64 — including the slower, flaky aarch64 Postgres path that the CI workflow (#1291) already learned to avoid. - `releases.yml`: pass `test_systems: '["x86_64-linux"]'` to the shared build workflow. The integration suite + coverage now run on x86_64 only; the aarch64 leg still **builds and pushes** its OCI image, so the multi-arch manifest is unchanged. `run_flake_check` stays at its default (`true`) so releases still gate on the full suite. - Mirrors the CI workflow's scoping. - `flake-check-topology` spec: the "Integration cohorts validated on a single CI architecture" requirement now covers **both** `ci.yml` and `releases.yml`, with a new release-tag scenario. Independent of the fan-out PR (#1293); branched off `main`. Relies on the `test_systems` input already on `kalbasit/gh-actions@main` (merged in #8). ## Test plan - [x] `actionlint .github/workflows/releases.yml` — exit 0 - [x] `task fmt` clean; pre-commit hooks pass - [ ] Confirm on the next release tag that the aarch64 leg builds the image but skips `nix flake check` --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
Why
After compile-once (#1292) CI is ~10m, bottlenecked by a single
nix flake checkbuilding ~13 check derivations on one contended 4-core runner. They're logically parallel but CPU-starved; the remaining costs (backend-cohort test execution, golangci's own analysis) aren't cacheable — they need more cores in parallel.What
Replace the monolithic check with a CI matrix:
check-matrixjob enumerates checks:nix eval .#checks.x86_64-linux --apply builtins.attrNames --json.checksjob runs each as its own parallel runner:nix build .#checks.x86_64-linux.<name>(fail-fast: false), pulling the shared_ncps-test-cache/_ncps-basefrom Cachix instead of rebuilding.coveragejob (needs: checks) merges per-cohort profiles → Codecov.run_flake_check: false(feat(ci): add run_flake_check to skip inline checks for fan-out consumers gh-actions#9) so it only builds/pushes the OCI image.Wall-clock collapses from sum-under-contention (~10m) to slowest-single-check + nix setup (~3–4m) — the path to the ~5m target. The per-job times on this run also give us the first clean per-check breakdown.
Depends on kalbasit/gh-actions#9 (adds
run_flake_check). The caller is temporarily pinned to the gh-actions branch to validate now; revert to@mainbefore merging once #9 lands.OpenSpec:
flake-check-topologygains "CI runs each check as an independent parallel job" + "Coverage is produced by a job consuming the fanned-out cohorts".