From 9107ca6b4fd45c5d38b120077535961878dd6463 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Mon, 13 Feb 2023 17:29:33 +0100 Subject: [PATCH] Check build with the MSRV declared in Cargo.toml --- .github/workflows/test.yml | 21 +++++++++++++++++++++ .gitignore | 3 +++ scripts/force-msrv-toolchain.sh | 16 ++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100755 scripts/force-msrv-toolchain.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c5b555..7dda8f9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -73,3 +73,24 @@ jobs: SNAPSHOT_DIR: rust-${{ matrix.toolchain }} with: command: test + + msrv-build: + name: Build crate with documented MSRV + runs-on: ubuntu-latest + + steps: + - name: Checkout source code + uses: actions/checkout@v2 + + - name: Install Rust MSRV version + run: scripts/force-msrv-toolchain.sh + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build diff --git a/.gitignore b/.gitignore index 3849ca4..f808d63 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ Cargo.lock .idea *.new + +# Ignore toolchain installed by script +rust-toolchain diff --git a/scripts/force-msrv-toolchain.sh b/scripts/force-msrv-toolchain.sh new file mode 100755 index 0000000..25b279b --- /dev/null +++ b/scripts/force-msrv-toolchain.sh @@ -0,0 +1,16 @@ +#! /bin/sh +# +# Force the use of the MSRV toolchain (for use with the CI). +# Since action-rs/toolchain@v1 uses rustup 1.21.x, only the +# toolchain name can be given in the file. +# +# If you call this script in your working directory, do not +# forget that it will create a "rust-toolchain" file there. + +set -e + +root=$(dirname "$0")/.. + +version=$(sed -ne 's/rust-version *= *"\(.*\)"/\1/p' "$root"/Cargo.toml) +echo $version > "$root"/rust-toolchain +echo "Rust $version installed as the forced toolchain"