-
Notifications
You must be signed in to change notification settings - Fork 13
344 lines (296 loc) · 11.4 KB
/
ci.yml
File metadata and controls
344 lines (296 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
lint:
name: lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust
run: rustup toolchain install stable --profile minimal -c rustfmt -c clippy
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: ./.github/actions/install-tools
with:
tools: just
- name: Check lint
run: just check-lint
- name: Check zizmor
run: |
pipx install zizmor==1.23.1
zizmor --format plain .github/
- name: Check `cargo package`
# creates a .crate for distribution and verifies it can build in isolation
# see https://doc.rust-lang.org/cargo/commands/cargo-package.html
run: cargo package --workspace
test:
name: test (${{ matrix.rust }})
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
rust: ["1.86", stable]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust
run: rustup toolchain install ${{ matrix.rust }} --profile minimal && rustup default ${{ matrix.rust }}
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: ./.github/actions/install-tools
with:
tools: just uv
- name: Run tests
run: just check-tests
test-all-features:
name: test-all-features (${{ matrix.rust }})
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
rust: ["1.86", stable]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust
run: rustup toolchain install ${{ matrix.rust }} --profile minimal && rustup default ${{ matrix.rust }}
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: ./.github/actions/install-tools
with:
tools: just uv
- name: Run tests with all features
run: just check-tests-all-features
docs:
name: docs
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust
run: rustup toolchain install nightly --profile minimal && rustup default nightly
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: ./.github/actions/install-tools
with:
tools: just
- name: Install cargo-docs-rs
run: cargo install --locked cargo-docs-rs
- name: Check docs
run: just check-docs
# test with the minimal versions of all our dependencies
test-minimal-versions:
name: test-minimal-versions
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust
run: rustup toolchain install nightly --profile minimal && rustup default nightly
- uses: Swatinem/rust-cache@ad397744b0d591a723ab90405b7247fac0e6b8db # v2
- uses: ./.github/actions/install-tools
with:
tools: just uv
- name: Generate lockfile
run: cargo generate-lockfile -Z minimal-versions
- name: Run tests
run: just check-tests-minimal-versions
compile-examples:
name: compile-examples (${{ matrix.rust }})
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
rust: ["1.86", stable]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust
run: rustup toolchain install ${{ matrix.rust }} --profile minimal && rustup default ${{ matrix.rust }}
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Compile examples
run: cargo build --examples --all-features
coverage:
name: coverage
runs-on: ubuntu-latest
permissions:
contents: write # needed for ratchet auto-update
pull-requests: write # needed for creating PRs on main
steps:
# persist-credentials needed for git push in the auto-update step below
# For fork PRs, head_ref points to a branch that doesn't exist on the base repo,
# so we fall back to the default ref (the merge commit).
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 # zizmor: ignore[artipacked]
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
with:
ref: ${{ github.head_ref || github.ref }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
with:
persist-credentials: false
- name: Install Rust
run: rustup toolchain install stable --profile minimal -c llvm-tools-preview
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Install cargo-llvm-cov
run: cargo install --locked cargo-llvm-cov
- uses: ./.github/actions/install-tools
with:
tools: just uv
- name: Run coverage
run: just check-coverage
- name: Auto-update coverage annotations and ratchet
if: success() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
env:
GH_TOKEN: ${{ github.token }}
run: |
if git diff --quiet; then
echo "No coverage annotation changes needed"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -u
git add .github/coverage-ratchet.json
if git diff --cached --quiet; then
exit 0
fi
if [ "${{ github.event_name }}" = "pull_request" ]; then
git commit -m "Auto-update coverage annotations and ratchet"
git push
else
BRANCH="auto/coverage-ratchet-update"
git checkout -b "$BRANCH"
git commit -m "Auto-update coverage annotations and ratchet"
git push -f origin "$BRANCH"
gh pr create \
--title "Auto-update coverage ratchet" \
--body "The coverage ratchet has tightened on main. This PR updates the ratchet file and removes unnecessary annotations." \
--base main \
--head "$BRANCH" || true
fi
conformance:
name: conformance
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust
run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: ./.github/actions/install-tools
with:
tools: just uv
- name: Run conformance tests
run: just check-conformance
nix:
name: nix
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: cachix/install-nix-action@1ca7d21a94afc7c957383a2d217460d980de4934 # v31.10.1
- uses: ./.github/actions/install-tools
with:
tools: just
- name: lint
run: just check-format-nix
release:
name: release
if: github.event_name == 'push' && github.repository == 'hegeldev/hegel-rust'
needs: [lint, test, test-all-features, test-minimal-versions, docs, coverage, conformance, nix]
runs-on: ubuntu-latest
permissions:
contents: write
# id-token: "enables the workflow to request and use an OIDC token from GitHub's OIDC provider".
# Used by our trusted publishing flow
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Check for RELEASE.md
id: check
run: |
if [ ! -f RELEASE.md ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
- name: Generate app token
if: steps.check.outputs.skip != 'true'
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
id: app-token
with:
app-id: ${{ vars.HEGEL_RELEASE_APP_ID }}
private-key: ${{ secrets.HEGEL_RELEASE_APP_PRIVATE_KEY }}
repositories: hegel-rust
- name: Re-checkout with app token # zizmor: ignore[artipacked]
if: steps.check.outputs.skip != 'true'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
token: ${{ steps.app-token.outputs.token }}
- name: Release
if: steps.check.outputs.skip != 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
HEGEL_RELEASE_APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
run: python .github/scripts/release.py release
- name: Install Rust
if: steps.check.outputs.skip != 'true'
run: rustup toolchain install stable --profile minimal
- name: Authenticate with crates.io
if: steps.check.outputs.skip != 'true'
uses: rust-lang/crates-io-auth-action@b7e9a28eded4986ec6b1fa40eeee8f8f165559ec # v1.0.3
id: crates-io-auth
- name: Publish hegeltest-macros
if: steps.check.outputs.skip != 'true'
run: cargo publish -p hegeltest-macros
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}
- name: Wait for crates.io index
if: steps.check.outputs.skip != 'true'
run: |
VERSION=$(grep '^version' hegel-macros/Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
echo "waiting for hegeltest-macros $VERSION to appear on crates.io..."
for i in $(seq 1 60); do
if cargo search hegeltest-macros | grep -q "\"$VERSION\""; then
exit 0
fi
sleep 3
done
echo "Timed out waiting for hegeltest-macros to appear on Crates.io"
exit 1
- name: Publish hegeltest
if: steps.check.outputs.skip != 'true'
run: cargo publish -p hegeltest
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}
- name: Push to main or open PR
if: steps.check.outputs.skip != 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: python .github/scripts/release.py push-or-pr