278 lines (241 loc) · 7.78 KB
/
build.yaml
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
name: Build
on: [push, pull_request]
jobs:
check-other-targets:
name: Type checking
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.32.0, 1.36.0, stable]
target:
- { triple: x86_64-unknown-netbsd, std: true }
- { triple: wasm32-wasi, std: true }
- { triple: thumbv7em-none-eabihf, std: false }
exclude:
- # alloc was not stable in 1.32
rust: 1.32.0
target: { triple: thumbv7em-none-eabihf, std: false }
- # WASI target did not exist at the time
rust: 1.32.0
target: { triple: wasm32-wasi, std: true }
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target.triple }}
override: true
- name: Install cargo-hack
shell: bash
run: |
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin
- name: Cache cargo output
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ matrix.target.triple }}-${{ hashFiles('**/Cargo.toml') }}
- name: Check feature powerset
uses: actions-rs/cargo@v1
with:
command: hack
args: |
check
--no-dev-deps
--feature-powerset
--optional-deps
--exclude-features default,libc,winapi,stdweb,std
--target ${{ matrix.target.triple }}
if: matrix.target.std == false
- name: Check feature powerset
uses: actions-rs/cargo@v1
with:
command: hack
args: |
check
--no-dev-deps
--feature-powerset
--optional-deps
--exclude-features default,libc,winapi,stdweb --features std
--target ${{ matrix.target.triple }}
if: matrix.rust == '1.32.0' && matrix.target.std == true
- name: Check feature powerset
uses: actions-rs/cargo@v1
with:
command: hack
args: |
check
--no-dev-deps
--feature-powerset
--optional-deps
--exclude-features default,libc,winapi,stdweb
--target ${{ matrix.target.triple }}
if: matrix.rust != '1.32.0' && matrix.target.std == true
check-web:
name: Type checking (web)
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.36.0, stable]
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Cache installed binaries
uses: actions/cache@v2
id: cache
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-web
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: wasm32-unknown-unknown
override: true
- name: Install cargo-web
run: cargo +stable install cargo-web
if: steps.cache.outputs.cache-hit != 'true'
- name: Cache cargo output
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-wasm32-unknown-unknown-${{ hashFiles('**/Cargo.toml') }}
# cargo-web is unable to handle the command generated by cargo-hack.
- name: "Check #![no_std] compatibility"
uses: actions-rs/cargo@v1
with:
command: web
args: check --no-default-features
- name: "Check #![no_std] compatibility with serde, rand"
uses: actions-rs/cargo@v1
with:
command: web
args: check --no-default-features --features serde,rand
- name: Check all-features
uses: actions-rs/cargo@v1
with:
command: web
args: check --all-features
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: [1.32.0, 1.36.0, stable] # 1.36 is when alloc was stabilized
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Install cargo-hack
shell: bash
run: |
host=$(rustc -Vv | grep host | sed 's/host: //')
if [[ $host =~ windows ]]; then
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-${host}.zip -o cargo-hack.zip
7z x cargo-hack.zip -o$HOME/.cargo/bin
elif [[ $host =~ darwin|linux ]]; then
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-${host}.tar.gz | tar xzf - -C ~/.cargo/bin
else
echo "unsupported operating system"
exit 1
fi
# This is a workaround for a known bug in GitHub Actions. See
# actions/cache#403 and rust-lang/cargo#8603 for details.
- name: Install GNU tar
run: |
brew install gnu-tar
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
if: matrix.os == 'macOS-latest'
- name: Cache cargo output
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ matrix.os }}-${{ hashFiles('**/Cargo.toml') }}2
- name: Test feature powerset (--tests)
uses: actions-rs/cargo@v1
with:
command: hack
args: |
test
--feature-powerset
--optional-deps
--exclude-features default,libc,winapi,stdweb --features std
--tests
if: matrix.rust == '1.32.0'
- name: Test feature powerset (--tests)
uses: actions-rs/cargo@v1
with:
command: hack
args: |
test
--feature-powerset
--optional-deps
--exclude-features default,libc,winapi,stdweb
--tests
if: matrix.rust != '1.32.0'
- name: Test documentation
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --doc
fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- name: Run `cargo fmt -- --check`
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Cache cargo output
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ubuntu-latest-cargo-stable-ubuntu-latest-${{ hashFiles('**/Cargo.toml') }}
- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features