-
Notifications
You must be signed in to change notification settings - Fork 2
367 lines (323 loc) · 11.4 KB
/
Copy pathci-check-app.yml
File metadata and controls
367 lines (323 loc) · 11.4 KB
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
name: App - Check
on:
workflow_call:
inputs:
test-args:
description: 'The arguments to pass to the test command'
type: string
default: '--all-features --lib --bins'
test-suites:
description: 'Extra test suites to run'
type: string
default: ''
rust-toolchain:
description: 'The Rust version to use'
type: string
default: 'stable'
rust-toolchain-formatting:
description: 'The Rust version to use to check formatting'
type: string
default: 'stable'
rust-toolchain-udeps:
description: 'The Rust version to use to run udeps'
type: string
default: 'nightly'
check-udeps:
description: Enable checking for unusued dependencies
type: boolean
default: true
rust-backtrace:
description: 'The Rust backtrace settings'
type: string
default: 'full'
install-protoc:
description: 'Install protoc before running tests'
type: boolean
default: true
use-sccache:
description: 'Run sccache-cache before running tests'
type: boolean
default: true
use-postgresql:
description: 'Run postgresql before running tests'
type: boolean
default: false
test-env-vars:
description: 'The environment variables to set for the tests'
type: string
default: ''
run-label:
description: 'The run label to use for the actions'
type: string
default: 'ubuntu-latest'
rust-cache-prefix:
description: 'Prefix for Rust cache key (bump to invalidate all caches)'
type: string
default: 'v0-rust'
rust-cache-save:
description: 'Whether to save the Rust cache (set to false for PRs to only restore from main)'
type: boolean
default: true
env:
RUST_BACKTRACE: ${{ inputs.rust-backtrace }}
permissions:
contents: read
jobs:
clippy:
name: Clippy
runs-on: ${{ inputs.run-label }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
submodules: recursive
- name: Install Rust ${{ inputs.rust-toolchain }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.rust-toolchain }}
components: clippy
- name: Restore Cargo cache
id: cache-restore
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
~/.cargo/git/
target/
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-clippy-
- name: Clean target if Cargo.lock changed
if: steps.cache-restore.outputs.cache-hit != 'true'
run: rm -rf target/
- name: Install Protoc
if: ${{ inputs.install-protoc == true }}
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run sccache-cache
if: ${{ inputs.use-sccache == true }}
uses: mozilla-actions/sccache-action@v0.0.4
- name: Clippy
run: cargo clippy --workspace --all-features --all-targets -- -D warnings
- name: Save Cargo cache
if: ${{ inputs.rust-cache-save }}
uses: actions/cache/save@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
~/.cargo/git/
target/
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
formatting:
name: Formatting
runs-on: ${{ inputs.run-label }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
submodules: recursive
- name: Install Rust ${{ inputs.rust-toolchain-formatting }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.rust-toolchain-formatting }}
components: rustfmt
- name: Restore Cargo cache
id: cache-restore
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
~/.cargo/git/
target/
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-formatting-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-formatting-
- name: Clean target if Cargo.lock changed
if: steps.cache-restore.outputs.cache-hit != 'true'
run: rm -rf target/
- name: Run sccache-cache
if: ${{ inputs.use-sccache == true }}
uses: mozilla-actions/sccache-action@v0.0.4
- name: Check Formatting
run: cargo fmt -- --check
- name: Save Cargo cache
if: ${{ inputs.rust-cache-save }}
uses: actions/cache/save@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
~/.cargo/git/
target/
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-formatting-${{ hashFiles('**/Cargo.lock') }}
tests:
name: Unit Tests
runs-on: ${{ inputs.run-label }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
submodules: recursive
- name: Install Rust ${{ inputs.rust-toolchain }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.rust-toolchain }}
- name: Restore Cargo cache
id: cache-restore
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
~/.cargo/git/
target/
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-
- name: Clean target if Cargo.lock changed
if: steps.cache-restore.outputs.cache-hit != 'true'
run: rm -rf target/
- name: Install Protoc
if: ${{ inputs.install-protoc == true }}
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run sccache-cache
if: ${{ inputs.use-sccache == true }}
uses: mozilla-actions/sccache-action@v0.0.4
- name: Unit Tests
run: cargo test ${{ inputs.test-args }}
- name: Save Cargo cache
if: ${{ inputs.rust-cache-save }}
uses: actions/cache/save@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
~/.cargo/git/
target/
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-${{ hashFiles('**/Cargo.lock') }}
tests-suites:
name: Tests Suite "${{ matrix.element }}"
if: (inputs.test-suites != '') && (inputs.test-suites != '[]')
strategy:
fail-fast: false
matrix:
element: ${{ fromJson(inputs.test-suites) }}
runs-on: ${{ inputs.run-label }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
submodules: recursive
- name: Parse and export environment variables
run: |
echo '${{ inputs.test-env-vars }}' | jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" >> $GITHUB_ENV
- name: Run Postgresql
if: ${{ inputs.use-postgresql == true }}
uses: ikalnytskyi/action-setup-postgres@v5
- name: Install Rust ${{ inputs.rust-toolchain }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.rust-toolchain }}
- name: Restore Cargo cache
id: cache-restore
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
~/.cargo/git/
target/
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-suites-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-suites-
- name: Clean target if Cargo.lock changed
if: steps.cache-restore.outputs.cache-hit != 'true'
run: rm -rf target/
- name: Install Protoc
if: ${{ inputs.install-protoc == true }}
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run sccache-cache
if: ${{ inputs.use-sccache == true }}
uses: mozilla-actions/sccache-action@v0.0.4
- name: Test Suite
run: cargo test --test ${{ matrix.element }}
- name: Save Cargo cache
if: ${{ inputs.rust-cache-save }}
uses: actions/cache/save@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
~/.cargo/git/
target/
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-suites-${{ hashFiles('**/Cargo.lock') }}
unused-dependencies:
name: Unused Dependencies
runs-on: ${{ inputs.run-label }}
if: ${{ inputs.check-udeps }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
submodules: recursive
- name: Install Rust ${{ inputs.rust-toolchain-udeps }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.rust-toolchain-udeps }}
- name: Restore Cargo cache
id: cache-restore
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
~/.cargo/git/
target/
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-unused-deps-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-unused-deps-
- name: Clean target if Cargo.lock changed
if: steps.cache-restore.outputs.cache-hit != 'true'
run: rm -rf target/
- name: Run sccache-cache
if: ${{ inputs.use-sccache == true }}
uses: mozilla-actions/sccache-action@v0.0.4
- name: Install cargo-udeps
run: cargo install cargo-udeps@0.1.43 --locked
- name: Check Dependencies
run: cargo udeps --all-targets
- name: Save Cargo cache
if: ${{ inputs.rust-cache-save }}
uses: actions/cache/save@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
~/.cargo/git/
target/
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-unused-deps-${{ hashFiles('**/Cargo.lock') }}
license:
name: Licenses
runs-on: ${{ inputs.run-label }}
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
submodules: recursive
- uses: EmbarkStudios/cargo-deny-action@v2
with:
rust-version: ${{ inputs.rust-toolchain }}
command: check license