-
Notifications
You must be signed in to change notification settings - Fork 2
353 lines (313 loc) · 12.1 KB
/
full.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
on:
push:
pull_request:
schedule:
# New nightlies are usually out ~25 mins after midnight, UTC
# i.e.: https://static.rust-lang.org/dist/2020-06-06/
# (we'll wait 40 mins to be safe)
- cron: '40 0 * * *'
name: full
jobs:
check:
name: Check + test
strategy:
fail-fast: false
matrix:
rust:
- stable
# - beta
- nightly
- 1.43.0
target:
- x86_64-unknown-linux-gnu
- wasm32-unknown-unknown
# - wasm32-wasi
features:
- "''"
# - "ext"
# - "crossterm-support"
- "ext,crossterm-support"
cargo-cache-ver: ["0.4.3"]
cargo-sweep-ver: ["0.5.0"]
rust-latest-ver: ["1.4.0"]
# TODO: move ^ these three to an env block on the install step?
# Note: remember to update these below as well when making changes!
continue-on-error: ${{ matrix.rust == 'nightly' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Cache the binaries
id: bin-cache
uses: actions/cache@v2
with:
path: |
~/.cargo/bin
~/.cargo/.crates2.json
~/.cargo/.crates.toml
key: ${{ matrix.cargo-cache-ver }}-${{ matrix.cargo-sweep-ver }}-${{ matrix.rust-latest-ver }}-cargo-bins
# We don't bother using actions-rs/install for this because:
# - we want to be able to install cargo-cache with specific features
# which actions-rs/install doesn't support
# - cache-cache with `--features ci-autoclean` is designed to install
# fast anyways
# - the cache should pick up the installation of these tools
# - this happens infrequently so it doesn't even really matter
#
# Note that these are always installed with the version of Rust that's on the
# GitHub Ubuntu runners by default (usually the current stable version). Ideally
# we'd use the version of Rust we're using for the job but we can't because we
# need rust-latest to figure out if we can use the caches to get the version of
# Rust we're using for the job (a circle).
- name: Install cargo-cache and cargo-sweep and rust-latest
# The versions here are intentionally pinned.
# When changing versions, remember to change them below, too.
if: steps.bin-cache.outputs.cache-hit != 'true'
run: |
cargo install cargo-cache \
--vers =${{ matrix.cargo-cache-ver }} \
--no-default-features \
--features ci-autoclean
cargo install cargo-sweep \
--vers =${{ matrix.cargo-sweep-ver }}
cargo install rust-latest \
--vers =${{ matrix.rust-latest-ver }}
- name: Get feature and toolchain key
id: keys
run: |
echo "::set-output name=features::$(echo '${{ matrix.features }}' | sed 's/,/+/g')"
echo "::set-output name=toolchain::$(rust-latest -c '${{ matrix.rust }}')"
# The split between the 'toolchain' and 'build artifact' caches has gotten
# pretty weird; it's really should be called "all the things we can cache
# without calculating the lock file" and "everything else".
#
# It really makes more sense for the registry and the ~/.cargo/git to be
# part of the build artifact cache (since, what actually gets put in those
# folders will vary with the deps), but this isn't too bad. Most toolchain
# versions (with the exception of the MSRV) will vary fast enough that
# the registry doesn't become too stale. And for the MSRV, hopefully its
# caches will get pushed out frequently enough (caches are LIFOed on date
# created, iiuc) that this isn't a problem.
- name: Cache the toolchain
id: toolchain-cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cache/.wasm-pack
# Update: we're going to skip caching the toolchain for now; the cache is
# frequently slower than just grabbing the toolchain from rlo/dist
# /usr/share/rust/.rustup
# ^ == ~/.rustup; this action doesn't resolve the symlink
key: ${{ steps.keys.outputs.toolchain }}-${{ matrix.target }}-${{ steps.keys.outputs.features }}-toolchain
# - name: Set default toolchain
# if: steps.toolchain-cache.outputs.cache-hit == 'true'
# run: |
# rustup default ${{ matrix.rust }}
- uses: actions-rs/toolchain@v1
# if: steps.toolchain-cache.outputs.cache-hit != 'true'
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: update
- name: Cache the build artifacts
uses: actions/cache@v2
with:
path: target
key: ${{ steps.keys.outputs.toolchain }}-${{ matrix.target }}-${{ steps.keys.outputs.features }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ steps.keys.outputs.toolchain }}-${{ matrix.target }}-${{ steps.keys.outputs.features }}-cargo-
# ^ means we don't have to start from scratch when the deps change
- name: Mark all files for cargo-sweep
run: cargo-sweep sweep -s
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: >-
--target ${{ matrix.target }}
--all-targets
--no-default-features
--features ${{ matrix.features }}
- name: Run cargo check release
uses: actions-rs/cargo@v1
with:
command: check
args: >-
--target ${{ matrix.target }}
--all-targets
--no-default-features
--features ${{ matrix.features }}
--release
# Run the non-wasm tests:
- name: Run cargo test
if: matrix.target == 'x86_64-unknown-linux-gnu'
uses: actions-rs/cargo@v1
with:
command: test
args: >-
--target ${{ matrix.target }}
--no-default-features
--features ${{ matrix.features }}
--no-fail-fast
# Run the non-wasm tests:
- name: Run cargo test release
if: matrix.target == 'x86_64-unknown-linux-gnu'
uses: actions-rs/cargo@v1
with:
command: test
args: >-
--target ${{ matrix.target }}
--no-default-features
--features ${{ matrix.features }}
--no-fail-fast
--release
# Run the wasm tests only on 'wasm32-unknown-unknown'
- name: Install wasm-pack to run wasm tests
if: matrix.target == 'wasm32-unknown-unknown'
uses: jetli/[email protected]
with:
version: 'latest'
# Run the wasm tests only on 'wasm32-unknown-unknown'
- name: Run cargo test (wasm)
if: matrix.target == 'wasm32-unknown-unknown'
run: >-
wasm-pack
test
--node
--
--no-default-features
--features ${{ matrix.features }}
--no-fail-fast
# Run wasm tests only on 'wasm32-unknown-unknown'
- name: Run cargo test release (wasm)
if: matrix.target == 'wasm32-unknown-unknown'
run: >-
wasm-pack
test
--node
--release
--
--no-default-features
--features ${{ matrix.features }}
--no-fail-fast
- name: Clean up the target folder and cargo's caches
# Since we're using the CI version of cargo-cache there aren't any
# options, which is fine.
run: |
cargo-cache
cargo-sweep sweep -f
lint:
name: Format + run clippy
strategy:
fail-fast: false
matrix:
rust: [ stable, nightly ]
cargo-cache-ver: ["0.4.3"]
cargo-sweep-ver: ["0.5.0"]
rust-latest-ver: ["1.4.0"]
# Note: change these above as well.
continue-on-error: ${{ matrix.rust == 'nightly' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
# Caching is still beneficial for this task since `cargo clippy` basically
# runs `cargo check` which grabs deps and builds them.
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.rust }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ matrix.rust }}-cargo-clippy-
- name: Cache the binaries
id: bin-cache
uses: actions/cache@v2
with:
path: |
~/.cargo/bin
~/.cargo/.crates2.json
~/.cargo/.crates.toml
key: ${{ matrix.cargo-cache-ver }}-${{ matrix.cargo-sweep-ver }}-${{ matrix.rust-latest-ver }}-cargo-bins
- name: Install cargo-cache and cargo-sweep and rust-latest
if: steps.bin-cache.outputs.cache-hit != 'true'
run: |
cargo install cargo-cache --vers =${{ matrix.cargo-cache-ver }} \
--no-default-features --features ci-autoclean
cargo install cargo-sweep --vers =${{ matrix.cargo-sweep-ver }}
cargo install rust-latest --vers =${{ matrix.rust-latest-ver }}
- name: Get toolchain key
id: keys
run: |
echo "::set-output name=toolchain::$(rust-latest -c '${{ matrix.rust }}')"
- name: Cache the toolchain
id: toolchain-cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
# /usr/share/rust/.rustup
# Update: we're going to skip caching the toolchain for now; the cache is
# frequently slower than just grabbing the toolchain from rlo/dist
key: ${{ steps.keys.outputs.toolchain }}-${{ matrix.target }}-${{ steps.keys.outputs.features }}-toolchain
# - name: Set default toolchain
# if: steps.toolchain-cache.outputs.cache-hit == 'true'
# run: |
# rustup default ${{ matrix.rust }}
- uses: actions-rs/toolchain@v1
# if: steps.toolchain-cache.outputs.cache-hit != 'true'
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy
target: wasm32-wasi
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: update
- name: Cache the build artifacts
uses: actions/cache@v2
with:
path: target
key: ${{ steps.keys.outputs.toolchain }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ steps.keys.outputs.toolchain }}-cargo-clippy-
- name: Mark all files for cargo-sweep
run: cargo-sweep sweep -s
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
# We explicitly allow `renamed_and_removed_lints` on nightly since
# otherwise we're forced to support the old and renamed lints at the same
# time which is somewhat impossible.
- name: Clippy Extra Args (nightly)
if: ${{ matrix.rust == 'nightly' }}
id: args
run: |
echo "::set-output name=extra::-Arenamed_and_removed_lints"
# Since we don't run any builds in this task, we shouldn't need to run clean
# before (← is the workaround for rust-lang/rust-clippy#4612).
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all --all-targets --all-features -- -D warnings ${{ steps.args.outputs.extra }}
- name: Format and lint the examples
run: |
cd examples
cargo fmt --all -- --check
cargo clippy --all --target wasm32-wasi -- -D warnings ${{ steps.args.outputs.extra }}
- name: Clean up the target folder and cargo's caches
run: |
cargo-cache
cargo-sweep sweep -f