Skip to content

Commit 2f56cd1

Browse files
authored
Merge pull request #2 from actions-rust-lang/support-toolchain-file
Add support for toolchain files
2 parents c17331e + 08934cd commit 2f56cd1

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

.github/workflows/ci.yml

+20-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,28 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
rust: [nightly, beta, stable]
16+
rust: [
17+
# Test with toolchain file override
18+
"1.50",
19+
"nightly",
20+
"beta",
21+
"stable",
22+
]
1723
steps:
1824
- uses: actions/checkout@v3
25+
# Test toolchain file support
26+
- name: Write rust-toolchain.toml
27+
run: |
28+
cat <<EOF >>rust-toolchain.toml
29+
[toolchain]
30+
channel = "nightly-2020-07-10"
31+
components = [ "rustfmt", "rustc-dev" ]
32+
targets = [ "wasm32-unknown-unknown", "thumbv2-none-eabi" ]
33+
profile = "minimal"
34+
EOF
35+
shell: bash
36+
if: matrix.rust == '1.50'
37+
1938
- uses: ./
2039
name: Run actions-rust-lang/setup-rust-toolchain ${{matrix.rust}}
2140
id: toolchain

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.2.0] - 2022-07-21
11+
12+
### Added
13+
14+
* Prefer toolchain definitions in `rust-toolchain` or `rust-toolchain.toml` files ([Toolchain File](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file)).
15+
Other input values are ignored if either file is found.
16+
1017
## [1.1.0] - 2022-07-19
1118

1219
### Added

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
## Inputs
3030
3131
All inputs are optional.
32+
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, it takes precedence.
33+
All input values are ignored if a toolchain file exists.
3234

3335
| Name | Description | Default |
3436
| ------------ | --------------------------------------------------------------------------------- | ------- |

action.yml

+17-10
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,29 @@ runs:
6060
shell: bash
6161
- name: rustup toolchain install ${{inputs.toolchain}}
6262
run: |
63-
rustup toolchain install ${{inputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
64-
rustup default ${{inputs.toolchain}}
63+
if [[ -f "rust-toolchain" || -f "rust-toolchain.toml" ]]
64+
then
65+
# Install the toolchain as specified in the file
66+
# Might break at some point: https://github.com/rust-lang/rustup/issues/1397
67+
rustup show
68+
else
69+
rustup toolchain install ${{inputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
70+
rustup default ${{inputs.toolchain}}
71+
fi
6572
shell: bash
6673

6774
- name: Print installed versions
6875
id: versions
6976
run: |
70-
echo "::set-output name=rustc-version::$(rustc +${{inputs.toolchain}} --version)"
71-
rustc +${{inputs.toolchain}} --version --verbose
72-
echo "::set-output name=cargo-version::$(cargo +${{inputs.toolchain}} --version)"
73-
cargo +${{inputs.toolchain}} --version --verbose
74-
echo "::set-output name=rustup-version::$(rustup +${{inputs.toolchain}} --version)"
75-
rustup +${{inputs.toolchain}} --version
77+
echo "::set-output name=rustc-version::$(rustc --version)"
78+
rustc --version --verbose
79+
echo "::set-output name=cargo-version::$(cargo --version)"
80+
cargo --version --verbose
81+
echo "::set-output name=rustup-version::$(rustup --version)"
82+
rustup --version
7683
77-
DATE=$(rustc +${{inputs.toolchain}} --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p')
78-
HASH=$(rustc +${{inputs.toolchain}} --version --verbose | sed -ne 's/^commit-hash: //p')
84+
DATE=$(rustc --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p')
85+
HASH=$(rustc --version --verbose | sed -ne 's/^commit-hash: //p')
7986
echo "::set-output name=cachekey::$(echo $DATE$HASH | head -c12)"
8087
shell: bash
8188

0 commit comments

Comments
 (0)