From 22cc6ffb5a442ba74456eb2335685bd9fa161ab8 Mon Sep 17 00:00:00 2001 From: Constantin Nickel Date: Tue, 14 Mar 2023 21:55:29 +0100 Subject: [PATCH 1/2] Set `rust-version` in Cargo metadata It limits clippy to only warn about lints that are compatible with the current MSRV. --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 9081c429..f966ec3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ version = "0.22.1" exclude = ["assets/syntaxes/*", "assets/themes/*"] build = "build.rs" edition = '2018' +rust-version = "1.62" [features] default = ["application"] From 40abebff8ecf213d65e5a3ae205823990a79f57d Mon Sep 17 00:00:00 2001 From: Constantin Nickel Date: Tue, 14 Mar 2023 22:14:29 +0100 Subject: [PATCH 2/2] Get the MSRV for the build job from the package metadata Co-authored-by: Martin Nordholts --- .github/workflows/CICD.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 260278e1..211815f2 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -1,7 +1,6 @@ name: CICD env: - MIN_SUPPORTED_RUST_VERSION: "1.62.0" CICD_INTERMEDIATES_DIR: "_cicd-intermediates" on: @@ -42,10 +41,13 @@ jobs: - name: Checkout source code uses: actions/checkout@v3 - - name: Install rust toolchain (v${{ env.MIN_SUPPORTED_RUST_VERSION }}) + - name: Get the MSRV from the package metadata + id: msrv + run: cargo metadata --no-deps --format-version 1 | jq -r '"version=" + (.packages[] | select(.name = "bat").rust_version)' >> $GITHUB_OUTPUT + - name: Install rust toolchain (v${{ steps.msrv.outputs.version }}) uses: dtolnay/rust-toolchain@master with: - toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }} + toolchain: ${{ steps.msrv.outputs.version }} components: clippy - name: Run clippy (on minimum supported rust version to prevent warnings we can't fix) run: cargo clippy --locked --all-targets ${{ env.MSRV_FEATURES }}