-
Notifications
You must be signed in to change notification settings - Fork 2
267 lines (237 loc) · 8.85 KB
/
Copy pathci-check-app.yml
File metadata and controls
267 lines (237 loc) · 8.85 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
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:
# DEPRECATED / no-op: sccache had no persistent backend configured here
# (its object store was never cached), so it provided no cross-run
# benefit and disabled incremental compilation, which fights the
# Swatinem/rust-cache target/ cache. The input is kept so existing
# callers (and ci.yml) don't break; it no longer wires anything.
description: '(deprecated, no-op) Run sccache-cache before running tests'
type: boolean
default: true
use-mold:
# Opt-in (default false): mold is a linker, so it only helps jobs that
# link a binary — i.e. tests / tests-suites, not clippy (check-only) or
# fmt (no compile). Keep this OFF for `cargo test --release` / LTO test
# builds: mold can't read ThinLTO bitcode objects without the LLVM
# plugin and the final link fails.
description: 'Use the mold linker (clang driver) for the test jobs. Only for non-LTO debug test builds.'
type: boolean
default: false
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: Rust cache
uses: Swatinem/rust-cache@23869a5bd66c73db3c0ac40331f3206eb23791dc # v2.9.1
with:
prefix-key: ${{ inputs.rust-cache-prefix }}
shared-key: clippy
save-if: ${{ inputs.rust-cache-save }}
- name: Install Protoc
if: ${{ inputs.install-protoc == true }}
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Clippy
run: cargo clippy --workspace --all-features --all-targets -- -D warnings
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
# `cargo fmt -- --check` does not compile anything, so there is no target/
# or dependency cache to restore here.
- name: Check Formatting
run: cargo fmt -- --check
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 }}
# Before the cache step so RUSTFLAGS is part of the Swatinem cache key.
- name: Set up mold linker
if: ${{ inputs.use-mold }}
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends mold clang
echo "RUSTFLAGS=${RUSTFLAGS:+$RUSTFLAGS }-C linker=clang -C link-arg=-fuse-ld=mold" >> "$GITHUB_ENV"
- name: Rust cache
uses: Swatinem/rust-cache@23869a5bd66c73db3c0ac40331f3206eb23791dc # v2.9.1
with:
prefix-key: ${{ inputs.rust-cache-prefix }}
shared-key: tests
save-if: ${{ inputs.rust-cache-save }}
- name: Install Protoc
if: ${{ inputs.install-protoc == true }}
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Unit Tests
run: cargo test ${{ inputs.test-args }}
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 }}
# Before the cache step so RUSTFLAGS is part of the Swatinem cache key.
- name: Set up mold linker
if: ${{ inputs.use-mold }}
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends mold clang
echo "RUSTFLAGS=${RUSTFLAGS:+$RUSTFLAGS }-C linker=clang -C link-arg=-fuse-ld=mold" >> "$GITHUB_ENV"
- name: Rust cache
uses: Swatinem/rust-cache@23869a5bd66c73db3c0ac40331f3206eb23791dc # v2.9.1
with:
prefix-key: ${{ inputs.rust-cache-prefix }}
shared-key: tests-suites
save-if: ${{ inputs.rust-cache-save }}
- name: Install Protoc
if: ${{ inputs.install-protoc == true }}
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Test Suite
run: cargo test --test ${{ matrix.element }}
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: Rust cache
uses: Swatinem/rust-cache@23869a5bd66c73db3c0ac40331f3206eb23791dc # v2.9.1
with:
prefix-key: ${{ inputs.rust-cache-prefix }}
shared-key: unused-deps
save-if: ${{ inputs.rust-cache-save }}
- name: Install cargo-udeps
run: cargo install cargo-udeps@0.1.43 --locked
- name: Check Dependencies
run: cargo udeps --all-targets
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 licenses