Repository navigation
386 lines (342 loc) · 12 KB
/
Copy pathtest.yml
File metadata and controls
386 lines (342 loc) · 12 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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
name: Test Actions
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
NSS_TEST_VERSION: "3.126"
NSS_TEST_SHA256: "c95a4cf93d6939000642254422d71dffccb5c017d0f40733d3e2be18aa93f1be"
ROUNDTRIP_CACHE_KEY: roundtrip-${{ github.run_id }}
defaults:
run:
shell: bash
jobs:
actionlint:
uses: ./.github/workflows/actionlint.yml
permissions:
contents: read
security-events: write # Required to upload SARIF results to GitHub
dependency-review:
if: github.event_name == 'pull_request'
uses: ./.github/workflows/dependency-review.yml
test-rust:
name: Test Rust action
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-15, windows-2025]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./rust
id: rust
with:
version: stable
tools: cargo-nextest
token: ${{ github.token }}
rust-cache: false
- name: Verify installation
env:
GOT: ${{ steps.rust.outputs.cache-key }}
run: |
[ "$GOT" = "${ImageOS}-stable" ] || { echo "::error::cache-key is '$GOT', want '${ImageOS}-stable'"; exit 1; }
cargo --version
rustc --version
cargo nextest --version
# test-rust passes rust-cache: false, so nothing else exercises the caching path.
test-rust-cache:
name: Test Rust action caching (${{ matrix.os }}, cache-key=${{ matrix.cache-key || 'unset' }})
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
cache-key: ""
want: ubuntu24-stable
- os: ubuntu-24.04
cache-key: release
want: ubuntu24-stable-release
# A second image of the same OS, which used to share an entry with the first.
- os: ubuntu-22.04
cache-key: ""
want: ubuntu22-stable
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- id: rust
uses: ./rust
with:
version: stable
token: ${{ github.token }}
cache-key: ${{ matrix.cache-key }}
- name: Verify cache key and build environment
env:
GOT: ${{ steps.rust.outputs.cache-key }}
WANT: ${{ matrix.want }}
run: |
[ "$GOT" = "$WANT" ] || { echo "::error::cache-key is '$GOT', want '$WANT'"; exit 1; }
[ "$CARGO_INCREMENTAL" = "0" ] || { echo "::error::CARGO_INCREMENTAL is '${CARGO_INCREMENTAL:-unset}', want 0"; exit 1; }
# Self-hosted runners don't set ImageOS, so check the fallback that covers them.
# rust-cache is off because only the composed key matters here, and a key that no
# hosted runner produces shouldn't take up a cache entry.
test-rust-cache-no-imageos:
name: Test Rust action caching (no ImageOS)
timeout-minutes: 10
runs-on: ubuntu-24.04
env:
ImageOS: ""
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- id: rust
uses: ./rust
with:
version: stable
token: ${{ github.token }}
rust-cache: false
- name: Verify the cache key falls back to the runner OS
env:
GOT: ${{ steps.rust.outputs.cache-key }}
run: |
[ "$GOT" = "Linux-stable" ] || { echo "::error::cache-key is '$GOT', want 'Linux-stable'"; exit 1; }
# Saving only happens on the default branch, so the round trip can only be
# exercised there: this job populates the cache, test-rust-cache-restore reads it.
test-rust-cache-save:
name: Populate Rust cache
timeout-minutes: 15
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./rust
with:
version: stable
token: ${{ github.token }}
cache-key: ${{ env.ROUNDTRIP_CACHE_KEY }}
- run: cargo build --locked --all-features
working-directory: test-crate
test-rust-cache-restore:
name: Restore Rust cache
timeout-minutes: 15
needs: test-rust-cache-save
permissions:
contents: read
actions: write # Required to delete the throwaway cache entry below
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- id: rust
uses: ./rust
with:
version: stable
token: ${{ github.token }}
cache-key: ${{ env.ROUNDTRIP_CACHE_KEY }}
- name: Verify the cache was restored
env:
HIT: ${{ steps.rust.outputs.cache-hit }}
run: |
[ "$HIT" = "true" ] || { echo "::error::cache-hit is '${HIT:-empty}', want true"; exit 1; }
# actions/cache has no delete action, so use the API.
- name: Remove the throwaway cache entry
if: ${{ always() }}
env:
GH_TOKEN: ${{ github.token }}
PREFIX: v0-rust-${{ steps.rust.outputs.cache-key }}
run: |
ids=$(gh cache list --key "$PREFIX" --json id --jq '.[].id')
for id in $ids; do gh cache delete "$id"; done
n=$(printf '%s' "$ids" | grep -c . || true)
[ "$n" -eq 1 ] || { echo "::error::matched $n entries for $PREFIX, want 1"; exit 1; }
test-toolchains:
name: Test toolchains action
timeout-minutes: 5
runs-on: ubuntu-24.04
# cargo is pre-installed on GitHub-hosted Ubuntu runners
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./toolchains
id: toolchains
with:
working-directory: test-crate
- name: Verify output
env:
TOOLCHAINS: ${{ steps.toolchains.outputs.toolchains }}
run: |
echo "Toolchains: $TOOLCHAINS"
python3 -c "
import os, json
data = json.loads(os.environ['TOOLCHAINS'])
assert len(data) == 3, f'Expected 3 toolchains, got {data}'
assert '1.70.0' in data, f'Expected MSRV 1.70.0 in {data}'
assert 'stable' in data, f'Expected stable in {data}'
assert 'nightly' in data, f'Expected nightly in {data}'
print('OK:', data)
"
test-nss:
name: Test NSS action
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- ubuntu-24.04
- ubuntu-24.04-arm
- macos-15
- macos-15-intel
- windows-2022
- windows-2025
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./nss
with:
minimum-version: ${{ env.NSS_TEST_VERSION }}
sha256: ${{ env.NSS_TEST_SHA256 }}
cache: false
- name: Verify NSS is available
run: |
if [ -n "$NSS_DIR" ]; then
echo "NSS_DIR=$NSS_DIR (built from source)"
else
pkg-config --modversion nss
echo "Using system NSS: $(pkg-config --modversion nss)"
fi
test-nss-deps-only:
name: Test NSS action (deps-only, ${{ matrix.target || matrix.os }})
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
- os: macos-15
- os: windows-2025
# The one deps-only path where NSS_BUILD_FLAGS varies.
- os: ubuntu-24.04
target: i686-unknown-linux-gnu
runs-on: ${{ matrix.os }}
env:
TARGET: ${{ matrix.target }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: $/nss
with:
deps-only: true
target: ${{ matrix.target }}
- name: Verify the toolchain and environment are set up, but no NSS was acquired
run: |
# build.sh needs all of these afterwards, whether this action installed
# them or the runner image did. Presence only: Ubuntu's gyp predates
# gyp-next and has no --version.
command -v gyp
command -v ninja
[ "$RUNNER_OS" != "Windows" ] || command -v nsinstall
[ -n "$NSS_BUILD_FLAGS" ] || { echo "::error::NSS_BUILD_FLAGS is unset"; exit 1; }
# build.sh would otherwise default target_arch to the host.
case "$NSS_BUILD_FLAGS" in
*"-t ia32"*) [ -n "$TARGET" ] || { echo "::error::-t ia32 set without a target"; exit 1; } ;;
*) [ -z "$TARGET" ] || { echo "::error::-t ia32 missing for $TARGET"; exit 1; } ;;
esac
# GCC-style flags would break the MSVC build, so they must not be set there.
if [ "$RUNNER_OS" == "Windows" ]; then
[ -z "$NSS_BUILD_CFLAGS" ] || { echo "::error::NSS_BUILD_CFLAGS is set on Windows"; exit 1; }
else
[ -n "$NSS_BUILD_CFLAGS" ] || { echo "::error::NSS_BUILD_CFLAGS is unset"; exit 1; }
fi
[ "$NSS_DIR" = "$GITHUB_WORKSPACE/nss" ] || { echo "::error::NSS_DIR is '$NSS_DIR'"; exit 1; }
# $NSS_DIR is this repository's own nss/ directory here, so look for a
# file only an NSS checkout would have.
[ ! -e "$NSS_DIR/build.sh" ] || { echo "::error::NSS was retrieved into $NSS_DIR"; exit 1; }
[ ! -d dist ] || { echo "::error::dist/ exists, so NSS was built"; exit 1; }
clippy:
uses: ./.github/workflows/clippy.yml
rustfmt:
uses: ./.github/workflows/rustfmt.yml
deny:
uses: ./.github/workflows/deny.yml
machete:
uses: ./.github/workflows/machete.yml
sanitize:
uses: ./.github/workflows/sanitize.yml
crap:
uses: ./.github/workflows/crap.yml
permissions:
contents: read
security-events: write # Required to upload SARIF results to GitHub
with:
features: hashing,encoding
mutants:
uses: ./.github/workflows/mutants.yml
with:
shards: 1
args: "--features hashing,encoding"
test-nss-android:
name: Test NSS action (Android)
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
target:
- aarch64-linux-android
- arm-linux-androideabi
- x86_64-linux-android
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./nss
with:
minimum-version: ${{ env.NSS_TEST_VERSION }}
sha256: ${{ env.NSS_TEST_SHA256 }}
target: ${{ matrix.target }}
token: ${{ github.token }}
cache: false
- name: Verify NSS is available for Android
run: |
echo "NSS_DIR=$NSS_DIR"
ls dist/Release/lib/*.a
test-nss-i686:
name: Test NSS action (i686)
timeout-minutes: 60
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./nss
with:
minimum-version: ${{ env.NSS_TEST_VERSION }}
sha256: ${{ env.NSS_TEST_SHA256 }}
target: i686-unknown-linux-gnu
token: ${{ github.token }}
cache: false
- name: Verify NSS is 32-bit
run: |
echo "NSS_DIR=$NSS_DIR"
ls dist/Release/lib/*.a
file dist/Release/lib/*.so | tee /dev/stderr | grep -q 'Intel 80386'