Skip to content

Commit 5ea736b

Browse files
committed
Allow overriding the toolchain file
1 parent 317ed62 commit 5ea736b

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- uses: actions/checkout@v4
2525
- uses: actions-rust-lang/setup-rust-toolchain@v1
2626
- run: cargo test --all-features
27-
27+
2828
# Check formatting with rustfmt
2929
formatting:
3030
name: cargo fmt
@@ -42,7 +42,9 @@ jobs:
4242
## Inputs
4343
4444
All inputs are optional.
45-
If a [toolchain file](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) (i.e., `rust-toolchain` or `rust-toolchain.toml`) is found in the root of the repository, its `toolchain` value takes precedence.
45+
If a [toolchain file](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) (i.e., `rust-toolchain` or `rust-toolchain.toml`) is found in the root of the repository and no `toolchain` value is provided, all items specified in the toolchain file will be installed.
46+
If a `toolchain` value is provided, the toolchain file will be ignored.
47+
If no `toolchain` value or toolchain file is present, it will default to `stable`.
4648
First, all items specified in the toolchain file are installed.
4749
Afterward, the `components` and `target` specified via inputs are installed in addition to the items from the toolchain file.
4850

action.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ inputs:
1515
toolchain:
1616
description: "Rust toolchain specification -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification"
1717
required: false
18-
default: "stable"
1918
target:
2019
description: "Target triple to install for this toolchain"
2120
required: false
@@ -107,9 +106,9 @@ runs:
107106
fi
108107
if: runner.os != 'Windows'
109108
shell: bash
110-
- name: rustup toolchain install ${{inputs.toolchain}}
109+
- name: rustup toolchain install ${{inputs.toolchain || 'stable'}}
111110
run: |
112-
if [[ -f "rust-toolchain" || -f "rust-toolchain.toml" ]]
111+
if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]]
113112
then
114113
# Install the toolchain as specified in the file
115114
# Might break at some point: https://github.com/rust-lang/rustup/issues/1397
@@ -121,10 +120,15 @@ runs:
121120
rustup target add ${targets//,/ }
122121
fi
123122
else
124-
rustup toolchain install ${{inputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
125-
rustup default ${{inputs.toolchain}}
123+
if [[ -z "$toolchain" ]]
124+
then
125+
toolchain=stable
126+
fi
127+
rustup toolchain install $toolchain${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
128+
rustup default $toolchain
126129
fi
127130
env:
131+
toolchain: ${{inputs.toolchain}}
128132
targets: ${{inputs.target}}
129133
components: ${{inputs.components}}
130134
shell: bash

0 commit comments

Comments
 (0)