Skip to content

Commit cdf8ef4

Browse files
fix(ci): pin Rust toolchain from .tool-versions and add MSVC target on Windows
Read rust version from .tool-versions instead of bare 'nightly' in CI workflow, composite action, and Taskfile CI tasks. Add MSVC target to setup-rust-toolchain on Windows runners. Fix setup-rust-windows status check to verify x86_64-pc-windows-msvc target is installed, preventing the task from being skipped when nightly is already present without the MSVC standard library.
1 parent b8b2d3e commit cdf8ef4

3 files changed

Lines changed: 29 additions & 11 deletions

File tree

.github/actions/setup-tauri-build/action.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ inputs:
99
runs:
1010
using: 'composite'
1111
steps:
12+
- name: Read pinned Rust toolchain from .tool-versions
13+
id: rust-version
14+
shell: bash
15+
run: |
16+
version=$(grep '^rust ' .tool-versions | awk '{print $2}')
17+
echo "toolchain=${version}" >> "$GITHUB_OUTPUT"
18+
1219
- name: Setup macOS self-hosted runner PATH
1320
if: runner.os == 'macOS'
1421
shell: bash
@@ -46,10 +53,11 @@ runs:
4653
run: npm ci
4754

4855

49-
- name: Setup Rust nightly toolchain
56+
- name: Setup Rust toolchain (${{ steps.rust-version.outputs.toolchain }})
5057
uses: actions-rust-lang/setup-rust-toolchain@v1
5158
with:
52-
toolchain: nightly
59+
toolchain: ${{ steps.rust-version.outputs.toolchain }}
60+
target: ${{ runner.os == 'Windows' && 'x86_64-pc-windows-msvc' || '' }}
5361
cache: false
5462

5563
- name: Setup CI environment (macOS/Linux)

.github/workflows/test.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ jobs:
4040
4141
- uses: actions/checkout@v6
4242

43+
- name: Read pinned Rust toolchain from .tool-versions
44+
id: rust-version
45+
shell: bash
46+
run: |
47+
version=$(grep '^rust ' .tool-versions | awk '{print $2}')
48+
echo "toolchain=${version}" >> "$GITHUB_OUTPUT"
49+
4350
- name: Setup Rust
4451
uses: actions-rust-lang/setup-rust-toolchain@v1
4552
with:
46-
toolchain: nightly
53+
toolchain: ${{ steps.rust-version.outputs.toolchain }}
4754
components: clippy, rustfmt
4855
cache: false
4956

taskfiles/ci.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ vars:
1515
CONFIG: '{{.CONFIG | default ""}}'
1616
CONFIG_FLAG: '{{if .CONFIG}}--config {{.CONFIG}}{{end}}'
1717
EXE_EXT: '{{if eq OS "windows"}}.exe{{end}}'
18+
PINNED_RUST:
19+
sh: grep '^rust ' {{.ROOT_DIR}}/.tool-versions | awk '{print $2}'
1820

1921
env:
2022
PATH: "{{.CARGO_BIN}}:{{.MISE_SHIMS}}:{{.PATH}}"
2123
RUSTC_WRAPPER: ""
22-
RUSTUP_TOOLCHAIN: nightly
24+
RUSTUP_TOOLCHAIN: "{{.PINNED_RUST}}"
2325

2426
tasks:
2527
setup:
@@ -33,27 +35,28 @@ tasks:
3335
platforms: [darwin, linux]
3436
cmds:
3537
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs |
36-
sh -s -- -y --default-toolchain nightly --no-modify-path
37-
- rustup toolchain install nightly --profile minimal --no-self-update
38-
- rustup default nightly
38+
sh -s -- -y --default-toolchain {{.PINNED_RUST}} --no-modify-path
39+
- rustup toolchain install {{.PINNED_RUST}} --profile minimal --no-self-update
40+
- rustup default {{.PINNED_RUST}}
3941
- rustc --version
4042
- cargo --version
4143
status:
4244
- test -x "{{.CARGO_BIN}}/rustup"
4345
- test -x "{{.CARGO_BIN}}/rustc"
4446
- test -x "{{.CARGO_BIN}}/cargo"
45-
- rustup run nightly rustc --version
47+
- rustup run {{.PINNED_RUST}} rustc --version
4648

4749
setup-rust-windows:
4850
desc: "Configure rustup nightly toolchain (Windows)"
4951
platforms: [windows]
5052
cmds:
51-
- rustup toolchain install nightly --profile minimal --no-self-update --target x86_64-pc-windows-msvc
52-
- rustup default nightly
53+
- rustup toolchain install {{.PINNED_RUST}} --profile minimal --no-self-update --target x86_64-pc-windows-msvc
54+
- rustup default {{.PINNED_RUST}}
5355
- rustc --version
5456
- cargo --version
5557
status:
56-
- rustup run nightly rustc --version
58+
- rustup run {{.PINNED_RUST}} rustc --version
59+
- rustup target list --installed --toolchain {{.PINNED_RUST}} | findstr x86_64-pc-windows-msvc
5760

5861
setup-cargo-tools:
5962
desc: "Install cargo-binstall and tauri-cli"

0 commit comments

Comments
 (0)