Skip to content

Commit 6cf32b9

Browse files
committed
#113 perf: use MSRV toolchain for coverage to share cache
1 parent 32c9ced commit 6cf32b9

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

.github/workflows/reusable-ci.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,27 @@ jobs:
216216
steps:
217217
- uses: actions/checkout@v5
218218

219-
- name: Install Rust stable
219+
- name: Read MSRV from Cargo.toml
220+
id: msrv
221+
shell: bash
222+
run: |
223+
set -euo pipefail
224+
if ! command -v jq >/dev/null 2>&1; then
225+
sudo apt-get update -y && sudo apt-get install -y jq
226+
fi
227+
RV=$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].rust_version // empty')
228+
if [ -z "$RV" ]; then
229+
echo "rust-version is not set in Cargo.toml"
230+
exit 1
231+
fi
232+
[[ "$RV" =~ ^[0-9]+\.[0-9]+$ ]] && RV="${RV}.0"
233+
echo "msrv=${RV}" >> "$GITHUB_OUTPUT"
234+
echo "Using MSRV: $RV"
235+
236+
- name: Install Rust (${{ steps.msrv.outputs.msrv }})
220237
uses: dtolnay/rust-toolchain@v1
221238
with:
222-
toolchain: stable
239+
toolchain: ${{ steps.msrv.outputs.msrv }}
223240
components: llvm-tools-preview
224241

225242
- name: Cache cargo
@@ -237,7 +254,7 @@ jobs:
237254
shell: bash
238255
run: |
239256
set -euo pipefail
240-
cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
257+
cargo +${{ steps.msrv.outputs.msrv }} llvm-cov --all-features --workspace --lcov --output-path lcov.info
241258
242259
- name: Upload coverage to Codecov
243260
uses: codecov/codecov-action@v5

0 commit comments

Comments
 (0)