This repository was archived by the owner on Dec 9, 2024. It is now read-only.
generated from clechasseur/rust-template
-
Notifications
You must be signed in to change notification settings - Fork 0
309 lines (266 loc) · 10.4 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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
name: CI
on: [ push ]
env:
CI: 1
jobs:
clippy:
name: Clippy validation${{ matrix.all-features && ' with all features' || '' }}
strategy:
fail-fast: false
matrix:
all-features: [ false ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust with clippy
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
with:
toolchain: stable
components: clippy
cache: false
- name: Rust Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
prefix-key: v1-rust
key: all-features-${{ matrix.all-features }}
cache-on-failure: true
- name: Run clippy
uses: clechasseur/rs-clippy-check@a2a93bdcf05de7909aabd62eca762179ad3dbe50 # v3.0.5
with:
args: --workspace --all-targets ${{ matrix.all-features && '--all-features' || '' }} -- -D warnings
fmt:
name: Rustfmt check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust nightly with rustfmt
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
with:
toolchain: nightly
components: rustfmt
cache: false
- name: Run Rustfmt
uses: clechasseur/rs-fmt-check@1a4ebb722c8e8a04f0d2e363c91744f81c968c42 # v2.0.5
with:
args: --all
msrv-check:
name: MSRV check for Rust ${{ matrix.toolchain }} on ${{ matrix.os }}${{ matrix.all-features && ' with all features' || '' }}
strategy:
fail-fast: false
matrix:
toolchain: [ 1.70.0 ]
os: [ ubuntu ]
all-features: [ false ]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust nightly and ${{ matrix.toolchain }}
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
with:
toolchain: nightly,${{ matrix.toolchain }}
cache: false
- name: Rust Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
prefix-key: v7-rust
key: all-features-${{ matrix.all-features }}-msrv-pins-files-${{ hashFiles('**/msrv-pins.toml') }}
cache-on-failure: true
- name: Install required tools
uses: taiki-e/install-action@3dc0bf887971817c6565ede5175dd4809d18f471 # v2.44.23
with:
tool: just,cargo-hack,cargo-minimal-versions,cargo-msrv,cargo-msrv-prep
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Note: there's a problem where running `cargo msrv-prep` with a version of Rust
# that's too old to resolve dependencies _before_ we apply the MSRV pins fails.
# For now, we'll run `cargo msrv-prep` and `cargo msrv-unprep` using the Nightly
# toolchain to work around the issue, but I'll have to think of a better way.
- name: Run checks using cargo-minimal-versions
run: |
just toolchain=nightly prep
just all_features=${{ matrix.all-features }} _check-minimal-only
just _rimraf target-minimal
just toolchain=nightly unprep
build:
name: Build for Rust ${{ matrix.toolchain }}${{ matrix.experimental && ' (experimental)' || '' }} on ${{ matrix.os }}${{ matrix.ignore-lock && ' without Cargo.lock' || '' }}${{ matrix.all-features && ' with all features' || '' }}
strategy:
fail-fast: false
matrix:
toolchain: [ 1.75.0, stable, nightly ]
os: [ ubuntu ]
ignore-lock: [ false ]
all-features: [ false ]
include:
- experimental: false
- toolchain: nightly
experimental: true
runs-on: ${{ matrix.os }}-latest
continue-on-error: ${{ matrix.experimental }}
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Remove Cargo.lock
if: ${{ matrix.ignore-lock }}
run: rm Cargo.lock
- name: Install Rust ${{ matrix.toolchain }}
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
with:
toolchain: ${{ matrix.toolchain }}
cache: false
- name: Rust Cache
if: ${{ !matrix.experimental }}
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
prefix-key: v2-rust
key: ignore-lock-${{ matrix.ignore-lock }}-all-features-${{ matrix.all-features }}
cache-on-failure: true
- name: Install just
uses: taiki-e/install-action@3dc0bf887971817c6565ede5175dd4809d18f471 # v2.44.23
with:
tool: just
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Start DB containers
uses: hoverkraft-tech/compose-action@f1ca7fefe3627c2dab0ae1db43a106d82740245e # v2.0.2
with:
down-flags: "--volumes"
- name: Run DB migrations
uses: clechasseur/rs-cargo@34eb9ee3e4186e5c7820a54393fbf081f78bc102 # v2.0.5
with:
command: run
args: --bin run_migrations
- name: Run checks
run: just all_features=${{ matrix.all-features }} check
- name: Run tests
run: just all_features=${{ matrix.all-features }} test
tarpaulin:
name: Code coverage
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
with:
toolchain: stable
cache: false
- name: Rust Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
prefix-key: v2-rust
cache-targets: false
cache-on-failure: true
- name: Install cargo-tarpaulin
uses: taiki-e/install-action@3dc0bf887971817c6565ede5175dd4809d18f471 # v2.44.23
with:
tool: cargo-tarpaulin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Start DB containers
uses: hoverkraft-tech/compose-action@f1ca7fefe3627c2dab0ae1db43a106d82740245e # v2.0.2
with:
down-flags: "--volumes"
- name: Run DB migrations
uses: clechasseur/rs-cargo@34eb9ee3e4186e5c7820a54393fbf081f78bc102 # v2.0.5
with:
command: run
args: --bin run_migrations
- name: Run cargo-tarpaulin
uses: clechasseur/rs-cargo@34eb9ee3e4186e5c7820a54393fbf081f78bc102 # v2.0.5
with:
command: tarpaulin
- name: Upload code coverage results to codecov.io
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
- name: Archive code coverage results
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: code-coverage-report
path: |
cobertura.xml
tarpaulin-report.html
doc:
name: Rustdoc check for Rust ${{ matrix.toolchain }}${{ matrix.experimental && ' (experimental)' || '' }}
strategy:
fail-fast: false
matrix:
toolchain: [ stable, nightly ]
include:
- experimental: false
- toolchain: nightly
experimental: true
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust ${{ matrix.toolchain }}
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
with:
toolchain: ${{ matrix.toolchain }}
cache: false
- name: Rust Cache
if: ${{ !matrix.experimental }}
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
prefix-key: v2-rust
cache-targets: false
cache-on-failure: true
- name: Install just
uses: taiki-e/install-action@3dc0bf887971817c6565ede5175dd4809d18f471 # v2.44.23
with:
tool: just
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate doc using rustdoc
run: just doc
publish-dry-run:
name: Publish dry-run
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
with:
toolchain: stable
cache: false
- name: Rust Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
prefix-key: v2-rust
cache-targets: false
cache-on-failure: true
- name: Perform publish dry-run
uses: clechasseur/rs-cargo@34eb9ee3e4186e5c7820a54393fbf081f78bc102 # v2.0.5
with:
command: publish
args: --dry-run
docker-image:
name: Build Docker image for Rust ${{ matrix.toolchain }}${{ matrix.experimental && ' (experimental)' || '' }}
strategy:
fail-fast: false
matrix:
toolchain: [ stable, nightly ]
include:
- experimental: false
- toolchain: nightly
experimental: true
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
- name: Build Docker image
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
target: final
push: false
tags: clechasseur/pokerust:ci
build-args: RUST_TOOLCHAIN=${{ matrix.toolchain }}
cache-from: ${{ matrix.experimental && 'type=inline' || 'type=gha' }}
cache-to: ${{ matrix.experimental && 'type=inline' || 'type=gha,mode=max' }}