-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
189 lines (162 loc) · 7.17 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: rustup toolchain install
author: wackbyte
description: Install a Rust toolchain
branding:
icon: settings
color: red
inputs:
toolchain:
description: |
rustup toolchain name.
It is recommended to use quotes in order to avoid versions being parsed as floating-point numbers.
Example values:
- `stable`
- `nightly`
- `1.42.0`
- `nightly-2022-01-01`
See the documentation: https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification
required: true
targets:
description: |
Comma-separated list of target triples to be additionally installed for this toolchain.
Example value: `wasm32-unknown-unknown`
See the documentation: https://doc.rust-lang.org/rustc/platform-support.html
required: false
components:
description: |
Comma-separated list of components to be additionally installed for this toolchain.
Example value: `clippy, rustfmt`
See the documentation: https://rust-lang.github.io/rustup/concepts/components.html
required: false
profile:
description: |
Group of components to install for this toolchain.
It is recommended to use `minimal` in CI so that the minimum number of components is installed.
Available values:
- `minimal`
- `default`
- `complete`
See the documentation: https://rust-lang.github.io/rustup/concepts/profiles.html
required: false
default: minimal
default:
description: |
Set this toolchain as default.
Equivalent to running `rustup default` with this toolchain.
See the documentation: https://rust-lang.github.io/rustup/overrides.html#default-toolchain
required: false
default: false
override:
description: |
Set this toolchain as an override for this directory.
Equivalent to running `rustup override set` with this toolchain.
This is helpful if a `rustup-toolchain.toml` or `rustup-toolchain` file is present in the directory and you would like to use this toolchain instead.
See the documentation: https://rust-lang.github.io/rustup/overrides.html
required: false
default: false
outputs:
cachekey:
description: |
A short hash of the installed rustc version.
Appropriate for use as a cache key.
Example value: `20220627a831`
value: ${{steps.rustc-version.outputs.cachekey}}
name:
description: |
rustup's name for the selected version of the toolchain.
Suitable for use with the `cargo +toolchain` shorthand.
Example value: `1.62.0`
value: ${{steps.parse.outputs.toolchain}}
runs:
using: composite
steps:
- id: parse
run: |
: parse toolchain version
if [[ $toolchain =~ ^stable' '[0-9]+' '(year|month|week|day)s?' 'ago$ ]]; then
if [[ ${{runner.os}} == macOS ]]; then
echo "toolchain=1.$((($(date -v-$(sed 's/stable \([0-9]*\) \(.\).*/\1\2/' <<< $toolchain) +%s)/60/60/24-16569)/7/6))" >> $GITHUB_OUTPUT
else
echo "toolchain=1.$((($(date --date "${toolchain#stable }" +%s)/60/60/24-16569)/7/6))" >> $GITHUB_OUTPUT
fi
elif [[ $toolchain =~ ^stable' 'minus' '[0-9]+' 'releases?$ ]]; then
echo "toolchain=1.$((($(date +%s)/60/60/24-16569)/7/6-${toolchain//[^0-9]/}))" >> $GITHUB_OUTPUT
else
echo "toolchain=$toolchain" >> $GITHUB_OUTPUT
fi
env:
toolchain: ${{inputs.toolchain}}
shell: bash
- id: flags
run: |
: construct rustup command line
echo "targets=$(for t in ${targets//,/ }; do echo -n ' --target' $t; done)" >> $GITHUB_OUTPUT
echo "components=$(for c in ${components//,/ }; do echo -n ' --component' $c; done)" >> $GITHUB_OUTPUT
echo "profile= --profile ${{inputs.profile}}" >> $GITHUB_OUTPUT
echo "downgrade=${{steps.parse.outputs.toolchain == 'nightly' && inputs.components && ' --allow-downgrade' || ''}}" >> $GITHUB_OUTPUT
env:
targets: ${{inputs.targets || ''}}
components: ${{inputs.components}}
shell: bash
- run: |
: set $CARGO_HOME
echo CARGO_HOME=${CARGO_HOME:-${{runner.os == 'Windows' && '$USERPROFILE' || '$HOME'}}/.cargo} >> $GITHUB_ENV
shell: bash
- run: |
: install rustup if needed
if ! command -v rustup &>/dev/null; then
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
echo "$CARGO_HOME/bin" >> $GITHUB_PATH
fi
if: runner.os != 'Windows'
shell: bash
- name: rustup toolchain install ${{steps.parse.outputs.toolchain}}
run: rustup toolchain install ${{steps.parse.outputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}}${{steps.flags.outputs.profile}}${{steps.flags.outputs.downgrade}} --no-self-update
shell: bash
- run: rustup default ${{steps.parse.outputs.toolchain}}
if: inputs.default
shell: bash
- run: rustup override set ${{steps.parse.outputs.toolchain}}
if: inputs.override
shell: bash
- id: rustc-version
run: |
: create cachekey
DATE=$(rustc +${{steps.parse.outputs.toolchain}} --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p')
HASH=$(rustc +${{steps.parse.outputs.toolchain}} --version --verbose | sed -ne 's/^commit-hash: //p')
echo "cachekey=$(echo $DATE$HASH | head -c12)" >> $GITHUB_OUTPUT
shell: bash
- run: |
: disable incremental compilation
if [ -z "${CARGO_INCREMENTAL+set}" ]; then
echo CARGO_INCREMENTAL=0 >> $GITHUB_ENV
fi
shell: bash
- run: |
: enable colors in Cargo output
if [ -z "${CARGO_TERM_COLOR+set}" ]; then
echo CARGO_TERM_COLOR=always >> $GITHUB_ENV
fi
shell: bash
- run: |
: enable Cargo sparse registry
# implemented in 1.66, stabilized in 1.68, made default in 1.70
if [ -z "${CARGO_REGISTRIES_CRATES_IO_PROTOCOL+set}" -o -f "${{runner.temp}}"/.implicit_cargo_registries_crates_io_protocol ]; then
if rustc +${{steps.parse.outputs.toolchain}} --version --verbose | grep -q '^release: 1\.6[89]\.'; then
touch "${{runner.temp}}"/.implicit_cargo_registries_crates_io_protocol || true
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse >> $GITHUB_ENV
elif rustc +${{steps.parse.outputs.toolchain}} --version --verbose | grep -q '^release: 1\.6[67]\.'; then
touch "${{runner.temp}}"/.implicit_cargo_registries_crates_io_protocol || true
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=git >> $GITHUB_ENV
fi
fi
shell: bash
- run: |
: work around spurious network errors in curl 8.0
# https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/timeout.20investigation
if rustc +${{steps.parse.outputs.toolchain}} --version --verbose | grep -q '^release: 1\.7[01]\.'; then
echo CARGO_HTTP_MULTIPLEXING=false >> $GITHUB_ENV
fi
shell: bash
- run: rustc +${{steps.parse.outputs.toolchain}} --version --verbose
shell: bash