Skip to content

ci: run integration suite on x86_64 only, not aarch64 - #1291

Merged
kalbasit merged 7 commits into
mainfrom
user/wnasreddine/ncps-ci-got-slow-again
May 29, 2026
Merged

kalbasit merged 7 commits into
mainfrom
user/wnasreddine/ncps-ci-got-slow-again

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

Why CI got slow and flaky

CI averages ~20 min, often exceeds 30, and fails roughly half of runs — so a PR takes several attempts to merge. Root cause (measured on run 26653285682):

build matrix leg Duration Result
x86_64-linux 17.4 min ✅
aarch64-linux 25.7 min ❌ (Postgres cohort timeout)

The shared build job fans out over ["x86_64-linux","aarch64-linux"] and runs the entire nix flake check — all integration cohorts (Garage/Postgres/MySQL/Redis) — on both legs. The aarch64 leg runs on slower ARM runners where the Postgres cohort times out, making it both the long pole and the dominant failure. Integration tests are architecture-independent, so the aarch64 run buys no signal — only wall clock and flaky reruns.

What this does

Passes test_systems: '["x86_64-linux"]' to the shared kalbasit/gh-actions workflow so nix flake check + coverage run on x86_64 only. The aarch64-linux leg still builds and pushes its OCI image (the lean, test-free packages.ncps), so the multi-arch manifest is unchanged — it just no longer re-runs the integration suite.

⚠️ Merge order

Depends on kalbasit/gh-actions#8 (adds the test_systems input). Since this repo consumes gh-actions/.github/workflows/ci.yml@main, #8 must merge first — until then this PR's shared job will fail with an unknown-input error. Re-run CI here after #8 lands.

Scope / non-goals

Per the OpenSpec change speed-up-ci: this kills the flakiness and removes the ~26-min aarch64 critical path. It does not rework the dd9622c per-backend cohort split (the secondary 8m→14m flake-check regression) — that's a deferred, separate lever toward the eventual ~5-min target.

OpenSpec: openspec/changes/speed-up-ci/.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. go Pull requests that update go code labels May 29, 2026
@coderabbitai

coderabbitai Bot commented May 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: caf7478e-89d9-48c5-9a78-8187ccbca8c7

📥 Commits

Reviewing files that changed from the base of the PR and between b9aab99 and f585815.

📒 Files selected for processing (1)
  • openspec/changes/archive/2026-05-29-speed-up-ci/tasks.md
✅ Files skipped from review due to trivial changes (1)
  • openspec/changes/archive/2026-05-29-speed-up-ci/tasks.md

📝 Walkthrough

Summary by CodeRabbit

  • Chores

    • Optimized CI to run integration tests and coverage on a single canonical architecture while still building and publishing container images for all target platforms, reducing pipeline time and speeding the non-canonical leg; added an opt-in control to scope which systems run the full suite.
  • Documentation

    • Added design, proposal, specs, task guide and archive metadata documenting the CI speed-up plan and rollout.

Walkthrough

This PR scopes CI integration tests and coverage to x86_64-linux via a new test_systems workflow input while preserving per-architecture OCI image builds; it includes the workflow wiring, proposal, design/rollout runbook, and updated specifications.

Changes

CI Test Systems Configuration

Layer / File(s) Summary
Workflow input configuration
.github/workflows/ci.yml
CI workflow passes test_systems: '["x86_64-linux"]' input to the shared reusable workflow, restricting integration test and coverage execution to x86_64-linux while preserving aarch64 OCI image build.
CI speed-up proposal and impact analysis
openspec/changes/archive/2026-05-29-speed-up-ci/proposal.md
Proposes restricting integration nix flake check and coverage to x86_64-linux to reduce wall-clock time and CI flakiness on aarch64, while keeping aarch64 image publishing and local flake check behavior unchanged.
Design rationale and cross-repo rollout plan
openspec/changes/archive/2026-05-29-speed-up-ci/design.md, openspec/changes/archive/2026-05-29-speed-up-ci/.openspec.yaml, openspec/changes/archive/2026-05-29-speed-up-ci/specs/flake-check-topology/spec.md, openspec/changes/archive/2026-05-29-speed-up-ci/tasks.md
Design document details the opt-in test_systems mechanism, gating rules, and wiring through orchestrator layers; archive files record rollout tasks and verification outcomes.
Active specification requirements and CI scenarios
openspec/specs/flake-check-topology/spec.md
Spec defines requirement that integration tests run on x86_64-linux only, specifies per-architecture CI scenarios (aarch64 skips flake-check but builds OCI image; x86_64 runs full suite with coverage), and confirms local behavior remains unchanged.

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • kalbasit/ncps#1235: Both PRs modify the CI workflow wiring to call the shared kalbasit/gh-actions reusable workflows; #1235 introduced the shared workflow caller and this PR extends that call with the test_systems input.

Suggested labels

merge-stack

Poem

🐰 The workflows now run lean and fleet,
With tests on x86 — a single seat!
While ARM still builds its image bright,
No duplicate checks slow down the night.
CI hops faster, clean and light!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: running the integration suite only on x86_64 instead of both x86_64 and aarch64, which is the primary objective of the PR.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the performance and flakiness issues, the specific solution, merge dependencies, and scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request proposes a design to speed up CI by running integration tests and coverage checks only on the canonical x86_64-linux architecture, while continuing to build OCI images for all architectures. It also fixes a critical bug in the cache package where a missing ds.wg.Done() call on early-return paths (such as context cancellation) caused c.Close() to hang indefinitely, and adds a regression test for this scenario. Feedback on the changes suggests replacing a developer-specific absolute path in the tasks documentation with a relative path to ensure portability.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
pkg/cache/cache_test.go (2)

4232-4235: 💤 Low value

Make error handling more explicit.

The error return value is completely ignored using _. While this may be intentional since the test focuses on cleanup rather than success, consider making it more explicit by assigning to a named variable (e.g., getNarErr) or adding a comment explaining why the error is ignored.

✨ Suggested improvement
 	nu := nar.URL{Hash: entry.NarHash, Compression: entry.NarCompression}
 
-	_, _, r, _ := c.GetNar(ctxA, nu)
+	// GetNar will return context.Canceled, but we're testing the cleanup path
+	_, _, r, getNarErr := c.GetNar(ctxA, nu)
+	_ = getNarErr
 	if r != nil {
 		r.Close()
 	}
🤖 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 `@pkg/cache/cache_test.go` around lines 4232 - 4235, The test currently calls
c.GetNar(ctxA, nu) and discards the error return with `_`, which hides potential
failures; change the call to capture the error into a clearly named variable
(e.g., getNarErr) and either assert/handle it or add an inline comment
explaining why the error is intentionally ignored, while still closing r when
non-nil (referencing GetNar, ctxA, nu, and r to locate the call).

4237-4245: 💤 Low value

Add clarifying comment about background download behavior.

The comment explains that the download goroutine reaches the upstream server, but doesn't explain why this happens when the caller's context was pre-cancelled. Consider adding a brief explanation that the download runs in a background goroutine with a detached context (not the caller's cancelled context), which is why it completes successfully.

📝 Suggested comment addition
 	// Wait for the download goroutine to reach the upstream server. At this
-	// point getNarFromUpstream will succeed, the cleanup goroutine will be added
-	// to backgroundWG, and it will eventually call ds.wg.Wait() — blocking
-	// forever if ds.wg.Done() was never called.
+	// point getNarFromUpstream will succeed (the download runs in a background
+	// goroutine with a detached context, unaffected by the caller's cancelled
+	// context), the cleanup goroutine will be added to backgroundWG, and it
+	// will eventually call ds.wg.Wait() — blocking forever if ds.wg.Done() was
+	// never called.
 	select {
 	case <-serverReceivedNar:
🤖 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 `@pkg/cache/cache_test.go` around lines 4237 - 4245, Add a brief clarifying
comment above the select that waits on serverReceivedNar explaining that
although the caller's context was pre-cancelled, the download runs in a
background goroutine with a detached/new context (not the caller's cancelled
context), so getNarFromUpstream will still be invoked and the cleanup goroutine
is registered on backgroundWG (and will call ds.wg.Wait()); this explains why
serverReceivedNar is signaled even when the original caller cancelled. Reference
the existing symbols serverReceivedNar, getNarFromUpstream, backgroundWG and
ds.wg.Wait in the comment to make the behavior explicit.
🤖 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:
- Line 26: Replace the mutable reusable-workflow ref used in the CI workflow by
pinning to a specific commit SHA instead of the branch ref
`user/wnasreddine/ncps-ci-got-slow-again`; locate the `uses:
kalbasit/gh-actions/.github/workflows/ci.yml@user/wnasreddine/ncps-ci-got-slow-again`
entry and change the ref portion to the corresponding commit SHA (e.g.,
`@<commit-sha>`), then once the dependency is finalized repin it to the stable
tag or branch (e.g., `@main` or a release tag).

---

Nitpick comments:
In `@pkg/cache/cache_test.go`:
- Around line 4232-4235: The test currently calls c.GetNar(ctxA, nu) and
discards the error return with `_`, which hides potential failures; change the
call to capture the error into a clearly named variable (e.g., getNarErr) and
either assert/handle it or add an inline comment explaining why the error is
intentionally ignored, while still closing r when non-nil (referencing GetNar,
ctxA, nu, and r to locate the call).
- Around line 4237-4245: Add a brief clarifying comment above the select that
waits on serverReceivedNar explaining that although the caller's context was
pre-cancelled, the download runs in a background goroutine with a detached/new
context (not the caller's cancelled context), so getNarFromUpstream will still
be invoked and the cleanup goroutine is registered on backgroundWG (and will
call ds.wg.Wait()); this explains why serverReceivedNar is signaled even when
the original caller cancelled. Reference the existing symbols serverReceivedNar,
getNarFromUpstream, backgroundWG and ds.wg.Wait in the comment to make the
behavior explicit.
🪄 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: 7efc30f6-aaf1-4bc8-a5a2-162dc5d0c9ef

📥 Commits

Reviewing files that changed from the base of the PR and between ee5b884 and cb6a139.

📒 Files selected for processing (8)
  • .github/workflows/ci.yml
  • openspec/changes/speed-up-ci/.openspec.yaml
  • openspec/changes/speed-up-ci/design.md
  • openspec/changes/speed-up-ci/proposal.md
  • openspec/changes/speed-up-ci/specs/flake-check-topology/spec.md
  • openspec/changes/speed-up-ci/tasks.md
  • pkg/cache/cache.go
  • pkg/cache/cache_test.go

Comment thread .github/workflows/ci.yml Resolved
kalbasit and others added 5 commits May 29, 2026 13:27
When canStream=true, ds.wg.Add(1) is called before the select that
waits for ds.start. Two early-return paths never called ds.wg.Done():

1. ctx.Done() fires before ds.start closes — GetNar returns ctx.Err()
   without launching the streaming goroutine whose defer does the Done.
2. ds.getError() returns non-nil after ds.start closes — same issue.

Both paths leave ds.wg permanently > 0, causing the cleanup goroutine
(pullNarIntoStore.func3, tracked by backgroundWG) to block forever at
ds.wg.Wait(), which in turn blocks c.Close() indefinitely.

On slower aarch64 runners the race is reliably triggered by the stress
test (cancelA fires before ds.start closes), explaining the 20-minute
timeout seen in CI.
CI ran the full `nix flake check` (Garage/Postgres/MySQL/Redis cohorts)
on both x86_64-linux and aarch64-linux. The aarch64 leg, on slower ARM
runners, was both the long pole (~26m vs ~17m) and the dominant failure
(recurring Postgres-cohort timeout), forcing repeated PR reruns. The
integration suite is architecture-independent, so the aarch64 run added
cost and flakiness without signal.

Pass `test_systems: '["x86_64-linux"]'` to the shared workflow so the
integration suite + coverage run on x86_64 only. The aarch64 leg still
builds and pushes its OCI image, so the multi-arch manifest is unchanged.

Depends on kalbasit/gh-actions#8 (adds the test_systems input); that PR
must land first. Tracked by OpenSpec change speed-up-ci.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Validate the test_systems change end-to-end on this PR's CI before
kalbasit/gh-actions#8 merges. MUST be reverted to @main before merging
(tracked as speed-up-ci task 2.7).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Revert the temporary gh-actions feature-branch pin now that test_systems
was validated end-to-end on CI (aarch64 leg 25.7m-fail -> 2.7m-pass).
Apply the flake-check-topology delta to the main spec and archive the
completed change.

Merge order: kalbasit/gh-actions#8 must land before this PR so @main
carries the test_systems input.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@kalbasit

kalbasit commented May 29, 2026 •

Copy link
Copy Markdown
Owner Author

This change is part of the following stack:

Change managed by git-spice.

@kalbasit
kalbasit force-pushed the user/wnasreddine/ncps-ci-got-slow-again branch from cb6a139 to b9aab99 Compare May 29, 2026 20:33
kalbasit and others added 2 commits May 29, 2026 13:38
Drop the machine-specific absolute path from the archived change notes.

Addresses review feedback on #1291.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@kalbasit
kalbasit merged commit e10cff0 into main May 29, 2026
26 of 36 checks passed
@kalbasit
kalbasit deleted the user/wnasreddine/ncps-ci-got-slow-again branch May 29, 2026 20:58
kalbasit added a commit that referenced this pull request May 29, 2026
## Why

After #1291, the `x86_64-linux` build leg (~17m) is CI's bottleneck, and
the **"Flake check" step is 16.3m of it** (measured, run 26661047200).
dd9622c split flake-check into 5 cohort derivations, each of which
recompiles the race+coverage-instrumented test binaries from scratch —
Go's build cache isn't shared across Nix sandboxes. The **4 backend
cohorts compile byte-identical binaries** (cgo `mattn/go-sqlite3` under
`-race`, ~2 min apiece on CI's 4-core runners), so 3 of those compiles
are pure waste that core contention can't parallelize away (this is
dd9622c's 8m→14m regression).

## What

Add a `_ncps-test-cache` derivation that compiles **both** cohort test
sets exactly once (`go test -run '^$'`, runs zero tests so no backend is
needed) and exports the populated `GOCACHE`. Each cohort seeds a
writable copy of that cache before its `go test`, turning compilation
into a cache hit. Cohort isolation, per-cohort `cover.out`, the merged
Codecov profile, the race detector, and `t.Skip` gating are all
unchanged.

Two Nix-specific details (documented in the code):
- `disallowedReferences = [ ]` — the cache legitimately references the
Go toolchain.
- `dontFixup = true` — patchelf/strip would rewrite cached objects and
invalidate Go's content hashes.
- Cohorts copy the cache preserving mode then `chmod -R u+w` —
`--no-preserve=mode` would strip the `covdata` helper's +x bit and break
coverage.

## Verification

- `_ncps-test-cache` builds (821M cache).
- **cmd cohort passes reusing the cache** — confirmed compile reuse (a
pre-fix run failed only on fork/exec of the *cached* `covdata` binary,
proving compilation was served from cache, not rebuilt).
- The postgres cohort's local `TestSchemaEquivalence` failure is
environmental: it fails identically with this change stashed, and the
cohort passes in CI on this branch.

This PR's own CI run will give the real before/after x86-leg number.

OpenSpec: `flake-check-topology` spec gains "Race+coverage test binaries
are compiled once and shared".

Co-authored-by: Claude Opus 4.8 <[email protected]>
@kalbasit kalbasit mentioned this pull request May 29, 2026
2 of 3 tasks
kalbasit added a commit that referenced this pull request May 29, 2026
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant