diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c150e354..2fd9e23f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,23 @@ jobs: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - &install-rust + name: Install rust + uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 + with: + override: true + components: rustfmt, clippy + - &cache-cargo + name: Cache cargo registry + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target/${{ env.BUILD_PROFILE }} + key: ${{ runner.os }}-cargo-${{ env.BUILD_PROFILE }}-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-${{ env.BUILD_PROFILE }}- - name: Install system dependencies run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libpq-dev - name: Export POSTGRES_TEST_URL @@ -38,7 +54,7 @@ jobs: with: url: postgres://postgres:password@localhost/test - name: Format - run: rustup component add rustfmt --toolchain nightly-2025-06-10 && cargo +nightly-2025-06-10 fmt --all -- --check + run: cargo fmt --all -- --check - name: Lint run: cargo clippy --no-default-features --features ${{ matrix.feature }} -- -D warnings - name: Test @@ -65,9 +81,8 @@ jobs: CODESCENE_CLI_SHA256: "a1c38415c5978908283c0608b648b27e954c93882b15d8b91d052d846c3eabd8" steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - components: llvm-tools-preview + - *install-rust + - *cache-cargo - uses: taiki-e/install-action@v2 with: tool: cargo-llvm-cov diff --git a/AGENTS.md b/AGENTS.md index 8f33a62e..d35fe794 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -94,7 +94,7 @@ This repository is written in Rust and uses Cargo for building and dependency management. Contributors should follow these best practices when working on the project: -- Run `cargo +nightly-2025-06-10 fmt --all` after making any change, and run +- Run `cargo fmt --all` after making any change, and run `cargo clippy -- -D warnings` and `RUSTFLAGS="-D warnings" cargo test` before committing. - Clippy warnings MUST be disallowed. diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..5f1b4070 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "nightly-2025-06-10" +components = ["rustfmt", "clippy"] diff --git a/test-util/src/lib.rs b/test-util/src/lib.rs index 297a1a36..2c1084ff 100644 --- a/test-util/src/lib.rs +++ b/test-util/src/lib.rs @@ -221,7 +221,7 @@ impl Drop for PostgresTestDb { /// /// ```rust /// use rstest::rstest; -/// use test_util::{postgres_db, PostgresTestDb}; +/// use test_util::{PostgresTestDb, postgres_db}; /// /// #[rstest] /// fn my_test(postgres_db: PostgresTestDb) {