-
Notifications
You must be signed in to change notification settings - Fork 55
332 lines (274 loc) · 9.31 KB
/
pull-request-checks.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
name: Pull Request Checks
on:
workflow_dispatch:
pull_request:
merge_group:
env:
CARGO_TERM_COLOR: always
jobs:
block-fixup:
name: Block fixup commits
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Block Fixup Commit Merge
# https://github.com/13rac1/block-fixup-merge-action
uses: 13rac1/[email protected]
# JOB to run change detection
changes:
name: Filter changes
runs-on: ubuntu-20.04
# Set job outputs to values from filter step
outputs:
rust: ${{ steps.filter.outputs.rust || 'true' }}
workflows: ${{ steps.filter.outputs.workflows || 'true' }}
docs: ${{ steps.filter.outputs.docs || 'true' }}
continue-on-error: true
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
if: ${{ github.event_name == 'pull_request' }}
# https://github.com/dorny/paths-filter
id: filter
with:
filters: |
rust:
- 'crates/**'
- 'plugins/**'
- 'Cargo.*'
workflows:
- '.github/workflows/**'
docs:
- 'docs/**'
#
# Checking that Cargo.lock is up to date
#
check-lockfile-uptodate:
name: Check whether Cargo.lock is up to date
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'pull_request' }}
outputs:
locks: ${{ steps.filter.outputs.locks }}
steps:
- uses: actions/checkout@v4
- name: Retrieve MSRV from workspace Cargo.toml
id: rust_version
uses: SebRollen/[email protected]
with:
file: Cargo.toml
field: "workspace.package.rust-version"
- name: Enable toolchain via github action
uses: dtolnay/rust-toolchain@master
with:
targets: armv7-unknown-linux-gnueabihf
toolchain: ${{ steps.rust_version.outputs.value }}
- uses: Swatinem/rust-cache@v2
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
locks:
- '**/Cargo.toml'
- name: Check whether lockfile is up to date
if: steps.filter.outputs.locks == 'true'
run: cargo check --locked
udeps:
name: Check for unused dependencies
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- uses: actions/checkout@v4
# TODO: remove nightly pin when we can update ahash (#2686)
- name: Install nightly
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-02-03
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Run cargo-udeps
run: |
cargo install --git https://github.com/est31/cargo-udeps --locked
cargo udeps --all-features --all-targets
dependency-sort:
name: Sort dependencies
runs-on: ubuntu-20.04
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: Install taplo
run: cargo install taplo-cli
- name: Check Cargo.toml formatting
run: taplo fmt --check
cargo-fmt:
name: Run cargo fmt
runs-on: ubuntu-20.04
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Nightly toolchain is needed for cargo fmt since issue: https://github.com/thin-edge/thin-edge.io/issues/1660
# dtolnay/rust-toolchain is preferred over actions-rs/toolchain is currently not maintained and currently using
# deprecated GHA api (see https://github.com/actions-rs/toolchain/issues/219).
# However since dtolnay/rust-toolchain does not support the 'override' option, an additional call to
# rustup override is required (see https://github.com/dtolnay/rust-toolchain/issues/29#issuecomment-1412903426)
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Cargo fmt --version
run: cargo fmt --version
- name: Cargo fmt
run: cargo fmt -- --check
cargo-clippy:
name: Run cargo clippy
runs-on: ubuntu-20.04
env:
RUSTFLAGS: -D warnings
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Enable cache
# https://github.com/marketplace/actions/rust-cache
uses: Swatinem/rust-cache@v2
- name: Cargo clippy
run: |
cargo clippy --version
cargo clippy --all-targets --all-features
cargo-audit:
name: Run cargo audit
runs-on: ubuntu-20.04
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: Cargo audit
run: cargo audit
# Only run check if the project still compiles on MSRV, test are run on stable
check-msrv:
name: Run cargo check on MSRV
runs-on: ubuntu-20.04
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Retrieve MSRV from workspace Cargo.toml
id: rust_version
uses: SebRollen/[email protected]
with:
file: Cargo.toml
field: "workspace.package.rust-version"
- name: Enable rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust_version.outputs.value }}
- name: Enable cache
uses: Swatinem/rust-cache@v2
- name: Run `cargo check`
run: cargo check --all-targets --all-features
cargo-test:
name: Run cargo test
runs-on: ubuntu-20.04
env:
RUSTFLAGS: -D warnings
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- name: Check disk space before setting up
run: df -BM
- name: Reclaim some disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf /opt/hostedtoolcache
- name: Check disk space after freeing
run: df -BM
- name: Checkout
uses: actions/checkout@v4
- name: Retrieve MSRV from workspace Cargo.toml
id: rust_version
uses: SebRollen/[email protected]
with:
file: Cargo.toml
field: "workspace.package.rust-version"
- name: Enable toolchain via github action
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Enable cache
uses: Swatinem/rust-cache@v2
- name: cargo install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: cargo llvm-cov
run: cargo llvm-cov --no-fail-fast --locked --all-features --all-targets --codecov --output-path codecov.json
# https://github.com/rust-lang/cargo/issues/6669
- name: cargo test --doc
run: cargo test --locked --all-features --doc
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
- name: Check disk space after completing workflow
run: df -BM
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
typos:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/[email protected]
continue-on-error: true
- run: exit 0
doc:
runs-on: ubuntu-latest
name: nightly / doc
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.workflows == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Enable cache
uses: Swatinem/rust-cache@v2
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: cargo doc
run: cargo doc --no-deps --all-features --workspace
markdown:
# Validate that the markdown is correct before merging as errors will cause
# the publishing of the docs to github pages to fail
runs-on: ubuntu-latest
name: Check markdown
needs: changes
if: ${{ needs.changes.outputs.docs == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
# use tedge-docs nodejs version for guidance, though it is not mandatory
# https://github.com/thin-edge/tedge-docs
node-version: '>=18.0'
- run: npx docusaurus-mdx-checker
working-directory: docs