Skip to content

ci: harden Rust CI/CD - #1051

Merged
scarmuega merged 8 commits into
mainfrom
ci/harden-rust-cicd
Jul 8, 2026
Merged

ci: harden Rust CI/CD#1051
scarmuega merged 8 commits into
mainfrom
ci/harden-rust-cicd

Conversation

@scarmuega

@scarmuega scarmuega commented Jul 8, 2026

Copy link
Copy Markdown
Member

Modernizes the Rust CI workflow and pins the toolchain, plus a one-time cargo fmt sweep to bring the tree into compliance with the pinned formatter.

Changes

  • .github/workflows/ci.yml — split the old monolithic check job into three jobs (fmt, clippy, test) that run in parallel; migrate off the archived actions-rs/* actions to dtolnay/rust-toolchain; add permissions: contents: read, concurrency with cancel-in-progress, persist-credentials: false, Swatinem/rust-cache@v2, and matrix fail-fast: false.
    • fmt runs on nightly rustfmt, because rustfmt.toml enables wrap_comments — an unstable option that stable rustfmt silently ignores. Running nightly makes the comment-wrapping check actually enforced. Local devs should format with cargo +nightly fmt.
    • clippy runs --all-targets --all-features -- -D warnings on the pinned toolchain.
    • fmt and clippy are blocking (no continue-on-error); all three jobs should be marked required in branch protection.
  • rust-toolchain.toml (new) — pins channel = "1.91" with rustfmt + clippy components so local and CI toolchains agree.
  • 86-file cargo fmt sweep — one-time reformat bringing the codebase into compliance with the pinned formatter (main currently fails cargo fmt --check). Formatting only; no logic changes.

Diff stat

 88 files changed, 658 insertions(+), 459 deletions(-)

Only .github/workflows/ci.yml and rust-toolchain.toml are functional; the remaining 86 files are the formatting sweep.

Not in scope

This PR does not touch cargo-dist (dist-workspace.toml), Docker (docker.yml), crate publishing, or changelog (cliff.toml) — those remain as they are on main.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@scarmuega, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2696698b-6f7f-4434-9224-967c21d367a4

📥 Commits

Reviewing files that changed from the base of the PR and between ae94e05 and da76eb2.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml
📝 Walkthrough

Walkthrough

This PR splits CI linting into separate fmt and clippy jobs, pins Rust 1.91 with rust-toolchain.toml, and applies formatting-only edits and doc-comment reflows across workspace crates, bootstrap code, sync code, tests, and supporting utilities.

Changes

CI, toolchain, and formatting sweep

Layer / File(s) Summary
Workflow controls and toolchain
.github/workflows/ci.yml, rust-toolchain.toml
Adds workflow-wide permissions and concurrency controls, splits the prior check job into fmt and clippy, rewires test to depend on clippy, and pins Rust 1.91 with rustfmt and clippy components.
Cardano module formatting
crates/cardano/src/estart/*, crates/cardano/src/ewrap/*, crates/cardano/src/model/*, crates/cardano/src/rewards/mod.rs, crates/cardano/src/roll/*, crates/cardano/src/rupd/*, crates/cardano/src/shard.rs, crates/cardano/src/utils.rs, crates/cardano/src/work.rs, crates/cardano/src/lib.rs, crates/trp/src/methods.rs
Reflows imports, match arms, assignments, comments, doc comments, and assertions across the Cardano workspace without changing behavior.
Core, Fjall, and redb3 doc/formatting
crates/core/src/*, crates/fjall/src/index/*, crates/fjall/src/state/*, crates/fjall/src/lib.rs, crates/redb3/src/*
Reflows module and method doc comments and reformats small code blocks in core, Fjall, and redb3 without behavior changes.
Bootstrap, gRPC, sync, and tests
src/adapters/storage.rs, src/bin/dolos/bootstrap/*, src/bin/dolos/common.rs, src/bin/dolos/data/import_archive.rs, src/bin/dolos/doctor/wal_integrity.rs, src/serve/grpc/v1alpha/*, src/serve/grpc/v1beta/*, src/serve/o7s_unix/statequery.rs, src/sync/*, tests/bootstrap.rs, tests/e2e/sync.rs, tests/epoch_pots/main.rs, tests/housekeeping.rs, xtask/src/ground_truth/*, crates/testing/src/*
Reorders imports, rewraps comments, reformats iterator setup and logging, and adjusts test assertions across bootstrap, gRPC, sync, xtask, and integration test files without altering behavior.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • txpipe/dolos#895: Both PRs touch crates/cardano/src/estart/loading.rs, with the same AVVM/loading path receiving formatting-only edits here.
  • txpipe/dolos#978: Both PRs touch the shard-level EWRAP loading path in crates/cardano/src/ewrap/loading.rs, including the same counter assignments reformatted here.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: hardening the Rust CI workflow and toolchain setup.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/harden-rust-cicd

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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 (1)
.github/workflows/ci.yml (1)

34-57: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Consider making test depend on fmt as well.

The test job only depends on clippy (needs: clippy), not fmt. If fmt fails but clippy and test pass, the CI may appear green depending on branch protection configuration. Adding fmt to the needs list ensures formatting is enforced before tests run.

♻️ Proposed fix
   test:
     name: Test (${{ matrix.os }})
     runs-on: ${{ matrix.os }}
-    needs: clippy
+    needs: [clippy, fmt]
🤖 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 34 - 57, The test workflow currently
only waits on clippy, so formatting failures from fmt can be missed. Update the
test job in the CI workflow to also depend on fmt by adjusting its needs list
alongside clippy, so formatting is enforced before the test steps run.
🤖 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 12-21: Harden the CI workflow by adding a top-level permissions
block with contents: read so the read-only jobs do not inherit broader token
access, and update every actions/checkout@v4 step in the workflow to set
persist-credentials: false. Apply this consistently across the fmt, clippy, and
test jobs so the checkout in each job does not leave GITHUB_TOKEN configured in
git for the rest of the run.

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 34-57: The test workflow currently only waits on clippy, so
formatting failures from fmt can be missed. Update the test job in the CI
workflow to also depend on fmt by adjusting its needs list alongside clippy, so
formatting is enforced before the test steps run.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: f4bbf49f-7d6e-4ebf-81ee-f301de6801a9

📥 Commits

Reviewing files that changed from the base of the PR and between 4f302cf and b143e0b.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • rust-toolchain.toml

Comment thread .github/workflows/ci.yml Outdated

@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.

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

21-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Track continue-on-error: true on fmt and clippy as a temporary measure.

Both fmt and clippy jobs have continue-on-error: true, which means CI will never fail on formatting or lint issues — including newly introduced ones. The PR objectives confirm this is intentional to avoid failing on existing issues, but without a follow-up tracking issue, these quality gates risk remaining permanently advisory.

Consider adding a TODO or tracking issue to fix existing violations and remove continue-on-error once the codebase is clean.

Also applies to: 34-34

🤖 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 at line 21, The fmt and clippy jobs are currently
marked continue-on-error, so add a clear TODO or tracking reference in the CI
workflow near the affected job definitions to record that this is temporary. Use
the workflow job names for fmt and clippy as the anchors, and note that the flag
should be removed once existing violations are resolved so new formatting or
lint regressions can fail CI again.
🤖 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.

Nitpick comments:
In @.github/workflows/ci.yml:
- Line 21: The fmt and clippy jobs are currently marked continue-on-error, so
add a clear TODO or tracking reference in the CI workflow near the affected job
definitions to record that this is temporary. Use the workflow job names for fmt
and clippy as the anchors, and note that the flag should be removed once
existing violations are resolved so new formatting or lint regressions can fail
CI again.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5daaadfb-ad6f-4235-b854-f4fc340fb010

📥 Commits

Reviewing files that changed from the base of the PR and between b143e0b and 6b59f31.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • rust-toolchain.toml
✅ Files skipped from review due to trivial changes (1)
  • rust-toolchain.toml

scarmuega added 6 commits July 8, 2026 19:39
- Add rust-toolchain.toml pinning to 1.91
- Standardize CI workflow (fmt + clippy -D warnings + test, Swatinem/rust-cache)
- Align cargo-dist 0.31.0 config (where applicable)
- Add tag-based crate publish workflow (where applicable)
- Adopt dolos docker tag convention for services/backends (where applicable)
- Add cliff.toml + cargo-release pre-release-hook
The rust-toolchain.toml file takes precedence over dtolnay/rust-toolchain's
components parameter, so rustfmt and clippy were not being installed in CI.
- RUSTFLAGS: -D warnings was causing test failures (turns compile warnings
  into errors during cargo test); clippy already passes -D warnings directly
- fmt and clippy are now continue-on-error: true to avoid blocking on
  pre-existing code quality issues; maintainers can remove this once clean
- Add permissions: contents: read (least-privilege GITHUB_TOKEN)
- Add persist-credentials: false to all checkout steps
- Add concurrency group to cancel superseded CI runs
- Fix pre-release-hook: use --tag v{{version}} instead of --latest
  (--latest resolves the previous tag since the new tag doesn't exist
  yet during cargo-release's pre-release-hook)
The rustfmt.toml uses wrap_comments=true (nightly-only). Use nightly
rustfmt in CI and re-format all code accordingly.
@scarmuega
scarmuega force-pushed the ci/harden-rust-cicd branch from 98ce94a to 3d38ecb Compare July 8, 2026 22:41
scarmuega and others added 2 commits July 8, 2026 19:45
… fmt

- Remove continue-on-error from fmt and clippy so failures block merge
  (the whole point of -D warnings).
- fmt now runs on nightly rustfmt, since rustfmt.toml's wrap_comments is
  an unstable option that stable silently ignores; stable would never
  enforce the comment wrapping this branch applied.
- Run fmt/clippy/test as independent parallel jobs (drop test's
  needs: clippy) for faster feedback; all three gate via branch protection.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@scarmuega
scarmuega merged commit 79e0ea6 into main Jul 8, 2026
17 of 18 checks passed
@scarmuega
scarmuega deleted the ci/harden-rust-cicd branch July 8, 2026 23:51
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