-
Notifications
You must be signed in to change notification settings - Fork 0
356 lines (316 loc) · 12.4 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
354
355
356
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
os:
- ubuntu-latest
- macos-latest
- windows-latest
# - wasm32-unknown-unknown
# - wasm32-wasi
features: # NOTE: Update the set of features clippy uses when linting when adding features..
- "''"
- "frontend,grader"
cargo-cache-ver: ["0.4.3"]
cargo-sweep-ver: ["0.5.0"]
rust-latest-ver: ["1.4.0"]
# Note: remember to update these below as well when making changes!
include:
- os: ubuntu-latest
features: "generate-fresh"
rust: 1.43.0
anew: true
cargo-cache-ver: "0.4.3"
cargo-sweep-ver: "0.5.0"
rust-latest-ver: "1.4.0"
- os: ubuntu-latest
features: "generate-fresh"
rust: stable
anew: true
cargo-cache-ver: "0.4.3"
cargo-sweep-ver: "0.5.0"
rust-latest-ver: "1.4.0"
continue-on-error: ${{ matrix.rust == 'nightly' }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
- name: Cache the binaries
id: bin-cache
if: matrix.os != 'windows-latest'
uses: actions/cache@v2
with:
path: |
~/.cargo/bin
~/.cargo/.crates2.json
~/.cargo/.crates.toml
key: ${{ matrix.os }}-${{ matrix.cargo-cache-ver }}-${{ matrix.cargo-sweep-ver }}-${{ matrix.rust-latest-ver }}-cargo-bins-v0
# 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' && matrix.os != 'windows-latest'
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
if: matrix.os != 'windows-latest'
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
if: matrix.os != 'windows-latest'
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
# 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.os }}-${{ steps.keys.outputs.features }}-toolchain
- uses: actions-rs/toolchain@v1
with:
profile: minimal
components: rustfmt
toolchain: ${{ matrix.rust }}
override: true
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: update
- name: Cache the build artifacts
uses: actions/cache@v2
if: matrix.os != 'windows-latest'
with:
path: |
target
lto-target
key: ${{ steps.keys.outputs.toolchain }}-${{ matrix.os }}-${{ steps.keys.outputs.features }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ steps.keys.outputs.toolchain }}-${{ matrix.os }}-${{ 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
if: matrix.os != 'windows-latest'
run: cargo-sweep sweep -s
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: >-
--all-targets
--no-default-features
--features ${{ matrix.features }}
- name: Run cargo build release
uses: actions-rs/cargo@v1
with:
command: build
args: >-
--all-targets
--no-default-features
--features ${{ matrix.features }}
--release
# Run the non-wasm tests:
- name: Run cargo test
continue-on-error: true
uses: actions-rs/cargo@v1
with:
command: test
args: >-
--no-default-features
--features ${{ matrix.features }}
--no-fail-fast
# Run the non-wasm tests:
- name: Run cargo test release
continue-on-error: true
uses: actions-rs/cargo@v1
with:
command: test
args: >-
--no-default-features
--features ${{ matrix.features }}
--no-fail-fast
--release
- name: Run the example
uses: actions-rs/cargo@v1
with:
command: run
args: >-
--no-default-features
--features ${{ matrix.features }}
--example mul
- name: Run the example with LTO (in release mode)
# Not brave enough to try LTO on windows (also, don't want to deal with
# cmd's env vars)
#
# Nightly Rust's LLVM doesn't play nice with lld-9 which is what the CI machines
# seem to have (https://github.com/actions/virtual-environments/blob/73b1f4219b0d5d9c78a1deecba3a69e0c319f500/images/linux/scripts/installers/clang.sh#L40-L44):
# » ld.lld-9: error: Invalid summary version 8. Version should be in the range [1-7].
if: matrix.os != 'windows-latest' && matrix.rust != 'nightly'
run: |
clang --version || :
ld.lld-9 --version || :
c++ --version || :
export CC=clang
export CXX=clang++
# No ld.lld on macOS: http://lists.llvm.org/pipermail/cfe-dev/2019-March/061666.html
# Also see:
# - https://github.com/rust-lang/rust/issues/60059
# - https://bcain-llvm.readthedocs.io/projects/clang/en/latest/ThinLTO/#id10
test ${{ matrix.os }} == 'macos-latest' && \
export RUSTFLAGS="-Clinker=clang -Clink-arg=-Wl,-mllvm,-threads=$(sysctl -n hw.ncpu)" \
|| export RUSTFLAGS="-Clinker-plugin-lto -Clinker=clang -Clink-arg=-fuse-ld=lld-9"
cargo run \
--target-dir lto-target \
--no-default-features \
--features ${{ matrix.features }},lto \
--release \
--example mul
- name: Compare the bindings
if: matrix.anew
run: git diff generated/
- name: Clean up the target folder and cargo's caches
if: matrix.os != 'windows-latest'
# 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.os }}-${{ steps.keys.outputs.features }}-toolchain
- uses: actions-rs/toolchain@v1
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
# 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 --features grader,frontend -- -D warnings
- name: Clean up the target folder and cargo's caches
run: |
cargo-cache
cargo-sweep sweep -f