1
1
name : ci
2
2
3
- env :
4
- CARGO_TERM_COLOR : always
5
- CLICOLOR : 1
6
-
7
3
on :
8
4
push :
9
5
branches :
17
13
- main
18
14
workflow_dispatch :
19
15
16
+ permissions :
17
+ contents : read
18
+
19
+ env :
20
+ CARGO_TERM_COLOR : always
21
+ CLICOLOR : ' 1'
22
+
20
23
jobs :
21
24
pure-rust-build :
22
25
runs-on : ubuntu-latest
26
+
23
27
container : debian:stable-slim
28
+
24
29
steps :
25
30
- uses : actions/checkout@v4
26
31
- name : Prerequisites
@@ -31,14 +36,14 @@ jobs:
31
36
run : |
32
37
set -x
33
38
for pattern in cmake g++ libssl-dev make pkgconf pkg-config; do
34
- if dpkg-query --status -- "$pattern"; then
35
- exit 1
36
- fi
39
+ if dpkg-query --status -- "$pattern"; then
40
+ exit 1
41
+ fi
37
42
done
38
43
for cmd in cmake g++ make pkgconf pkg-config; do
39
- if command -v -- "$cmd"; then
40
- exit 1
41
- fi
44
+ if command -v -- "$cmd"; then
45
+ exit 1
46
+ fi
42
47
done
43
48
- name : Install Rust via Rustup
44
49
run : curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
@@ -47,21 +52,20 @@ jobs:
47
52
48
53
test :
49
54
runs-on : ubuntu-latest
55
+
50
56
steps :
51
57
- uses : actions/checkout@v4
52
58
- uses : dtolnay/rust-toolchain@stable
53
59
- uses : Swatinem/rust-cache@v2
54
60
- name : Setup dependencies
55
- run :
56
- sudo apt-get install -y --no-install-recommends liblzma-dev tree
61
+ run : sudo apt-get install -y --no-install-recommends liblzma-dev tree
57
62
- uses : extractions/setup-just@v2
58
63
- uses : taiki-e/install-action@v2
59
64
with :
60
65
tool : nextest
61
66
- name : test
62
67
env :
63
- CI : true
64
- GIX_TEST_IGNORE_ARCHIVES : 1
68
+ GIX_TEST_IGNORE_ARCHIVES : ' 1'
65
69
run : just ci-test
66
70
67
71
test-fast :
71
75
- windows-latest
72
76
- macos-latest
73
77
- ubuntu-latest
78
+
74
79
runs-on : ${{ matrix.os }}
80
+
75
81
steps :
76
82
- uses : actions/checkout@v4
77
83
- uses : dtolnay/rust-toolchain@stable
88
94
tool : nextest
89
95
- name : " Test (nextest)"
90
96
env :
91
- GIX_TEST_CREATE_ARCHIVES_EVEN_ON_CI : 1
97
+ GIX_TEST_CREATE_ARCHIVES_EVEN_ON_CI : ' 1 '
92
98
run : cargo nextest run --workspace --no-fail-fast
93
99
- name : Doctest
94
100
run : cargo test --workspace --doc --no-fail-fast
97
103
98
104
test-fixtures-windows :
99
105
runs-on : windows-latest
106
+
100
107
steps :
101
108
- uses : actions/checkout@v4
102
109
- uses : dtolnay/rust-toolchain@stable
@@ -119,8 +126,8 @@ jobs:
119
126
[xml]$junit_xml = Get-Content -Path 'target/nextest/with-xml/junit.xml'
120
127
121
128
$actual_failures = $junit_xml.SelectNodes("//testcase[failure]") |
122
- ForEach-Object { "$($_.classname) $($_.name)" } |
123
- Sort-Object
129
+ ForEach-Object { "$($_.classname) $($_.name)" } |
130
+ Sort-Object
124
131
125
132
Write-Output $actual_failures
126
133
Set-Content -Path 'actual-failures.txt' -Value $actual_failures
@@ -129,13 +136,15 @@ jobs:
129
136
# Fail on any differences, even unexpectedly passing tests, so they can be investigated.
130
137
# (If the job is made blocking for PRs, it may make sense to make this less stringent.)
131
138
git --no-pager diff --no-index --exit-code --unified=1000000 --color=always -- `
132
- etc/test-fixtures-windows-expected-failures-see-issue-1358.txt actual-failures.txt
139
+ etc/test-fixtures-windows-expected-failures-see-issue-1358.txt actual-failures.txt
133
140
134
141
test-32bit :
135
142
runs-on : ubuntu-latest
143
+
136
144
strategy :
137
145
matrix :
138
146
target : [ armv7-linux-androideabi ]
147
+
139
148
steps :
140
149
- uses : actions/checkout@v4
141
150
- uses : dtolnay/rust-toolchain@stable
@@ -157,6 +166,7 @@ jobs:
157
166
158
167
lint :
159
168
runs-on : ubuntu-latest
169
+
160
170
steps :
161
171
- uses : actions/checkout@v4
162
172
- uses : dtolnay/rust-toolchain@master
@@ -170,17 +180,21 @@ jobs:
170
180
run : just doc
171
181
- name : Run cargo fmt
172
182
run : cargo fmt --all -- --check
173
- - name : Run cargo diet
183
+ - name : Install cargo diet
184
+ env :
185
+ CARGO_DIET_TAG : v1.2.7
174
186
run : |
175
- curl -LSfs https://raw.githubusercontent.com/the-lean-crate/cargo-diet/master/ci/install.sh | \
176
- sh -s -- --git the-lean-crate/cargo-diet --target x86_64-unknown-linux-musl --tag v1.2.4
177
-
178
- # Let's not fail CI for this, it will fail locally often enough, and a crate a little bigger
179
- # than allows is no problem either if it comes to that.
180
- just check-size || true
187
+ curl -LSfs "https://raw.githubusercontent.com/the-lean-crate/cargo-diet/refs/tags/$CARGO_DIET_TAG/ci/install.sh" |
188
+ sh -s -- --git the-lean-crate/cargo-diet --target x86_64-unknown-linux-musl --tag "$CARGO_DIET_TAG"
189
+ - name : Run cargo diet
190
+ run : just check-size
191
+ # Let's not fail CI for this, it will fail locally often enough, and a crate a little bigger
192
+ # than allows is no problem either if it comes to that.
193
+ continue-on-error : true
181
194
182
195
cargo-deny :
183
196
runs-on : ubuntu-latest
197
+
184
198
strategy :
185
199
matrix :
186
200
checks :
@@ -198,27 +212,51 @@ jobs:
198
212
199
213
wasm :
200
214
name : WebAssembly
215
+
201
216
runs-on : ubuntu-latest
202
- continue-on-error : true
217
+
203
218
strategy :
204
219
matrix :
205
220
target : [ wasm32-unknown-unknown, wasm32-wasi ]
221
+
222
+ env :
223
+ TARGET : ${{ matrix.target }}
224
+
206
225
steps :
207
- - uses : actions/checkout@master
226
+ - uses : actions/checkout@v4
208
227
- name : Install Rust
209
- run : rustup update stable && rustup default stable && rustup target add ${{ matrix.target }}
228
+ run : |
229
+ rustup update stable
230
+ rustup default stable
231
+ rustup target add "$TARGET"
210
232
- uses : Swatinem/rust-cache@v2
211
- - run : set +x; for name in gix-sec; do (cd $name && cargo build --target ${{ matrix.target }}); done
212
- name : " WASI only: crates without feature toggle"
233
+ - name : ' WASI only: crates without feature toggle'
213
234
if : endsWith(matrix.target, '-wasi')
214
- - run : set +x; for name in gix-actor gix-attributes gix-bitmap gix-chunk gix-command gix-commitgraph gix-config-value gix-date gix-glob gix-hash gix-hashtable gix-mailmap gix-object gix-packetline gix-path gix-pathspec gix-prompt gix-quote gix-refspec gix-revision gix-traverse gix-url gix-validate; do (cd $name && cargo build --target ${{ matrix.target }}); done
215
- name : crates without feature toggles
216
- - run : set +x; for feature in progress fs-walkdir-parallel parallel io-pipe crc32 zlib zlib-rust-backend fast-sha1 rustsha1 cache-efficiency-debug; do (cd gix-features && cargo build --features $feature --target ${{ matrix.target }}); done
217
- name : features of gix-features
218
- - run : set +x; for name in gix-pack; do (cd $name && cargo build --features wasm --target ${{ matrix.target }}); done
219
- name : crates with 'wasm' feature
220
- - run : cd gix-pack && cargo build --all-features --target ${{ matrix.target }}
221
- name : gix-pack with all features (including wasm)
235
+ run : |
236
+ set +x
237
+ for name in gix-sec; do
238
+ (cd -- "$name" && cargo build --target "$TARGET")
239
+ done
240
+ - name : crates without feature toggles
241
+ run : |
242
+ set +x
243
+ for name in gix-actor gix-attributes gix-bitmap gix-chunk gix-command gix-commitgraph gix-config-value gix-date gix-glob gix-hash gix-hashtable gix-mailmap gix-object gix-packetline gix-path gix-pathspec gix-prompt gix-quote gix-refspec gix-revision gix-traverse gix-url gix-validate; do
244
+ (cd -- "$name" && cargo build --target "$TARGET")
245
+ done
246
+ - name : features of gix-features
247
+ run : |
248
+ set +x
249
+ for feature in progress fs-walkdir-parallel parallel io-pipe crc32 zlib zlib-rust-backend fast-sha1 rustsha1 cache-efficiency-debug; do
250
+ (cd gix-features && cargo build --features "$feature" --target "$TARGET")
251
+ done
252
+ - name : crates with 'wasm' feature
253
+ run : |
254
+ set +x
255
+ for name in gix-pack; do
256
+ (cd -- "$name" && cargo build --features wasm --target "$TARGET")
257
+ done
258
+ - name : gix-pack with all features (including wasm)
259
+ run : cd gix-pack && cargo build --all-features --target "$TARGET"
222
260
223
261
check-packetline :
224
262
strategy :
@@ -230,10 +268,13 @@ jobs:
230
268
# However, when changes are made to `etc/copy-packetline.sh`, re-enable the other platforms for testing.
231
269
# - macos-latest
232
270
# - windows-latest
271
+
233
272
runs-on : ${{ matrix.os }}
273
+
234
274
defaults :
235
275
run :
236
276
shell : bash
277
+
237
278
steps :
238
279
- uses : actions/checkout@v4
239
280
- name : Check that working tree is initially clean
@@ -249,22 +290,63 @@ jobs:
249
290
git status
250
291
git diff --exit-code
251
292
293
+ # Check that only jobs intended not to block PR auto-merge are omitted as
294
+ # dependencies of the `tests-pass` job below, so that whenever a job is
295
+ # added, a decision is made about whether it must pass for PRs to merge.
296
+ check-blocking :
297
+ runs-on : ubuntu-latest
298
+
299
+ env :
300
+ # List all jobs that are intended NOT to block PR auto-merge here.
301
+ EXPECTED_NONBLOCKING_JOBS : |-
302
+ test-fixtures-windows
303
+ wasm
304
+ tests-pass
305
+
306
+ defaults :
307
+ run :
308
+ shell : bash # Without specifying this, we don't get `-o pipefail`.
309
+
310
+ steps :
311
+ - name : Find this workflow
312
+ run : |
313
+ relative_workflow_with_ref="${GITHUB_WORKFLOW_REF#"$GITHUB_REPOSITORY/"}"
314
+ echo "WORKFLOW_PATH=${relative_workflow_with_ref%@*}" >> "$GITHUB_ENV"
315
+ - uses : actions/checkout@v4
316
+ with :
317
+ sparse-checkout : ${{ env.WORKFLOW_PATH }}
318
+ - name : Get all jobs
319
+ run : yq '.jobs | keys.[]' -- "$WORKFLOW_PATH" | sort | tee all-jobs.txt
320
+ - name : Get blocking jobs
321
+ run : yq '.jobs.tests-pass.needs.[]' -- "$WORKFLOW_PATH" | sort | tee blocking-jobs.txt
322
+ - name : Get jobs we intend do not block
323
+ run : sort <<<"$EXPECTED_NONBLOCKING_JOBS" | tee expected-nonblocking-jobs.txt
324
+ - name : Each job must block PRs or be declared not to
325
+ run : |
326
+ sort -m blocking-jobs.txt expected-nonblocking-jobs.txt |
327
+ diff --color=always -U1000 -- - all-jobs.txt
328
+
252
329
# Dummy job to have a stable name for the "all tests pass" requirement
253
330
tests-pass :
254
331
name : Tests pass
332
+
255
333
needs :
256
334
- pure-rust-build
257
335
- test
258
336
- test-fast
259
337
- test-32bit
260
338
- lint
261
339
- cargo-deny
262
- - wasm
263
340
- check-packetline
341
+ - check-blocking
342
+
264
343
if : always() # always run even if dependencies fail
344
+
265
345
runs-on : ubuntu-latest
346
+
266
347
steps :
267
- # fail if ANY dependency has failed or cancelled
268
- - if : " contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')"
348
+ - name : Fail if ANY dependency has failed or cancelled
349
+ if : " contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')"
269
350
run : exit 1
270
- - run : exit 0
351
+ - name : OK
352
+ run : exit 0
0 commit comments