-
Notifications
You must be signed in to change notification settings - Fork 16
285 lines (218 loc) · 8.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
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
name: CI
on:
push:
pull_request:
# smoelius: Every Thursday at 3:00 UTC (Wednesday at 22:00 EST), run `cargo test -- --ignored`.
schedule:
- cron: "0 3 * * 4"
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v3
- name: Dylint versions
run: cargo search dylint | sort | tee dylint_versions
# smoelius: The `~/.cargo/` entries are from:
# * https://github.com/actions/cache/blob/main/examples.md#rust---cargo.
# * https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
# The rest were added by me.
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.dylint_drivers/
~/.rustup/toolchains/
target/dylint/
key: ${{ runner.os }}-dylint-${{ hashFiles('dylint_versions') }}
- name: Rustup
run: rustup update
- name: Install llvm
run: sudo apt-get install llvm
- name: Actionlint
run: go install github.com/rhysd/actionlint/cmd/actionlint@latest && "$HOME"/go/bin/actionlint --shellcheck='-e SC2016'
- name: Shellcheck
run: shellcheck --exclude=SC2002 scripts/*
- name: Prettier
run: npm install -g prettier && prettier --check '**/*.json' '**/*.md' '**/*.yml'
- name: Markdown link check
run: npm install -g markdown-link-check && markdown-link-check ./**/*.md
# https://github.com/DevinR528/cargo-sort/issues/57#issuecomment-1457714872
- name: Cargo sort
run: |
cargo install cargo-sort || true
find . -name Cargo.toml -print0 | xargs -0 -n 1 dirname | xargs -n 1 cargo sort --check --grouped --no-format
- name: Format
run: cargo fmt && git diff --exit-code
- name: Format README
run: ./scripts/update_README.sh && git diff --exit-code
- name: License
run: |
cargo install cargo-license || true
./scripts/check_licenses.sh
- name: Clippy
run: |
rustup +nightly component add clippy
./scripts/clippy.sh
- name: Dylint
run: |
cargo install cargo-dylint dylint-link || true
./scripts/dylint.sh
- name: Udeps
run: |
cargo install cargo-udeps || true
cargo clean && cargo +nightly udeps --features=test-fuzz/auto_concretize --all-targets
test:
runs-on: ubuntu-latest
strategy:
matrix:
serde_format: [bincode, cbor, cbor4ii]
toolchain: [stable, nightly]
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v3
- name: Set toolchain
run: rustup default ${{ matrix.toolchain }}
- name: Install llvm
run: sudo apt-get install llvm
# smoelius: The Substrate tests require `protoc`.
- name: Install protoc
if: ${{ github.event_name == 'schedule' }}
run: sudo apt-get install protobuf-compiler
- name: Install afl
run: cargo install afl
# smoelius: The wasm32 target is needed for some Substrate tests, regardless of the toolchain
# used to build test-fuzz.
- name: Add wasm32 target
if: ${{ github.event_name == 'schedule' }}
run: |
rustup target add wasm32-unknown-unknown
rustup +nightly target add wasm32-unknown-unknown
- name: Test
run: |
AUTO_CONCRETIZE=
IGNORED=
SHUFFLE=
if [[ ${{ matrix.toolchain }} = nightly ]]; then
AUTO_CONCRETIZE='--features=test-fuzz/auto_concretize'
SHUFFLE='-Z unstable-options --shuffle --test-threads=1'
fi
if [[ ${{ github.event_name }} = schedule ]]; then
IGNORED='--ignored'
fi
cargo test --features=test-fuzz/serde_${{ matrix.serde_format }} "$AUTO_CONCRETIZE" -- --nocapture $IGNORED $SHUFFLE
env:
AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES: 1
RUST_BACKTRACE: 1
RUST_LOG: warn
test-uninstalled-cargo-afl:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: nightly
steps:
- uses: actions/checkout@v3
- name: Test
run: |
OUTPUT="$(cargo run -p cargo-test-fuzz -- test-fuzz -p test-fuzz-examples --no-run 2>&1 1>/dev/null || true)"
echo "$OUTPUT"
echo "$OUTPUT" | grep '^Error: Could not determine `cargo-afl` version. Is it installed? Try `cargo install afl`.$'
test-incompatible-cargo-afl:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: nightly
steps:
- uses: actions/checkout@v3
- name: Install llvm
run: sudo apt-get install llvm
- name: Install older afl
run: cargo install afl --version=0.11.0
- name: Test
run: |
OUTPUT="$(cargo run -p cargo-test-fuzz -- test-fuzz -p test-fuzz-examples --no-run 2>&1 1>/dev/null || true)"
echo "$OUTPUT"
echo "$OUTPUT" | grep '^Error: `[^`]*` depends on `afl [^`]*`, which is incompatible with `cargo-afl [^`]*`.$'
test-newer-afl:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: nightly
steps:
- uses: actions/checkout@v3
- name: Install llvm
run: sudo apt-get install llvm
- name: Install afl 0.12.1
run: cargo install afl --version=0.12.1
- name: Require afl 0.12.2
run: |
sed -i 's/afl = "[^"]*"/afl = "=0.12.2"/' test-fuzz/Cargo.toml
- name: Test
run: |
OUTPUT="$(cargo run -p cargo-test-fuzz -- test-fuzz -p test-fuzz-examples --no-run 2>&1 1>/dev/null || true)"
echo "$OUTPUT"
echo "$OUTPUT" | grep '^`[^`]*` depends on `afl [^`]*`, which is newer than `cargo-afl [^`]*`.'
echo "$OUTPUT" | grep 'Consider upgrading with `cargo install afl --force --version [^`]*`.$'
test-incompatible-test-fuzz:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: nightly
steps:
- uses: actions/checkout@v3
- name: Install llvm
run: sudo apt-get install llvm
- name: Install afl
run: cargo install afl
- name: Downgrade test-fuzz version
run: |
sed -i 's/^\(version = "\)[^.]*\.[^.]*\.\([^"]*"\)$/\10.0.\2/' test-fuzz/Cargo.toml
sed -i 's/^\(test-fuzz = {.*\<version = "=\)[^.]*\.[^.]*\.\([^"]*".*}\)$/\10.0.\2/' cargo-test-fuzz/Cargo.toml examples/Cargo.toml
- name: Test
run: |
OUTPUT="$(cargo run -p cargo-test-fuzz -- test-fuzz -p test-fuzz-examples --no-run 2>&1 1>/dev/null || true)"
echo "$OUTPUT"
echo "$OUTPUT" | grep '^Error: `[^`]*` depends on `test-fuzz [^`]*`, which is incompatible with `cargo-test-fuzz [^`]*`.$'
test-newer-test-fuzz:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: nightly
steps:
- uses: actions/checkout@v3
- name: Install llvm
run: sudo apt-get install llvm
- name: Install afl
run: cargo install afl
- name: Upgrade test-fuzz version
run: |
sed -i 's/^\(version = "[^.]*\.[^.]*\)\.[^"]*\("\)$/\1.255\2/' test-fuzz/Cargo.toml
sed -i 's/^\(test-fuzz = {.*\<version = "=[^.]*\.[^.]*\)\.[^"]*\(".*}\)$/\1.255\2/' cargo-test-fuzz/Cargo.toml examples/Cargo.toml
sed -i 's/^\(version = "[^-]*\)-[^"]*\("\)$/\1\2/' cargo-test-fuzz/Cargo.toml
- name: Test
run: |
OUTPUT="$(cargo run -p cargo-test-fuzz -- test-fuzz -p test-fuzz-examples --no-run 2>&1 1>/dev/null || true)"
echo "$OUTPUT"
echo "$OUTPUT" | grep '^`[^`]*` depends on `test-fuzz [^`]*`, which is newer than `cargo-test-fuzz [^`]*`.'
echo "$OUTPUT" | grep 'Consider upgrading with `cargo install cargo-test-fuzz --force --version [^`]*`.$'
all-checks:
needs:
- lint
- test
- test-uninstalled-cargo-afl
- test-incompatible-cargo-afl
- test-newer-afl
- test-incompatible-test-fuzz
- test-newer-test-fuzz
runs-on: ubuntu-latest
steps:
- run: true