Skip to content

chore: Rust format and testing in CI#2205

Open
aclauer wants to merge 7 commits into
mainfrom
andrew/chore/rust-tests-in-ci
Open

chore: Rust format and testing in CI#2205
aclauer wants to merge 7 commits into
mainfrom
andrew/chore/rust-tests-in-ci

Conversation

@aclauer
Copy link
Copy Markdown
Collaborator

@aclauer aclauer commented May 21, 2026

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 run cargo fmt, cargo clippy, cargo test in 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

  • I have read and approved the CLA.

@aclauer aclauer linked an issue May 21, 2026 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@aclauer aclauer marked this pull request as ready for review May 21, 2026 16:56
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 21, 2026

Greptile Summary

This PR introduces a rust CI job that auto-discovers all Cargo workspaces via find Cargo.lock, then runs cargo fmt, cargo clippy, and cargo test across every discovered workspace. The job is added as a required gate in ci-complete.

  • Workspace discovery uses find with GNU-specific -printf '%h\ ', which is correct on ubuntu-latest and the output is safely passed as a multiline heredoc to GITHUB_OUTPUT.
  • Cargo commands all scope to the full workspace (--workspace, --all-targets, --all-features, --locked); fmt, clippy, and tests are guarded consistently.
  • Sequential loops process each discovered workspace one at a time in a single runner, which diverges from the PR description's claim of parallel execution.

Confidence Score: 5/5

Safe to merge — the workflow correctly discovers workspaces, runs all three cargo checks with appropriate flags, and gates ci-complete on the new job.

The cargo commands are well-formed, workspace flags are consistent across all three steps, and the heredoc output pattern is correctly used. The only gap is that the workspace loops run sequentially rather than in parallel, but this is a performance concern, not a correctness one.

No files require special attention; the single changed file is straightforward CI configuration.

Important Files Changed

Filename Overview
.github/workflows/ci.yml Adds a rust job that auto-discovers Cargo workspaces via find, then sequentially runs cargo fmt, cargo clippy, and cargo test in each; job is wired into ci-complete as a required gate

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Push / PR event] --> B[rust job]
    B --> C[Checkout]
    C --> D[Find Cargo workspace roots\nfind Cargo.lock → crates output]
    D --> E[Install Rust toolchain\nrustfmt + clippy]
    E --> F[Cache cargo build\nSwatinem/rust-cache]
    F --> G[cargo fmt loop\nfor each workspace sequentially]
    G --> H[cargo clippy loop\nfor each workspace sequentially]
    H --> I[cargo test loop\nfor each workspace sequentially]
    I --> J[ci-complete gate\nalls-green check]
    J -->|pass| K[Branch protection satisfied]
    J -->|fail| L[PR blocked]
Loading

Reviews (4): Last reviewed commit: "Remove crate matrix and discovery job" | Re-trigger Greptile

Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
@leshy
Copy link
Copy Markdown
Member

leshy commented May 22, 2026

@Dreamsorcerer can you review?

Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
leshy and others added 4 commits May 22, 2026 16:45
Co-authored-by: Sam Bull <git@sambull.org>
Co-authored-by: Sam Bull <git@sambull.org>
Co-authored-by: Sam Bull <git@sambull.org>
leshy
leshy previously approved these changes May 22, 2026
@leshy leshy enabled auto-merge (squash) May 22, 2026 13:46
Comment thread .github/workflows/ci.yml Outdated
Comment on lines +71 to +72
matrix:
crate: ${{ fromJSON(needs.rust-discover.outputs.crates) }}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oops I approved, but disabled auto-merge, letting you guys decide, just ping me when you need approval

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's a good point, I'll change that

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be fixed now, also removed the separate discover job

@leshy leshy disabled auto-merge May 22, 2026 13:47
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.

Add Rust tests to CI

3 participants