-
Notifications
You must be signed in to change notification settings - Fork 1.2k
373 lines (348 loc) · 12.7 KB
/
ci.yaml
File metadata and controls
373 lines (348 loc) · 12.7 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
name: CI
on:
merge_group:
pull_request:
types: [opened, synchronize, reopened]
schedule:
# Run CI on `main` daily so there is a cache available for merge queues.
# See <https://github.com/orgs/community/discussions/66430>
- cron: "0 8 * * *"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
CARGO_TERM_VERBOSE: true
LIBC_CI: 1
RUSTDOCFLAGS: -Dwarnings
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: full
# Base branch for PRs or for merges, current ref for cron runs on a branch.
TARGET_REF: ${{ github.base_ref || github.event.merge_group.base_ref || github.ref }}
defaults:
run:
shell: bash
jobs:
style_check:
name: Style check
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- name: Setup Rust toolchain
run: ./ci/install-rust.sh && rustup component add rustfmt
- name: Check style
run: ./ci/style.py
clippy:
name: Clippy on ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, macos-26, windows-2025]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- run: rustup update stable --no-self-update
- uses: Swatinem/rust-cache@v2
# Here we use the latest stable Rust toolchain already installed by GitHub
# Ideally we should run it for every target, but we cannot rely on unstable toolchains
# due to Clippy not being consistent between them.
- run: cargo clippy --workspace --exclude libc-test --exclude ctest-test --all-targets -- -D warnings
# This runs `cargo build --target ...` for all T1 and T2 targets`
verify_build:
name: Verify build
strategy:
matrix:
toolchain: [stable, 1.65.0]
include:
# Nightly has a lot of targets, so split it in half
- toolchain: nightly
half: 1
- toolchain: nightly
half: 2
- toolchain: beta
only: '(aarch64|x86_64)' # just a spot check for beta
- toolchain: stable
- toolchain: 1.65.0 # msrv
runs-on: ubuntu-24.04
timeout-minutes: 25
env:
TOOLCHAIN: ${{ matrix.toolchain }}
steps:
- uses: actions/checkout@v6
- name: Setup Rust toolchain
run: ./ci/install-rust.sh
- name: Install semver-checks
uses: taiki-e/install-action@cargo-semver-checks
if: matrix.toolchain == 'stable'
- name: Retrieve semver baseline
if: matrix.toolchain == 'stable'
run: ./ci/prep-semver-baseline.sh
# FIXME(ci): These `du` statements are temporary for debugging cache
- name: Target size before restoring cache
run: du -sh target | sort -k 2 || true
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}-${{ matrix.toolchain }}
- name: Target size after restoring cache
run: du -sh target | sort -k 2 || true
- name: Execute build check
run: |
set -eux
if [ "${{ matrix.toolchain }}" = "1.65.0" ]; then
# Remove `-Dwarnings` at the MSRV since lints may be different
export RUSTFLAGS=""
# Remove `ctest` which uses the 2024 edition
perl -i -ne 'print unless /"ctest(-test)?",/ || /"libc-test",/' Cargo.toml
fi
python3 ci/verify-build.py \
--toolchain "$TOOLCHAIN" \
${BASELINE_CRATE_DIR:+"--baseline-crate-dir" "$BASELINE_CRATE_DIR"} \
${{ matrix.only && format('--only "{0}"', matrix.only) }} \
${{ matrix.half && format('--half "{0}"', matrix.half) }}
- name: Target size after job completion
run: du -sh target | sort -k 2
test_tier1:
name: Test tier1
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-26
- target: aarch64-pc-windows-msvc
os: windows-11-arm
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
# FIXME: It currently causes segfaults.
#- target: i686-pc-windows-gnu
# env: { ARCH_BITS: 32, ARCH: i686 }
- target: i686-pc-windows-msvc
os: windows-2025
- target: i686-unknown-linux-gnu
- target: x86_64-pc-windows-gnu
os: windows-2025
env: { ARCH_BITS: 64, ARCH: x86_64 }
- target: x86_64-pc-windows-msvc
os: windows-2025
- target: x86_64-unknown-linux-gnu
runs-on: ${{ matrix.os && matrix.os || 'ubuntu-24.04' }}
timeout-minutes: 25
env:
TARGET: ${{ matrix.target }}
steps:
- uses: actions/checkout@v6
- name: Setup Rust toolchain
run: ./ci/install-rust.sh
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Add matrix env variables to the environment
if: matrix.env
run: |
echo '${{ toJson(matrix.env) }}' |
jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' >>$GITHUB_ENV
shell: bash
- name: Run natively
if: runner.os != 'Linux'
run: ./ci/run.sh ${{ matrix.target }}
- name: Run in Docker
if: runner.os == 'Linux'
run: ./ci/run-docker.sh ${{ matrix.target }}
- name: Create CI artifacts
id: create_artifacts
if: always()
run: echo "step is actually running" && python3 ci/create-artifacts.py
- uses: actions/upload-artifact@v7
if: always() && steps.create_artifacts.outcome == 'success'
with:
name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }}
path: ${{ env.ARCHIVE_PATH }}
retention-days: 5
test_tier2:
name: Test tier2
needs: [test_tier1, style_check]
strategy:
fail-fast: true
max-parallel: 16
matrix:
include:
# FIXME(sparc): this takes much longer to run than any other job, put
# it first to make sure it gets a head start.
- target: sparc64-unknown-linux-gnu
- target: aarch64-linux-android
- target: aarch64-unknown-linux-musl
- target: aarch64-unknown-linux-musl
env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 }
artifact-tag: new-musl
- target: arm-linux-androideabi
- target: arm-unknown-linux-gnueabihf
- target: arm-unknown-linux-musleabihf
- target: arm-unknown-linux-musleabihf
env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 }
artifact-tag: new-musl
# FIXME(#4297): Disabled due to spurious failue
# - target: i686-linux-android
- target: i686-unknown-linux-musl
- target: i686-unknown-linux-musl
env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 }
artifact-tag: new-musl
- target: loongarch64-unknown-linux-gnu
- target: loongarch64-unknown-linux-musl
- target: loongarch64-unknown-linux-musl
env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 }
artifact-tag: new-musl
- target: powerpc64-unknown-linux-gnu
- target: powerpc64le-unknown-linux-gnu
- target: powerpc64le-unknown-linux-musl
- target: powerpc64le-unknown-linux-musl
env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 }
artifact-tag: new-musl
- target: riscv64gc-unknown-linux-gnu
- target: s390x-unknown-linux-gnu
- target: wasm32-unknown-emscripten
- target: wasm32-wasip1
- target: wasm32-wasip2
- target: x86_64-apple-darwin
os: macos-26-intel
- target: x86_64-linux-android
# FIXME: Exec format error (os error 8)
# - target: x86_64-unknown-linux-gnux32
- target: x86_64-unknown-linux-musl
- target: x86_64-unknown-linux-musl
env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 }
artifact-tag: new-musl
# FIXME: It seems some items in `src/unix/mod.rs` aren't defined on redox actually.
# - target: x86_64-unknown-redox
# FIXME(ppc): SIGILL running tests, see
# https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713
# - target: powerpc-unknown-linux-gnu
runs-on: ${{ matrix.os && matrix.os || 'ubuntu-24.04' }}
timeout-minutes: 25
env:
TARGET: ${{ matrix.target }}
steps:
- uses: actions/checkout@v6
- name: Setup Rust toolchain
run: ./ci/install-rust.sh
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Add matrix env variables to the environment
if: matrix.env
run: |
echo '${{ toJson(matrix.env) }}' |
jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' >>$GITHUB_ENV
shell: bash
- name: Run natively
if: runner.os != 'Linux'
run: ./ci/run.sh ${{ matrix.target }}
- name: Run in Docker
if: runner.os == 'Linux'
run: ./ci/run-docker.sh ${{ matrix.target }}
- name: Create CI artifacts
id: create_artifacts
if: always()
run: ./ci/create-artifacts.py
- uses: actions/upload-artifact@v7
if: always() && steps.create_artifacts.outcome == 'success'
with:
name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }}
path: ${{ env.ARCHIVE_PATH }}
retention-days: 5
test_tier2_vm:
name: Test tier2 VM
needs: [test_tier1, style_check]
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- target: x86_64-pc-solaris
- target: x86_64-unknown-netbsd
timeout-minutes: 25
steps:
- uses: actions/checkout@v6
- name: test on Solaris
uses: vmactions/solaris-vm@v1.3.2
if: contains(matrix.target, 'solaris')
with:
release: "11.4-gcc"
usesh: true
mem: 4096
copyback: false
prepare: |
set -x
source <(curl -s https://raw.githubusercontent.com/psumbera/solaris-rust/refs/heads/main/sh.rust-web-install)
rustc --version
uname -a
run: |
export PATH=$HOME/.rust_solaris/bin:$PATH
./ci/run.sh ${{ matrix.target }}
- name: Test on NetBSD
uses: vmactions/netbsd-vm@v1
if: contains(matrix.target, 'netbsd')
with:
release: "10.1"
usesh: true
mem: 4096
copyback: false
prepare: |
set -x
/usr/sbin/pkg_add curl
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
--profile minimal --default-toolchain nightly -y
run: |
set -x
. "$HOME/.cargo/env"
which rustc
rustc -Vv
./ci/run.sh ${{ matrix.target }}
ctest_msrv:
name: Check ctest MSRV
runs-on: ubuntu-24.04
timeout-minutes: 10
env:
RUSTFLAGS: # No need to check warnings on old MSRV, unset `-Dwarnings`
steps:
- uses: actions/checkout@master
- run: |
msrv="$(
cargo metadata --format-version 1 |
jq -r --arg CRATE_NAME ctest '.packages | map(select((.name == $CRATE_NAME) and (.id | startswith("path+file")))) | first | .rust_version'
)"
echo "MSRV: $msrv"
echo "MSRV=$msrv" >> "$GITHUB_ENV"
- name: Install Rust
run: rustup update "$MSRV" --no-self-update && rustup default "$MSRV"
- uses: Swatinem/rust-cache@v2
- run: cargo build -p ctest
docs:
name: Ensure docs build
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update nightly --no-self-update && rustup default nightly
- uses: Swatinem/rust-cache@v2
- run: cargo doc --workspace --no-deps
# One job that "summarizes" the success state of this pipeline. This can then be added to branch
# protection, rather than having to add each job separately.
success:
name: success
runs-on: ubuntu-24.04
needs:
- style_check
- test_tier1
- test_tier2
- test_tier2_vm
- verify_build
- ctest_msrv
- docs
- clippy
# GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
# dependencies fails.
if: always() # make sure this is never "skipped"
steps:
# Manually check the status of all dependencies. `if: failure()` does not work.
- name: check if any dependency failed
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'