Skip to content

Commit a5e0472

Browse files
ci: Check equality of rust versions (#253)
Add a new workflow which obtains - the rust version from the project's rust-toolchain.toml - the rust version from the CI toolchain and tests that they are equal. This check captures the policy (going forward, up to revision) that twenty-first only offers guarantees about compiling on the latest rust version. Co-authored-by: Ferdinand Sauer <ferdinand@neptune.cash>
1 parent 79a37aa commit a5e0472

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/versions.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Version Check
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
check-rust-version:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Install Stable Rust Toolchain
18+
uses: dtolnay/rust-toolchain@stable
19+
20+
# Capture the version installed by the action (immediately after install)
21+
# Ignore the point (patch) release number.
22+
- name: Capture installed rustc version
23+
id: installed_version
24+
run: |
25+
INSTALLED=$(rustc --version | awk '{print $2}' | awk -F. '{print $1"."$2}')
26+
echo "installed_version=$INSTALLED" >> $GITHUB_OUTPUT
27+
28+
- name: Extract rust-toolchain.toml version
29+
id: toolchain_version
30+
run: |
31+
VERSION=$(grep -E '^channel\s*=' rust-toolchain.toml | cut -d '"' -f2)
32+
echo "toolchain_version=$VERSION" >> $GITHUB_OUTPUT
33+
34+
- name: Compare Rust versions
35+
run: |
36+
echo "Installed rustc version: ${{ steps.installed_version.outputs.installed_version }}"
37+
echo "rust-toolchain.toml version: ${{ steps.toolchain_version.outputs.toolchain_version }}"
38+
39+
if [[ "${{ steps.toolchain_version.outputs.toolchain_version }}" != "${{ steps.installed_version.outputs.installed_version }}" ]]; then
40+
echo "Mismatch: rust-toolchain.toml and installed rustc version differ"
41+
exit 1
42+
fi
43+
echo "All Rust versions match."

0 commit comments

Comments
 (0)