From 2555d2fc34c137c454779f3e29eecc73dc4c20bb Mon Sep 17 00:00:00 2001 From: Leynos Date: Mon, 16 Jun 2025 22:19:24 +0100 Subject: [PATCH 1/2] Add rust toolchain file and update CI --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++---- AGENTS.md | 2 +- rust-toolchain.toml | 3 +++ test-util/src/lib.rs | 2 +- 4 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c150e354..98dff08f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,21 @@ jobs: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - name: Install rust + uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 + with: + override: true + components: rustfmt, clippy + - 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('**/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 +52,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 +79,21 @@ jobs: CODESCENE_CLI_SHA256: "a1c38415c5978908283c0608b648b27e954c93882b15d8b91d052d846c3eabd8" steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - name: Install rust + uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 + with: + override: true + components: rustfmt, clippy + - name: Cache cargo registry + uses: actions/cache@v4 with: - components: llvm-tools-preview + path: | + ~/.cargo/registry + ~/.cargo/git + target/${{ env.BUILD_PROFILE }} + key: ${{ runner.os }}-cargo-${{ env.BUILD_PROFILE }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-${{ env.BUILD_PROFILE }}- - 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) { From cda3ecbdd87aff780eff53a222f8689da6a98544 Mon Sep 17 00:00:00 2001 From: Leynos Date: Tue, 17 Jun 2025 01:19:59 +0100 Subject: [PATCH 2/2] Refactor CI workflow --- .github/workflows/ci.yml | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98dff08f..2fd9e23f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,19 +29,21 @@ jobs: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v4 - - name: Install rust + - &install-rust + name: Install rust uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 with: override: true components: rustfmt, clippy - - name: Cache cargo registry + - &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('**/Cargo.lock') }} + 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 @@ -79,21 +81,8 @@ jobs: CODESCENE_CLI_SHA256: "a1c38415c5978908283c0608b648b27e954c93882b15d8b91d052d846c3eabd8" steps: - uses: actions/checkout@v4 - - name: Install rust - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 - with: - override: true - components: rustfmt, clippy - - 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('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-${{ env.BUILD_PROFILE }}- + - *install-rust + - *cache-cargo - uses: taiki-e/install-action@v2 with: tool: cargo-llvm-cov