-
-
Notifications
You must be signed in to change notification settings - Fork 25
253 lines (241 loc) · 7.31 KB
/
ci.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
on:
pull_request:
workflow_dispatch:
push:
branches: ["main"]
env:
# disable incremental compilation.
#
# incremental compilation is useful as part of an edit-build-test-edit cycle,
# as it lets the compiler avoid recompiling code that hasn't changed. however,
# on CI, we're not making small edits; we're almost always building the entire
# project from scratch. thus, incremental compilation on CI actually
# introduces *additional* overhead to support making future builds
# faster...but no future builds will ever occur in any given CI environment.
#
# see https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
# for details.
CARGO_INCREMENTAL: 0
# allow more retries for network requests in cargo (downloading crates) and
# rustup (installing toolchains). this should help to reduce flaky CI failures
# from transient network timeouts or other issues.
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
# don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short
RUSTFLAGS: -Dwarnings
msrv: 1.57.0
LOOM_LOG: 'thingbuf=trace,debug'
name: CI
jobs:
changed_paths:
continue-on-error: true
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
do_not_skip: '["workflow_dispatch", "push"]'
paths: '["**/*.rs", "**/Cargo.toml", ".github/workflows/ci.yml"]'
build_no_std:
name: Check no_std
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
strategy:
matrix:
feature: [alloc, static]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: check
args: --no-default-features --features ${{ matrix.feature }}
tests:
name: Tests
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
strategy:
matrix:
# test all Rust versions on Ubuntu
rust: [stable, 1.57.0]
os: [ubuntu-latest]
# test stable Rust on Windows and MacOS as well
include:
- rust: stable
os: windows-latest
- rust: stable
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt
- name: Run cargo test (with static APIs)
if: ${{ matrix.rust != env.msrv }}
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
- name: Run cargo test (no static APIs)
if: ${{ matrix.rust == env.msrv }}
uses: actions-rs/cargo@v1
with:
command: test
# skip doctests, which require all features to be enabled
args: --lib --tests
benches:
name: Compile benchmarks
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: -p bench --benches
rustfmt:
runs-on: ubuntu-latest
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
steps:
- uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy_check:
name: Clippy check
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
override: true
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Run particularly slow loom models individually
slow_models:
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
strategy:
matrix:
model:
- mpsc_send_recv_wrap
- mpsc_try_send_recv
- mpsc_try_recv_ref
- mpsc_test_skip_slot
- mpsc_async::rx_close_unconsumed
- mpsc_blocking::rx_close_unconsumed
name: model '${{ matrix.model }}''
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Run model
run: cargo test --profile loom --lib -- ${{ matrix.model }}
env:
# it would be nice to run these with more preemptions, but
# that makes these models super slow...and LOOM_MAX_PREEMPTIONS=1 is
# good enough for Tokio's CI, so...
LOOM_MAX_PREEMPTIONS: 1
RUSTFLAGS: "--cfg loom"
# Run other loom models by scope
models:
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
strategy:
matrix:
scope:
# NOTE: if adding loom models in a new module, that module needs to be
# added to this list!
- mpsc_blocking
- mpsc_async
- thingbuf
- util
name: models in '${{ matrix.scope }}'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Run models
run: cargo test --profile loom --lib -- ${{ matrix.scope }}
env:
LOOM_MAX_PREEMPTIONS: 2
# `--cfg ci_skip_slow_models` will exclude the loom models that are
# tested in `slow-models`.
RUSTFLAGS: "--cfg loom --cfg ci_skip_slow_models"
# Dummy job that requires all loom models to pass
all_models:
name: all loom models
runs-on: ubuntu-latest
needs:
- slow_models
- models
steps:
- run: exit 0
miri:
name: Miri tests
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: miri
- name: Run Miri tests
run: cargo miri test --lib --no-fail-fast
env:
MIRIFLAGS: -Zmiri-disable-isolation