diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index 9dbf7268..7a8dcb80 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -16,26 +16,29 @@ jobs: strategy: fail-fast: true matrix: - # 1.85 is the MSRV for the crate - rust: ['nightly', 'beta', 'stable', '1.85'] + rust: ['nightly', 'beta', 'stable', 'msrv'] runs-on: ubuntu-latest steps: - name: Checkout source uses: actions/checkout@v3 - - name: Install ${{matrix.rust}} toolchain + - name: Resolve version + id: resolve_version + run: echo "version=$(./scripts/resolve-toolchain-version.sh ${{matrix.rust}})" >> "${GITHUB_OUTPUT}" + + - name: Install ${{ steps.resolve_version.outputs.version }} toolchain if: matrix.rust == 'nightly' uses: dtolnay/rust-toolchain@master with: - toolchain: ${{matrix.rust}} + toolchain: ${{ steps.resolve_version.outputs.version }} components: miri rustfmt clippy - - name: Install ${{matrix.rust}} toolchain + - name: Install ${{ steps.resolve_version.outputs.version }} toolchain if: matrix.rust != 'nightly' uses: dtolnay/rust-toolchain@master with: - toolchain: ${{matrix.rust}} + toolchain: ${{ steps.resolve_version.outputs.version }} components: rustfmt clippy - uses: taiki-e/install-action@cargo-binstall @@ -51,4 +54,4 @@ jobs: - name: Run full test script - run: ./scripts/full-test.sh "${{matrix.rust}}" + run: ./scripts/full-test.sh "${{ steps.resolve_version.outputs.version }}" diff --git a/scripts/resolve-toolchain-version.sh b/scripts/resolve-toolchain-version.sh new file mode 100755 index 00000000..de38099f --- /dev/null +++ b/scripts/resolve-toolchain-version.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -o errexit # make script exit when a command fails +set -o nounset # make script exit when using undeclared variables +set -o pipefail # make script exit when command fails in a pipe +set -o xtrace # print a trace of all commands executed by script + +if [ "$#" -ne 1 ]; then + >&2 echo "Illegal number of parameters [$#]" + >&2 echo "usage: ${0} " + exit 1 +fi + +MAYBE_RESOLVED="${1}" + +if [[ "${MAYBE_RESOLVED}" == "msrv" ]]; then + MAYBE_RESOLVED="$(cargo metadata --no-deps --format-version 1 \ + | jq -r '.packages | map(select(.name == "blart"))[0].rust_version')" +fi + +echo "${MAYBE_RESOLVED}" \ No newline at end of file