-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·259 lines (228 loc) · 9.18 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
on:
push:
pull_request:
name: full
jobs:
check:
name: Check
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
rust:
- stable
cargo-cache-ver: ["0.4.3"]
cargo-sweep-ver: ["0.5.0"]
rust-latest-ver: ["1.4.0"]
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
# 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 }}')"
echo "TOOLCHAIN=$(rust-latest -c '${{ matrix.rust }}')" >> $GITHUB_ENV
# 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
# ~/.cache/.wasm-pack # {{{ for wasm }}}
# 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 }}-${{ matrix.target }}-${{ steps.keys.outputs.features }}-toolchain
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Update Cargo.lock
uses: actions-rs/cargo@v1
with:
command: update
- name: Cache the build artifacts
if: matrix.os != 'windows-latest'
uses: actions/cache@v2
with:
path: target
key: ${{ steps.keys.outputs.toolchain }}-${{ matrix.os }}-${{ matrix.target }}-${{ steps.keys.outputs.features }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ steps.keys.outputs.toolchain }}-${{ matrix.os }}-${{ 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
if: matrix.os != 'windows-latest'
run: cargo-sweep sweep -s
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: >-
--all-features
- name: Run cargo check release
uses: actions-rs/cargo@v1
with:
command: check
args: >-
--all-features
--release
- 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
# Workaround for actions/cache#403 (https://github.com/actions/cache/issues/403)
#
# rust-lang/cargo#8603 has the exact bug that we run into
# (https://github.com/rust-lang/cargo/issues/8603)
- name: Flush the disk cache for macOS
if: matrix.os == 'macos-latest'
run: sudo /usr/sbin/purge
lint:
name: Format + run clippy
strategy:
fail-fast: false
matrix:
rust: [stable]
cargo-cache-ver: ["0.4.3"]
cargo-sweep-ver: ["0.5.0"]
rust-latest-ver: ["1.4.0"]
# Note: change these above as well.
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
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy
- name: Update 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-targets --all-features -- -D warnings
- name: Clean up the target folder and cargo's caches
run: |
cargo-cache
cargo-sweep sweep -f