@@ -22,10 +22,31 @@ jobs:
2222 ref : ${{ github.event.pull_request.head.sha }}
2323 submodules : recursive
2424
25+ - name : Install yq
26+ run : |
27+ set -euo pipefail
28+ YQ_VERSION="v4.52.4"
29+ mkdir -p "$HOME/.local/bin"
30+ wget -qO "$HOME/.local/bin/yq" \
31+ "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"
32+ chmod +x "$HOME/.local/bin/yq"
33+ echo "$HOME/.local/bin" >> $GITHUB_PATH
34+
35+ - name : ' Read nightly channel from rust-toolchain.toml'
36+ id : toolchain-meta
37+ run : |
38+ set -euo pipefail
39+ CHANNEL=$(yq -r '.toolchain.channel' rust-toolchain.toml)
40+ if [ -z "$CHANNEL" ] || [ "$CHANNEL" = "null" ]; then
41+ echo "::error::Could not read toolchain.channel from rust-toolchain.toml"
42+ exit 1
43+ fi
44+ echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT"
45+
2546 - name : " Set up nightly Rust" # https://github.com/rust-lang/rustup/issues/3409
2647 uses : dtolnay/rust-toolchain@master
2748 with :
28- toolchain : nightly-2024-11-29 # Hardcoded version, same as is in the build.rs
49+ toolchain : ${{ steps.toolchain-meta.outputs.channel }}
2950
3051 - name : ' Build stable-mir-json' # rustfmt documentation claims it is unstable on code that doesn't build
3152 run : |
@@ -66,10 +87,31 @@ jobs:
6687 ref : ${{ github.event.pull_request.head.sha }}
6788 submodules : recursive
6889
90+ - name : Install yq
91+ run : |
92+ set -euo pipefail
93+ YQ_VERSION="v4.52.4"
94+ mkdir -p "$HOME/.local/bin"
95+ wget -qO "$HOME/.local/bin/yq" \
96+ "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"
97+ chmod +x "$HOME/.local/bin/yq"
98+ echo "$HOME/.local/bin" >> $GITHUB_PATH
99+
100+ - name : ' Read nightly channel from rust-toolchain.toml'
101+ id : toolchain-meta
102+ run : |
103+ set -euo pipefail
104+ CHANNEL=$(yq -r '.toolchain.channel' rust-toolchain.toml)
105+ if [ -z "$CHANNEL" ] || [ "$CHANNEL" = "null" ]; then
106+ echo "::error::Could not read toolchain.channel from rust-toolchain.toml"
107+ exit 1
108+ fi
109+ echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT"
110+
69111 - name : " Set up nightly Rust" # https://github.com/rust-lang/rustup/issues/3409
70112 uses : dtolnay/rust-toolchain@master
71113 with :
72- toolchain : nightly-2024-11-29 # Hardcoded version, same as is in the build.rs
114+ toolchain : ${{ steps.toolchain-meta.outputs.channel }}
73115
74116 - name : ' Build stable-mir-json'
75117 run : | # Warning check should be redundant since code-quality runs first
@@ -108,16 +150,30 @@ jobs:
108150 "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"
109151 chmod +x "$HOME/.local/bin/yq"
110152 echo "$HOME/.local/bin" >> $GITHUB_PATH
111- yq --version
112153
154+ - name : ' Read nightly channel from rust-toolchain.toml'
155+ id : toolchain-meta
156+ run : |
157+ set -euo pipefail
158+ CHANNEL=$(yq -r '.toolchain.channel' rust-toolchain.toml)
159+ if [ -z "$CHANNEL" ] || [ "$CHANNEL" = "null" ]; then
160+ echo "::error::Could not read toolchain.channel from rust-toolchain.toml"
161+ exit 1
162+ fi
163+ echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT"
164+
165+ - name : " Set up nightly Rust" # https://github.com/rust-lang/rustup/issues/3409
166+ uses : dtolnay/rust-toolchain@master
167+ with :
168+ toolchain : ${{ steps.toolchain-meta.outputs.channel }}
113169
114- - name : ' Read rustc commit from rust-toolchain.toml '
170+ - name : ' Derive rustc commit and check out Rust repo '
115171 id : rustc-meta
116172 run : |
117173 set -euo pipefail
118- COMMIT=$(yq '.metadata. rustc- commit' rust-toolchain.toml )
119- if [ -z "$COMMIT" ] || [ "$COMMIT" = "null" ] ; then
120- echo "::error::metadata.rustc-commit not found in rust-toolchain.toml "
174+ COMMIT=$(rustc -vV | grep ' commit-hash' | cut -d' ' -f2 )
175+ if [ -z "$COMMIT" ]; then
176+ echo "::error::Could not determine rustc commit-hash from 'rustc -vV' "
121177 exit 1
122178 fi
123179 echo "rustc-commit=$COMMIT" >> "$GITHUB_OUTPUT"
@@ -130,11 +186,6 @@ jobs:
130186 path : rust
131187 fetch-depth : 1
132188
133- - name : " Set up nightly Rust" # https://github.com/rust-lang/rustup/issues/3409
134- uses : dtolnay/rust-toolchain@master
135- with :
136- toolchain : nightly-2024-11-29 # Hardcoded version, same as is in the build.rs
137-
138189 - name : ' Build stable-mir-json'
139190 run : | # Warning check should be redundant since code-quality runs first
140191 RUSTFLAGS='--deny warnings' cargo build -vv
0 commit comments