Skip to content

Commit 154a347

Browse files
authored
Merge pull request #29 from actions-rust-lang/upd-toolchain-nightly
2 parents bb3f6a1 + af70248 commit 154a347

File tree

3 files changed

+54
-42
lines changed

3 files changed

+54
-42
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: CI
22

33
on:
4-
push:
4+
push: { branches: [main] }
55
pull_request:
66
schedule: [cron: "40 1 * * *"]
77

@@ -12,54 +12,61 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
rust: [
15+
rust:
1616
# Test with toolchain file override
17-
"",
17+
- null
18+
1819
# Test that the sparse registry check works.
1920
# 1.66 and 1.67 don't support stable sparse registry.
20-
"1.66",
21-
"nightly",
22-
"beta",
23-
"stable",
24-
]
25-
os: [
26-
"ubuntu-latest",
27-
"windows-latest",
28-
"macos-latest",
29-
]
21+
- "1.66"
22+
23+
- "nightly"
24+
- "beta"
25+
- "stable"
26+
os:
27+
- ubuntu-latest
28+
- windows-latest
29+
- macos-latest
3030
steps:
3131
- uses: actions/checkout@v4
32+
3233
# Test toolchain file support
3334
- name: Write rust-toolchain.toml
35+
if: matrix.rust == null
36+
shell: bash
3437
run: |
3538
cat <<EOF >>rust-toolchain.toml
3639
[toolchain]
37-
channel = "nightly-2022-09-10"
40+
channel = "nightly-2024-01-11"
3841
components = [ "rustfmt", "rustc-dev" ]
3942
targets = [ "wasm32-unknown-unknown", "thumbv7m-none-eabi" ]
4043
profile = "minimal"
4144
EOF
42-
shell: bash
43-
if: matrix.rust == ''
4445
45-
- uses: ./
46+
- id: toolchain
4647
name: Run actions-rust-lang/setup-rust-toolchain ${{matrix.rust || 'on toolchain file'}}
47-
id: toolchain
48+
uses: ./
4849
with:
4950
toolchain: ${{matrix.rust}}
5051
components: clippy
52+
5153
- name: Check ${{'${{steps.toolchain.outputs.rustc-version}}'}}
5254
run: echo '${{steps.toolchain.outputs.rustc-version}}'
55+
5356
- name: Check ${{'${{steps.toolchain.outputs.cargo-version}}'}}
5457
run: echo '${{steps.toolchain.outputs.cargo-version}}'
58+
5559
- name: Check ${{'${{steps.toolchain.outputs.rustup-version}}'}}
5660
run: echo '${{steps.toolchain.outputs.rustup-version}}'
57-
- run: rustc --version && cargo --version
58-
shell: bash
61+
62+
- shell: bash
63+
run: rustc --version && cargo --version
5964

6065
# Test with creating a small project
6166
- run: cargo init . --bin --name ci
67+
6268
# Add tiny empty crate.
6369
# This checks that registry access works.
6470
- run: cargo add serde_as
71+
6572
- run: cargo clippy

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
* Allow overriding the toolchain file with explicit `toolchain` input. (#26)
11+
1012
## [1.6.0] - 2023-12-04
1113

1214
### Added

action.yml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,21 @@ runs:
5959
shell: bash
6060

6161
- id: flags
62+
env:
63+
targets: ${{inputs.target}}
64+
components: ${{inputs.components}}
65+
shell: bash
6266
run: |
6367
: construct rustup command line
6468
echo "targets=$(for t in ${targets//,/ }; do echo -n ' --target' $t; done)" >> $GITHUB_OUTPUT
6569
echo "components=$(for c in ${components//,/ }; do echo -n ' --component' $c; done)" >> $GITHUB_OUTPUT
6670
echo "downgrade=${{inputs.toolchain == 'nightly' && inputs.components && ' --allow-downgrade' || ''}}" >> $GITHUB_OUTPUT
71+
72+
# The environment variables always need to be set before the caching action
73+
- name: Setting Environment Variables
6774
env:
68-
targets: ${{inputs.target}}
69-
components: ${{inputs.components}}
75+
NEW_RUSTFLAGS: ${{inputs.rustflags}}
7076
shell: bash
71-
# The environment variables always need to be set before the caching action
72-
- name: "Setting Environment Variables"
7377
run: |
7478
if [[ ! -v CARGO_INCREMENTAL ]]; then
7579
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
@@ -95,23 +99,27 @@ runs:
9599
if [[ ! -v CARGO_REGISTRIES_CRATES_IO_PROTOCOL ]]; then
96100
echo "CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse" >> $GITHUB_ENV
97101
fi
98-
shell: bash
99-
env:
100-
NEW_RUSTFLAGS: ${{inputs.rustflags}}
101-
- name: "Install Rust Problem Matcher"
102+
103+
- name: Install Rust Problem Matcher
102104
if: inputs.matcher == 'true'
103-
run: echo "::add-matcher::${{ github.action_path }}/rust.json"
104105
shell: bash
106+
run: echo "::add-matcher::${{ github.action_path }}/rust.json"
105107

106108
- name: Install rustup, if needed
109+
if: runner.os != 'Windows'
110+
shell: bash
107111
run: |
108112
if ! command -v rustup &> /dev/null ; then
109113
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
110114
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
111115
fi
112-
if: runner.os != 'Windows'
113-
shell: bash
116+
114117
- name: rustup toolchain install ${{inputs.toolchain || 'stable'}}
118+
env:
119+
toolchain: ${{inputs.toolchain}}
120+
targets: ${{inputs.target}}
121+
components: ${{inputs.components}}
122+
shell: bash
115123
run: |
116124
if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]]
117125
then
@@ -132,14 +140,10 @@ runs:
132140
rustup toolchain install $toolchain${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
133141
rustup default $toolchain
134142
fi
135-
env:
136-
toolchain: ${{inputs.toolchain}}
137-
targets: ${{inputs.target}}
138-
components: ${{inputs.components}}
139-
shell: bash
140143
141-
- name: Print installed versions
142-
id: versions
144+
- id: versions
145+
name: Print installed versions
146+
shell: bash
143147
run: |
144148
echo "rustc-version=$(rustc --version)" >> $GITHUB_OUTPUT
145149
rustc --version --verbose
@@ -151,9 +155,9 @@ runs:
151155
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')
152156
HASH=$(rustc --version --verbose | sed -ne 's/^commit-hash: //p')
153157
echo "cachekey=$(echo $DATE$HASH | head -c12)" >> $GITHUB_OUTPUT
154-
shell: bash
155158
156-
- name: "Downgrade registry access protocol when needed"
159+
- name: Downgrade registry access protocol when needed
160+
shell: bash
157161
run: |
158162
# Not all versions support setting CARGO_REGISTRIES_CRATES_IO_PROTOCOL
159163
# On versions 1.66, 1.67, and 1.68.0-nightly the value "sparse" is still unstable.
@@ -163,8 +167,7 @@ runs:
163167
echo "Downgrade cargo registry protocol to git"
164168
echo "CARGO_REGISTRIES_CRATES_IO_PROTOCOL=git" >> $GITHUB_ENV
165169
fi
166-
shell: bash
167170
168-
- name: "Setup Rust Caching"
171+
- name: Setup Rust Caching
169172
if: inputs.cache == 'true'
170173
uses: Swatinem/rust-cache@v2

0 commit comments

Comments
 (0)