chore: Rust format and testing in CI#2205
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR adds a
Confidence Score: 5/5Safe to merge — the new The implementation is straightforward and avoids the matrix-empty-list pitfall by using a for loop. All three Cargo commands use consistent, workspace-wide flags. The only note is that unquoted No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant GHA as GitHub Actions
participant find as find (Cargo.lock)
participant toolchain as dtolnay/rust-toolchain
participant cache as Swatinem/rust-cache
participant cargo as cargo (per workspace)
GHA->>find: Search repo for Cargo.lock files
find-->>GHA: Newline-separated workspace paths → GITHUB_OUTPUT
GHA->>toolchain: Install stable + rustfmt + clippy
GHA->>cache: Cache cargo build (workspaces list)
loop For each workspace path
GHA->>cargo: cargo fmt --all -- --check
cargo-->>GHA: exit 0 / non-zero
GHA->>cargo: cargo clippy --workspace --all-targets --all-features --locked -D warnings
cargo-->>GHA: exit 0 / non-zero
GHA->>cargo: cargo test --workspace --all-features --locked
cargo-->>GHA: exit 0 / non-zero
end
GHA->>GHA: ci-complete evaluates rust job result
Reviews (5): Last reviewed commit: "Merge branch 'main' into andrew/chore/ru..." | Re-trigger Greptile |
|
@Dreamsorcerer can you review? |
Co-authored-by: Sam Bull <git@sambull.org>
Co-authored-by: Sam Bull <git@sambull.org>
Co-authored-by: Sam Bull <git@sambull.org>
| matrix: | ||
| crate: ${{ fromJSON(needs.rust-discover.outputs.crates) }} |
There was a problem hiding this comment.
One blocking detail here I think. I don't think we should be using a matrix here, atleast from what I see of the current run.
Currently, this results in 3 separate jobs, requiring 3 workers. Each job only takes ~20s with about 50% of that time doing the setup/teardown of the job.
So currently this is basically 3 x 20s, instead of 1 x 40s. The difference today is neglible, but if we start adding in more crates over time, then this will lead to worker starvation and delay the other (slower) test jobs.
There was a problem hiding this comment.
oops I approved, but disabled auto-merge, letting you guys decide, just ping me when you need approval
There was a problem hiding this comment.
That's a good point, I'll change that
There was a problem hiding this comment.
should be fixed now, also removed the separate discover job
Problem
Need to run Rust formatting checks and tests in CI
Closes DIM-938
Solution
Added auto discovery job to find all Rust workspaces in the repository based on
Cargo.lock. Then runcargo fmt,cargo clippy,cargo testin all work spaces in parallel.How to Test
Run in CI, result of all three commands matches local results. All workspaces are automatically detected without any hardcoded paths.
Contributor License Agreement