Skip to content

Commit bb3f6a1

Browse files
authored
Merge pull request #26 from Twey/allow-overriding-toolchain-file
2 parents c7e1de2 + 99ab88a commit bb3f6a1

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: CI
32

43
on:
@@ -8,14 +7,14 @@ on:
87

98
jobs:
109
install:
11-
name: Rust ${{matrix.rust}} ${{matrix.os}}
10+
name: Rust ${{matrix.rust || '(toolchain file)'}} ${{matrix.os}}
1211
runs-on: ${{matrix.os}}
1312
strategy:
1413
fail-fast: false
1514
matrix:
1615
rust: [
1716
# Test with toolchain file override
18-
"1.60",
17+
"",
1918
# Test that the sparse registry check works.
2019
# 1.66 and 1.67 don't support stable sparse registry.
2120
"1.66",
@@ -41,10 +40,10 @@ jobs:
4140
profile = "minimal"
4241
EOF
4342
shell: bash
44-
if: matrix.rust == '1.60'
43+
if: matrix.rust == ''
4544

4645
- uses: ./
47-
name: Run actions-rust-lang/setup-rust-toolchain ${{matrix.rust}}
46+
name: Run actions-rust-lang/setup-rust-toolchain ${{matrix.rust || 'on toolchain file'}}
4847
id: toolchain
4948
with:
5049
toolchain: ${{matrix.rust}}

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
@@ -112,9 +111,9 @@ runs:
112111
fi
113112
if: runner.os != 'Windows'
114113
shell: bash
115-
- name: rustup toolchain install ${{inputs.toolchain}}
114+
- name: rustup toolchain install ${{inputs.toolchain || 'stable'}}
116115
run: |
117-
if [[ -f "rust-toolchain" || -f "rust-toolchain.toml" ]]
116+
if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]]
118117
then
119118
# Install the toolchain as specified in the file
120119
# Might break at some point: https://github.com/rust-lang/rustup/issues/1397
@@ -126,10 +125,15 @@ runs:
126125
rustup target add ${targets//,/ }
127126
fi
128127
else
129-
rustup toolchain install ${{inputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
130-
rustup default ${{inputs.toolchain}}
128+
if [[ -z "$toolchain" ]]
129+
then
130+
toolchain=stable
131+
fi
132+
rustup toolchain install $toolchain${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
133+
rustup default $toolchain
131134
fi
132135
env:
136+
toolchain: ${{inputs.toolchain}}
133137
targets: ${{inputs.target}}
134138
components: ${{inputs.components}}
135139
shell: bash

0 commit comments

Comments
 (0)