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
name: CI
on:
pull_request:
branches:
# A new push to a PR cancels the run still going for the previous push, so a
# superseded commit doesn't keep ~200 job-minutes of runners busy.
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
FOUNDRY_VERSION: v1.7.1
# Layout (V2-1811). Each piece of work runs once, in the job that needs that
# build, and `CI Gate` is the single "is this PR green" check:
# quick-checks fmt, clippy, docs, the no-default-features lib check
# msrv the declared minimum toolchain
# notices THIRD-PARTY-NOTICES.txt generation
# test (3 OS) every lib, bin and integration test target; Linux also runs
# the doc tests, the ignored five-node devnet test and the lib
# tests without default features
# filesystems the storage tests on ext4, XFS and btrfs
# build-release the shipped Linux binary, built exactly as release.yml does
jobs:
quick-checks:
name: Quick checks
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
# Compile without cfg(test) too: browser unit tests can otherwise hide
# unused helpers whose production callers require webrtc-direct.
- name: Check library without default features
run: cargo check --lib --no-default-features --locked
- name: Documentation
run: cargo doc --all-features --no-deps
env:
RUSTDOCFLAGS: "-D warnings"
msrv:
name: Rust 1.95 MSRV
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.95.0
- uses: Swatinem/rust-cache@v2
- run: cargo check --all-targets --all-features --locked
# The release workflow ships THIRD-PARTY-NOTICES.txt in every archive.
# Generating it on each pull request catches a dependency that ships no
# licence text, or a new crate that compiles bundled C code, before release.
notices:
name: Third-party notices
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Generate THIRD-PARTY-NOTICES.txt
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
python scripts/third_party_notices/generate.py
--config scripts/third_party_notices/config.toml
--output THIRD-PARTY-NOTICES.txt
--target x86_64-unknown-linux-musl
--target aarch64-unknown-linux-musl
--target x86_64-apple-darwin
--target aarch64-apple-darwin
--target x86_64-pc-windows-msvc
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
os:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: ${{ env.FOUNDRY_VERSION }}
- name: Unit tests (lib and bins)
run: cargo test --lib --bins --features test-utils
# Build every integration test binary in one cargo invocation, so they compile
# and link in parallel. When each target was built in its own step, each spent
# 2-5 minutes building its binary for tests that finish in under a second.
- name: Build integration test binaries
shell: bash
run: cargo test --test '*' --features test-utils --no-run
# Every integration target Cargo knows about, read from `cargo metadata`,
# so a new tests/*.rs runs without anyone editing this file. Each target
# runs on its own, serially, and must pass at least one test: a target
# whose required features are not passed is skipped with a warning and a
# zero exit, and a cfg can compile a target down to nothing, so "exit 0"
# alone doesn't show that anything ran. All targets run even after one
# fails, and the step fails at the end listing them.
- name: Integration tests (every target)
shell: bash
run: |
# GitHub runs `shell: bash` with -e; turn it off so one failing target
# doesn't stop the rest from running.
set +e -uo pipefail
targets=$(cargo metadata --no-deps --format-version 1 \
| jq -r '.packages[] | select(.name == "ant-node") | .targets[] | select(.kind | index("test")) | .name' | tr -d '\r')
echo "integration targets: $(echo $targets)"
[ -n "$targets" ] || { echo "cargo metadata listed no integration targets"; exit 1; }
failed=""
for t in $targets; do
extra=""
if [ "$t" = devnet_lifecycle ] && [ "$RUNNER_OS" = Windows ]; then
# It stops ant-devnet with SIGTERM and SIGKILL, so it is Unix
# only, and compiles to nothing on Windows.
echo "skipping $t on $RUNNER_OS (Unix only)"
continue
fi
if [ "$t" = storage_scale ]; then
# Its gates compare the store scan against timed directory walks, and
# were measured on Linux; it has only ever run there.
if [ "$RUNNER_OS" != Linux ]; then
echo "skipping $t on $RUNNER_OS (Linux only)"
continue
fi
# Prints the measured index memory and inode cost, which is the point of it.
extra="--nocapture"
fi
echo "::group::$t"
cargo test --test "$t" --features test-utils -- --test-threads=1 $extra 2>&1 | tee "/tmp/$t.log"
status=${PIPESTATUS[0]}
echo "::endgroup::"
if [ "$status" -ne 0 ]; then
failed="$failed $t"
elif ! grep -qE 'test result: ok\. [1-9][0-9]* passed' "/tmp/$t.log"; then
echo "::error::$t ran no tests"
failed="$failed $t(ran-nothing)"
fi
done
if [ -n "$failed" ]; then
echo "::error::failing integration targets:$failed"
exit 1
fi
- name: Doc tests
if: runner.os == 'Linux'
run: cargo test --doc --all-features
- name: WebRTC Direct five-node devnet (ignored by default)
if: runner.os == 'Linux'
run: >-
cargo test --test webrtc_direct_devnet --features test-utils
-- --ignored --test-threads=1
- name: Unit tests without default features (no logging, no webrtc-direct)
if: runner.os == 'Linux'
run: cargo test --lib --no-default-features
# The run-directory tests that mount a tmpfs and bind mounts inside run
# directories, make directories another user owns, or act as another
# user. They need root, which the runner gives through sudo, so
# `cargo test` alone skips them.
- name: ant-devnet run directories against real mounts and other users
if: runner.os == 'Linux'
shell: bash
run: |
set -euo pipefail
cargo test --lib --features test-utils with_sudo_ -- --ignored --test-threads=1 2>&1 | tee /tmp/run_dir_sudo.log
grep -qE 'test result: ok\. [1-9]' /tmp/run_dir_sudo.log \
|| { echo 'the run-directory sudo tests ran nothing'; exit 1; }
filesystems:
name: Storage on ${{ matrix.fs }}
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
fs:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install the filesystem tools
run: sudo apt-get update && sudo apt-get install -y xfsprogs btrfs-progs
- name: Make a ${{ matrix.fs }} volume and mount it
shell: bash
run: |
set -euo pipefail
# A loopback image, so these run on a filesystem of the right kind rather than
# on whatever the runner happens to give us. ext4 is what most of the fleet is
# on; XFS and btrfs are the two the design reasons about separately, btrfs
# because it has been observed reordering writes around a rename.
# 3 GiB is ample: these tests use tens of MiB.
truncate -s 3G /tmp/${{ matrix.fs }}.img
mkfs.${{ matrix.fs }} -q /tmp/${{ matrix.fs }}.img
sudo mkdir -p /mnt/antfs
sudo mount -o loop /tmp/${{ matrix.fs }}.img /mnt/antfs
sudo chown "$USER" /mnt/antfs
df -hT /mnt/antfs
# TMPDIR is what `TempDir::new` uses, so this puts every temporary store these tests
# build on the mounted filesystem rather than on the runner's root.
#
# These used to be the migration harnesses. The migration is gone, and what is left
# worth asking of a filesystem is what the store itself does on it: publish a chunk
# through a temporary and a rename, flush the directory, unlink it again, and rebuild
# an index from the names afterwards. The storage tests do all of that, and running
# them here is what keeps ext4, XFS and btrfs covered now that the harnesses that used
# to cover them have been deleted. They do not measure free space before and after;
# the harness that did was about the migration and went with it.
- name: Storage behaviour on ${{ matrix.fs }}
env:
TMPDIR: /mnt/antfs
shell: bash
run: |
set -euo pipefail
cargo test --lib --features test-utils storage:: 2>&1 | tee /tmp/storage.log
grep -qE 'test result: ok\. [1-9]' /tmp/storage.log \
|| { echo 'the storage tests ran nothing'; exit 1; }
# PR CI used to build `--release --no-default-features` on three OSes, a
# configuration nobody ships. This builds the Linux x64 archive's binary the
# way release.yml does (default features, musl, via cross), so a dependency
# that breaks under musl or cross shows up on the PR rather than at the tag.
# The test jobs already compile default features on macOS and Windows.
build-release:
name: Build release (x86_64-unknown-linux-musl)
runs-on: ubuntu-22.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
- uses: Swatinem/rust-cache@v2
with:
key: x86_64-unknown-linux-musl
- name: Install cross (as release.yml does)
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build
run: cross build --release --target x86_64-unknown-linux-musl
# The crash harness drives the store through a failpoint that parks the process
# forever on an environment variable, and the store's own tests use the same one. It
# is compiled only under `test-utils`, which is not a default feature and is not
# passed by the release workflow, so a shipped binary does not contain it. This proves
# that on the binary that ships rather than trusting it: the variable name is a string
# literal, so it survives into the binary (stripping removes symbols, not string data)
# whenever the code that reads it is compiled, and its absence is the absence of the
# failpoint. The exact number is one per failpoint and is deliberately not asserted,
# so that adding a failpoint does not fail this check.
- name: The shipped binary carries no failpoint
shell: bash
run: |
set -euo pipefail
bin=target/x86_64-unknown-linux-musl/release/ant-node
ls -la "$bin"
found=$(strings -a "$bin" | grep -c 'ANT_HALT_' || true)
if [ "$found" != "0" ]; then
echo "the publish failpoint is compiled into the release build"
exit 1
fi
echo "no failpoint in the release build"
# Kept outside CI Gate until V2-1800 settles how advisories are handled: an
# advisory comes from the RustSec database, not from the PR, so today this
# reds every PR (RUSTSEC-2026-0387, V2-1743).
security:
name: Security Audit
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-audit
run: cargo install cargo-audit
- name: Run security audit
run: cargo audit
# The single check that says whether a PR is green. It fails unless every job
# it needs succeeded; a skipped or cancelled job counts as a failure.
gate:
name: CI Gate
if: always()
needs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Every required job succeeded
env:
NEEDS: ${{ toJSON(needs) }}
run: |
echo "$NEEDS" | jq -r 'to_entries[] | "\(.key): \(.value.result)"'
echo "$NEEDS" | jq -e 'to_entries | all(.value.result == "success")' > /dev/null