Skip to content

ci: merge test and coverage jobs into single instrumented run - #476

Merged
thiras merged 2 commits into
mainfrom
ci/merge-test-coverage-jobs
May 8, 2026
Merged

thiras merged 2 commits into
mainfrom
ci/merge-test-coverage-jobs

Conversation

@thiras

@thiras thiras commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Merge the duplicated test (plain nextest) and coverage (instrumented nextest) jobs into a single instrumented test job, eliminating the second full-workspace test run on every Rust PR.
  • Preserve the prior blocking/non-blocking split via continue-on-error on coverage post-processing steps; extract the pytest helper suite to a non-blocking coverage-tooling-tests job so coverage-diff.py regressions surface as a red X rather than an easy-to-miss yellow step.
  • Tighten coverage-comment.md handling: atomic .tmp + rename rules out partial writes from a mid-stream script crash, and core.warning on Post coverage comment surfaces sustained API outages in the run summary.

Behavior changes worth flagging for reviewers:

  • The required test step now runs with LLVM instrumentation (cargo llvm-cov nextest instead of plain cargo nextest run).
  • Doc-only PRs skip Rust tests via the existing changes gate; re-actors/alls-green treats skipped jobs as success, and main still runs on push so drift is caught at merge time.

Test plan

  • Open a Rust-touching PR; verify changes sets rust: true, the merged test job runs green, the sticky <!-- decdn-coverage-comment --> appears, and ci-success is green.
  • Open a docs-only PR; verify changes sets rust: false, the test job is skipped, ci-success stays green.
  • After this PR merges, confirm the coverage-lcov artifact is uploaded by the main-branch run (gh run view <id> --log | grep 'Upload coverage baseline').
  • Negative: break a unit test on a throwaway branch and confirm the test job goes red and ci-success blocks the PR.
  • Negative: temporarily break .github/scripts/coverage-diff.py and confirm coverage-tooling-tests goes red while ci-success stays green.

🤖 Generated with Claude Code

The previous test (plain nextest) and coverage (instrumented nextest) jobs
both ran the full workspace test suite, doubling CI minutes on every Rust
PR. Merge into a single test job that runs instrumented nextest once. The
test step is the required signal feeding ci-success; LCOV upload/download,
diff generation, and the sticky PR comment all carry continue-on-error: true
so flaky coverage tooling cannot block PRs — preserving the prior
coverage-job non-blocking semantics.

The pytest suite for coverage-diff.py is extracted to a separate non-blocking
coverage-tooling-tests job so a regression in the helper surfaces as a red X
in the checks list rather than as an easy-to-miss yellow step.

Behavior changes:
- Required test step now runs with LLVM instrumentation.
- Doc-only PRs skip Rust tests via the changes gate (alls-green treats
  skipped jobs as success; main still runs on push so drift is caught at
  merge time).

Hardenings:
- Atomic write for coverage-comment.md (.tmp + rename) rules out posting
  truncated output on a mid-stream coverage-diff.py crash.
- core.warning + try/catch on Post coverage comment surfaces sustained API
  outages in the run summary beyond just a yellow step.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 8, 2026 00:09
@gemini-code-assist

Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@github-actions

github-actions Bot commented May 8, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 85.87% (was 85.88%, ▼ 0.01%) — 9151/10657 lines

No Rust files changed in this PR.

History
Commit Total Δ vs base
638d671 85.89% ▲ +0.01%
5c36543 (HEAD) 85.87% ▼ 0.01%

Copilot AI 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.

Pull request overview

This PR streamlines Rust CI by removing the separate “plain tests” job and making the required test job run the workspace suite once under LLVM coverage instrumentation, while keeping coverage post-processing best-effort (non-blocking) and moving coverage helper pytest into its own visible, non-blocking job.

Changes:

  • Replace the duplicated test + coverage jobs with a single instrumented test job (cargo llvm-cov nextest) and mark coverage post-processing steps as continue-on-error.
  • Make coverage comment generation more robust via atomic write (.tmp + rename) and improved API error surfacing (core.warning).
  • Add a separate coverage-tooling-tests job to run pytest for .github/scripts/coverage-diff.py without blocking PRs.
Comments suppressed due to low confidence (1)

.github/workflows/ci.yml:339

  • test now depends on changes, but ci-success does not. If changes fails, test will be skipped and re-actors/alls-green treats skipped jobs as success, so required checks could go green without running tests. Consider adding changes to ci-success.needs (or otherwise ensuring a changes failure blocks merges) so a gating failure can’t silently bypass the required test signal.
  ci-success:
    name: CI success
    if: always()
    runs-on: ubuntu-latest
    needs: [fmt, clippy, test, deny, doc, msrv, markdownlint]
    steps:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved
Three fixes from Copilot review:

1. Add `changes` to `ci-success.needs`. A `changes` job failure would skip
   `test` via needs-propagation, and re-actors/alls-green treats skipped as
   success by default, so the required check could go green without tests
   running. Adding `changes` directly to `ci-success.needs` makes a `changes`
   failure fail `ci-success`.

2. Drop `continue-on-error: true` from `Upload coverage baseline`. The step
   only runs on push to main (post-merge), so a failure paints main CI red
   rather than blocking a PR. Silent degradation is worse — a persistent
   upload failure would freeze the coverage baseline that all PR diffs are
   computed against. Reverts an overzealous addition from the merge commit.

3. Write a marker-bearing fallback `coverage-comment.md` when
   `coverage-diff.py` crashes. With atomic write + hashFiles guard, a script
   crash previously left no comment file and the Post step skipped — leaving
   any prior sticky comment stale. The fallback now causes the Post step to
   update the sticky to a ":warning: Coverage diff generation failed"
   indicator, so readers don't mistake stale data for current results.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@thiras

thiras commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

Re: review's low-confidence note about changes not being in ci-success.needs — verified the concern is real. re-actors/alls-green@release/v1 treats skipped jobs as success by default, and a changes job failure would skip test via needs-propagation, letting the required check go green without tests running. Fixed in 5c36543 by adding changes to ci-success.needs so a changes failure fails ci-success directly.

@thiras
thiras merged commit a2852fc into main May 8, 2026
10 checks passed
@thiras
thiras deleted the ci/merge-test-coverage-jobs branch May 8, 2026 00:21
thiras added a commit that referenced this pull request May 8, 2026
Replace `github.event_name == 'push'` with `github.event_name !=
'pull_request'` on every Rust-job gate (fmt, clippy, deny, doc, msrv,
test). The workflow also triggers on `workflow_dispatch`, where
`dorny/paths-filter` can't reliably compute a diff and reports
`rust: false`; the prior `push`-only escape hatch silently skipped Rust
jobs on manual runs, making "Run workflow" green without actually
validating Rust. The new gate forces full Rust validation on any
non-PR event.

Also brings the pre-existing `test` gate (introduced in #476) onto the
same condition for consistency — its workflow_dispatch hole was
inherited rather than introduced by this PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
thiras added a commit that referenced this pull request May 8, 2026
* ci: skip rust jobs on doc-only PRs and accept skips in alls-green

Doc-only PRs (e.g. #477) had `CI success` failing because
re-actors/alls-green treats `skipped` as failure unless explicitly
listed in `allowed-skips`. The `test` job was already gated by the
`changes` paths-filter but the aggregator wasn't told to accept the
skip; the workflow comment claimed otherwise, which was misleading.

Apply the same gate to the other Rust-only jobs (fmt, clippy, deny,
doc, msrv) so doc-only PRs no longer burn CI minutes on no-op runs,
add `allowed-skips` for the gated set, and correct the comment.

`changes` and `markdownlint` always run, so they're intentionally
omitted from `allowed-skips` — a skip from either still fails the gate.

Closes #478

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* ci: include workflow_dispatch in rust-job gates

Replace `github.event_name == 'push'` with `github.event_name !=
'pull_request'` on every Rust-job gate (fmt, clippy, deny, doc, msrv,
test). The workflow also triggers on `workflow_dispatch`, where
`dorny/paths-filter` can't reliably compute a diff and reports
`rust: false`; the prior `push`-only escape hatch silently skipped Rust
jobs on manual runs, making "Run workflow" green without actually
validating Rust. The new gate forces full Rust validation on any
non-PR event.

Also brings the pre-existing `test` gate (introduced in #476) onto the
same condition for consistency — its workflow_dispatch hole was
inherited rather than introduced by this PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* ci: extend rust paths-filter to cover rustfmt/deny/cargo config

The `rust` filter is the gate for every Rust-only job (fmt, clippy,
deny, doc, msrv, test) and `allowed-skips` accepts those skips on the
ci-success aggregator. With `rustfmt.toml`, `deny.toml`, and
`.cargo/config.toml` outside the filter, a PR editing only one of
those files would skip the very job that consumes it (most acutely:
a `deny.toml` advisory-ignore change merging without `cargo deny`
running). Add them all so the gate matches the toolchain's actual
input set. `.cargo/**` is intentionally a glob so future per-target
overrides under that dir are caught automatically.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
thiras added a commit that referenced this pull request May 8, 2026
* ci: speed up coverage build with mold linker + debug-info trim

The merged test+coverage job (PR #476) is the sole driver of PR
wall-clock — ~3m21s out of ~4m end-to-end on a recent successful run
(25562733813), with the `Run tests` step alone consuming 2m20s of
that. Other jobs all parallelize within ~50s.

Three step-scoped changes attack the build/link phase:

* Install `mold` and route the final link through it via
  `-C link-arg=-fuse-ld=mold`. Workspace links ~8 instrumented test
  binaries (alloy/iroh/tokio/aws-sdk dep tree); mold is typically
  5–10× faster at the link step than ld.
* `-C debuginfo=1` (line-tables-only). cargo-llvm-cov only needs the
  `.debug_line` section to map counters to source lines for the
  SF/DA records in lcov.info; full DWARF type/variable info is
  unnecessary. Documented as the recommended setting in cargo-llvm-cov.
* `-C split-debuginfo=unpacked` puts debug info in side files
  instead of inline in object files; smaller .o files mean faster
  linking and a smaller cached target tree.

Plus `CARGO_INCREMENTAL=0` (incremental files bloat the cache for no
gain on a single CI run) and `--no-clean` on `cargo llvm-cov nextest`
(explicit "trust the cached target", matches modern default).

All knobs are scoped to the `Run tests` step's env block on purpose:
Swatinem/rust-cache hashes env into its key, so this only invalidates
`shared-key: coverage` on the merge run. The clippy/doc/msrv shared
keys stay warm — keeping the steady-state PR wall-clock as the goal,
not the one-time merge cost.

Coverage is preserved as a blocking PR signal; no changes to
ci-success `needs:` or `allowed-skips`. The post-processing
(LCOV diff, sticky comment) is unaffected.

Expected: `Run tests` 2m20s → ~1m45s–2m, full PR wall-clock
~4m → ~3m–3m15s. Sub-2m would need a paid larger runner, deferred.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* ci: clarify mold-scoping comment in test job

Per review feedback on PR #484: clippy/doc/msrv jobs do still link
build scripts and proc-macro cdylibs, even though they don't link the
final test binaries. Reword the comment to reflect what the scoping
decision is actually about — mold's wall-clock impact is dominated
by the test job's many large instrumented binaries — instead of
overstating that other jobs don't link at all.

No behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* ci: correct debuginfo level + fix mechanism claims in comments

Self-review caught real issues that flowed from the original commit's
comments into the actual flag choice. Fixing:

* RUSTFLAGS bug: was `-C debuginfo=1`, now `-C debuginfo=line-tables-only`.
  Per `rustc -C help`, `=1` is the alias for "limited", which still
  emits subprogram DIEs and inlined-call info. `=line-tables-only` is
  strictly tighter — exactly the `.debug_line`-only output the comment
  block claimed we were already producing. Behavior change: build now
  actually emits less debug info than before.

* Swatinem/rust-cache mechanism comment was wrong. The original wording
  said setting RUSTFLAGS at step level "invalidates the coverage shared-
  key." That's not what happens: the rust-cache step runs earlier in
  the job and doesn't observe this step-level env, so the cache key
  isn't invalidated at all. The actual mechanism is cargo's per-artifact
  fingerprint detecting the RUSTFLAGS change and recompiling affected
  crates within the restored target/. Conclusion (clippy/doc/msrv stay
  warm) still holds, but for a different reason.

* `--no-clean` comment was inverted. cargo-llvm-cov runs
  `cargo clean --package <each>` per invocation by default; --no-clean
  actively suppresses that. Without it, the rust-cache restore would
  be wiped by cargo-llvm-cov before the build started. The flag is
  doing real work, not just being defensive.

Also dropped rot-prone counts from the comments (8-crate, ~8 binaries,
specific dep names). The reasoning stands without them and they go
stale every time a crate is added.

No semantic change to the linker (still mold), the split-debuginfo
setting, the cache-disable knob, or the --no-clean flag itself. Only
the debuginfo level changes: limited → line-tables-only.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* ci: move RUSTFLAGS to job-level env so rust-cache sees it

Step-level env was the wrong scope. Evidence from PR #484's first three
runs (all ~7m50s for the test job, vs ~2m20s baseline):

  Run 1 (cold): "Cache hit for: v0-rust-coverage-...-ae62368c-b23bd388"
                — restored main's old-RUSTFLAGS target.
  Build:        starts compiling proc-macro2/quote/syn/serde from scratch
                — cargo's per-artifact fingerprint saw the new RUSTFLAGS
                in step env and invalidated everything in the restored
                target/.
  Post:         "Cache up-to-date." — Swatinem skipped the save because
                its cache key (computed without seeing the step env)
                matched an existing entry.
  Run 2 & 3:    same key, same restore, same full rebuild, same skipped
                save. Groundhog Day.

Fix: hoist RUSTFLAGS and CARGO_INCREMENTAL from the `Run tests` step's
env to the job's env. rust-cache's `Swatinem/rust-cache` step then runs
inside this env, hashes RUST*/CARGO* env into its cache key (per its
config.ts), and gives the `coverage` partition a key that actually
reflects the build configuration. First post-merge run misses cleanly
once and saves the new target; every subsequent run hits warm.

The env is bounded to this job's `env:` block, so other jobs
(clippy/doc/msrv) still don't inherit it. Their warm caches are
preserved — that property was already verified on the prior runs
(clippy ~45s, doc ~45s, MSRV ~43s, unchanged from baseline).

Comment block at the previous step-level `env:` location moves to the
job-level `env:` and is rewritten to reflect the actual mechanism. The
narrative comment at the `Run tests` step is shortened — it no longer
needs to re-explain RUSTFLAGS scoping, only the `--no-clean` rationale.

No semantic change to mold, debuginfo level, split-debuginfo, or
CARGO_INCREMENTAL=0; only the env's *scope* changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* ci: trigger warm-cache measurement run

No-op commit to force a CI run that hits the freshly-saved
v0-rust-coverage-Linux-x64-d64fc7f4-b23bd388 cache cleanly. The
preceding run (6a00c37) was a one-time cache miss after the cache-key
fix landed; this run is the actual wall-clock measurement.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.

2 participants