Skip to content

Commit 9714d4d

Browse files
committed
More
1 parent 3b15a9b commit 9714d4d

13 files changed

Lines changed: 450 additions & 11 deletions

File tree

.github/workflows/check-mtu.yml

Lines changed: 368 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,368 @@
1+
name: Check
2+
on:
3+
push:
4+
branches: ["main"]
5+
pull_request:
6+
branches: ["main"]
7+
merge_group:
8+
env:
9+
CARGO_TERM_COLOR: always
10+
RUST_BACKTRACE: 1
11+
RUST_TEST_TIME_UNIT: 10,30
12+
RUST_TEST_TIME_INTEGRATION: 10,30
13+
RUST_TEST_TIME_DOCTEST: 10,30
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref_name }}
17+
cancel-in-progress: true
18+
19+
permissions:
20+
contents: read
21+
22+
defaults:
23+
run:
24+
shell: bash
25+
working-directory: mtu # Run all checks in the mtu directory
26+
27+
jobs:
28+
toolchains:
29+
name: Determine toolchains
30+
runs-on: ubuntu-24.04
31+
outputs:
32+
toolchains: ${{ steps.toolchains.outputs.toolchains }}
33+
steps:
34+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+
with:
36+
sparse-checkout: Cargo.toml
37+
persist-credentials: false
38+
- id: toolchains
39+
run: |
40+
msrv="$(grep rust-version Cargo.toml | tr -d '"' | cut -f3 -d\ )"
41+
echo "toolchains=[\"$msrv\", \"stable\", \"nightly\"]" >> "$GITHUB_OUTPUT"
42+
43+
check:
44+
name: Check code
45+
needs: toolchains
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15, windows-2025]
50+
rust-toolchain: ${{ fromJSON(needs.toolchains.outputs.toolchains) }}
51+
type: [debug]
52+
include:
53+
# Also do some release builds on the latest OS versions.
54+
- os: ubuntu-24.04
55+
rust-toolchain: stable
56+
type: release
57+
- os: macos-15
58+
rust-toolchain: stable
59+
type: release
60+
- os: windows-2025
61+
rust-toolchain: stable
62+
type: release
63+
# Also do some debug builds on the oldest OS versions.
64+
- os: ubuntu-22.04
65+
rust-toolchain: stable
66+
type: debug
67+
- os: macos-13
68+
rust-toolchain: stable
69+
type: debug
70+
- os: windows-2022
71+
rust-toolchain: stable
72+
type: debug
73+
env:
74+
BUILD_TYPE: ${{ matrix.type == 'release' && '--release' || '' }}
75+
runs-on: ${{ matrix.os }}
76+
77+
steps:
78+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
79+
with:
80+
persist-credentials: false
81+
82+
- uses: .github/actions/rust
83+
with:
84+
version: ${{ matrix.rust-toolchain }}
85+
components: ${{ matrix.rust-toolchain == 'nightly' && 'llvm-tools' || '' }} ${{ matrix.rust-toolchain == 'nightly' && 'rust-src' || '' }}
86+
tools: ${{ matrix.rust-toolchain == 'nightly' && 'cargo-llvm-cov, ' || '' }}
87+
token: ${{ secrets.GITHUB_TOKEN }}
88+
89+
- name: Check
90+
run: |
91+
OPTIONS=(--all-targets)
92+
if [ "$BUILD_TYPE" ]; then
93+
OPTIONS+=("$BUILD_TYPE")
94+
fi
95+
cargo check "${OPTIONS[@]}"
96+
97+
- name: Run tests and determine coverage
98+
env:
99+
RUST_LOG: trace
100+
TOOLCHAIN: ${{ matrix.rust-toolchain }}
101+
WINDOWS: ${{ startsWith(matrix.os, 'windows') && 'windows' || '' }}"
102+
TYPE: ${{ matrix.type }}
103+
run: |
104+
OPTIONS=(--no-fail-fast)
105+
if [ "$BUILD_TYPE" ]; then
106+
OPTIONS+=("$BUILD_TYPE")
107+
fi
108+
if [ "$TOOLCHAIN" == "nightly" ] && [ "$TYPE" == "debug" ]; then
109+
cargo llvm-cov test --mcdc --include-ffi "${OPTIONS[@]}" --codecov --output-path codecov.json
110+
else
111+
if [ "$WINDOWS" == "windows" ]; then
112+
# The codegen_windows_bindings test only succeeds when run via llvm-cov?!
113+
OPTIONS+=(-- --skip codegen_windows_bindings)
114+
fi
115+
cargo test "${OPTIONS[@]}"
116+
fi
117+
cargo bench --no-run
118+
119+
- uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
120+
with:
121+
files: codecov.json
122+
fail_ci_if_error: false
123+
token: ${{ secrets.CODECOV_TOKEN }}
124+
verbose: true
125+
env:
126+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
127+
if: matrix.type == 'debug' && matrix.rust-toolchain == 'nightly'
128+
129+
- name: Run tests with sanitizers
130+
if: (matrix.os == 'ubuntu-24.04' || matrix.os == 'macos-15') && matrix.rust-toolchain == 'nightly'
131+
env:
132+
RUST_LOG: trace
133+
ASAN_OPTIONS: detect_leaks=1:detect_stack_use_after_return=1
134+
OS: ${{ matrix.os }}
135+
run: |
136+
if [ "$OS" = "ubuntu-24.04" ]; then
137+
sudo apt-get install -y --no-install-recommends llvm
138+
TARGET="x86_64-unknown-linux-gnu"
139+
SANITIZERS="address thread leak memory"
140+
elif [ "$OS" = "macos-15" ]; then
141+
# llvm-symbolizer (as part of llvm) is installed by default on macOS runners
142+
TARGET="aarch64-apple-darwin"
143+
# no memory and leak sanitizer support yet
144+
SANITIZERS="address thread"
145+
# Suppress non-mtu leaks on macOS. TODO: Check occasionally if these are still needed.
146+
{
147+
echo "leak:dyld4::RuntimeState"
148+
echo "leak:fetchInitializingClassList"
149+
echo "leak:std::rt::lang_start_internal"
150+
} > suppressions.txt
151+
# shellcheck disable=SC2155
152+
export LSAN_OPTIONS="suppressions=$(pwd)/suppressions.txt"
153+
fi
154+
for sanitizer in $SANITIZERS; do
155+
echo "Running tests with $sanitizer sanitizer..."
156+
export RUSTFLAGS="-Z sanitizer=$sanitizer"
157+
export RUSTDOCFLAGS="$RUSTFLAGS"
158+
cargo +nightly test -Z build-std --target "$TARGET"
159+
done
160+
161+
162+
check-vm:
163+
name: Check on VMs
164+
strategy:
165+
fail-fast: false
166+
matrix:
167+
os: [freebsd, openbsd, netbsd, solaris]
168+
runs-on: ubuntu-24.04
169+
env:
170+
RUST_LOG: trace
171+
172+
steps:
173+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
174+
with:
175+
persist-credentials: false
176+
- run: curl -o rustup.sh --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs
177+
178+
- if: matrix.os == 'freebsd'
179+
uses: vmactions/freebsd-vm@966989c456d41351f095a421f60e71342d3bce41 # v1.2.1
180+
with:
181+
usesh: true
182+
envs: "CARGO_TERM_COLOR RUST_BACKTRACE RUST_LOG GITHUB_ACTIONS RUST_TEST_TIME_UNIT RUST_TEST_TIME_INTEGRATION RUST_TEST_TIME_DOCTEST"
183+
prepare: | # This executes as root
184+
set -e
185+
pkg install -y curl llvm
186+
run: | # This executes as user
187+
set -e
188+
sh rustup.sh --default-toolchain nightly --profile minimal --component clippy,llvm-tools -y
189+
. "$HOME/.cargo/env"
190+
cargo check --all-targets
191+
cargo clippy -- -D warnings
192+
cargo install cargo-llvm-cov --locked
193+
cargo llvm-cov test --mcdc --include-ffi --no-fail-fast --codecov --output-path codecov.json
194+
cargo test --no-fail-fast --release
195+
rm -rf target # Don't sync this back to host
196+
197+
- if: matrix.os == 'openbsd'
198+
uses: vmactions/openbsd-vm@0d65352eee1508bab7cb12d130536d3a556be487 # v1.1.8
199+
with:
200+
usesh: true
201+
envs: "CARGO_TERM_COLOR RUST_BACKTRACE RUST_LOG GITHUB_ACTIONS RUST_TEST_TIME_UNIT RUST_TEST_TIME_INTEGRATION RUST_TEST_TIME_DOCTEST"
202+
prepare: | # This executes as root
203+
set -e
204+
# TODO: Is there a way to not pin the version of llvm? -z to pkg_add doesn't work.
205+
pkg_add rust rust-clippy llvm-19.1.7p3 # rustup doesn't support OpenBSD at all
206+
run: | # This executes as user
207+
set -e
208+
export LIBCLANG_PATH=/usr/local/llvm19/lib
209+
cargo check --all-targets
210+
cargo clippy -- -D warnings
211+
# FIXME: No profiler support in openbsd currently, error is:
212+
# > error[E0463]: can't find crate for `profiler_builtins`
213+
# > = note: the compiler may have been built without the profiler runtime
214+
# export LLVM_COV=/usr/local/llvm19/bin/llvm-cov
215+
# export LLVM_PROFDATA=/usr/local/llvm19/bin/llvm-profdata
216+
# cargo install cargo-llvm-cov --locked
217+
# cargo llvm-cov test --mcdc --include-ffi --no-fail-fast --codecov --output-path codecov.json
218+
cargo test --no-fail-fast # Remove this once profiler is supported
219+
cargo test --no-fail-fast --release
220+
rm -rf target # Don't sync this back to host
221+
222+
- if: matrix.os == 'netbsd'
223+
uses: vmactions/netbsd-vm@46a58bbf03682b4cb24142b97fa315ae52bed573 # v1.1.8
224+
with:
225+
usesh: true
226+
envs: "CARGO_TERM_COLOR RUST_BACKTRACE RUST_LOG GITHUB_ACTIONS RUST_TEST_TIME_UNIT RUST_TEST_TIME_INTEGRATION RUST_TEST_TIME_DOCTEST"
227+
prepare: | # This executes as root
228+
set -e
229+
/usr/sbin/pkg_add pkgin
230+
pkgin -y install curl clang
231+
run: | # This executes as user
232+
set -e
233+
sh rustup.sh --default-toolchain nightly --profile minimal --component clippy,llvm-tools -y
234+
. "$HOME/.cargo/env"
235+
cargo check --all-targets
236+
cargo clippy -- -D warnings
237+
# FIXME: No profiler support in netbsd currently, error is:
238+
# > error[E0463]: can't find crate for `profiler_builtins`
239+
# > = note: the compiler may have been built without the profiler runtime
240+
# cargo install cargo-llvm-cov --locked
241+
# cargo llvm-cov test --mcdc --include-ffi --no-fail-fast --codecov --output-path codecov.json
242+
cargo test --no-fail-fast # Remove this once profiler is supported
243+
cargo test --no-fail-fast --release
244+
rm -rf target # Don't sync this back to host
245+
246+
- if: matrix.os == 'solaris'
247+
uses: vmactions/solaris-vm@170f1f96f376cf7467cc41627e0c7590932fccaa # v1.1.4
248+
with:
249+
release: "11.4-gcc"
250+
usesh: true
251+
envs: "CARGO_TERM_COLOR RUST_BACKTRACE RUST_LOG GITHUB_ACTIONS RUST_TEST_TIME_UNIT RUST_TEST_TIME_INTEGRATION RUST_TEST_TIME_DOCTEST"
252+
prepare: | # This executes as root
253+
set -e
254+
pkg install clang-libs
255+
run: | # This executes as also as root on Solaris
256+
set -e
257+
source <(curl -s https://raw.githubusercontent.com/psumbera/solaris-rust/refs/heads/main/sh.rust-web-install) || true # This doesn't exit with zero on success
258+
export LIBCLANG_PATH="/usr/lib/amd64"
259+
cargo check --all-targets
260+
cargo clippy -- -D warnings
261+
# FIXME: No profiler support in openbsd currently, error is:
262+
# > error[E0463]: can't find crate for `profiler_builtins`
263+
# > = note: the compiler may have been built without the profiler runtime
264+
# cargo install cargo-llvm-cov --locked
265+
# cargo llvm-cov test --mcdc --include-ffi --no-fail-fast --codecov --output-path codecov.json
266+
cargo test --no-fail-fast # Remove this once profiler is supported
267+
cargo test --no-fail-fast --release
268+
rm -rf target # Don't sync this back to host
269+
270+
- uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
271+
with:
272+
files: codecov.json
273+
fail_ci_if_error: false
274+
token: ${{ secrets.CODECOV_TOKEN }}
275+
verbose: true
276+
env:
277+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
278+
279+
check-android:
280+
name: Check Android builds
281+
runs-on: ubuntu-24.04
282+
env:
283+
# https://searchfox.org/mozilla-central/search?q=NDK_VERSION =&path=python/mozboot/mozboot/android.py
284+
NDK_VERSION: 27.2.12479018 # r27c
285+
# https://searchfox.org/mozilla-central/search?q=\bapi_level=&path=taskcluster/scripts/misc/build-llvm-common.sh&regexp=true
286+
API_LEVEL: 21
287+
288+
strategy:
289+
matrix:
290+
include:
291+
- target: x86_64-linux-android
292+
emulator-arch: x86_64
293+
# Note that x86_64 image is only available for API 21+. See
294+
# https://github.com/ReactiveCircus/android-emulator-runner?tab=readme-ov-file#configurations.
295+
- target: i686-linux-android
296+
emulator-arch: x86
297+
# FIXME: https://github.com/ReactiveCircus/android-emulator-runner/issues/404
298+
# - target: armv7-linux-androideabi
299+
# emulator-arch: arm64-v8
300+
301+
steps:
302+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
303+
with:
304+
persist-credentials: false
305+
306+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
307+
with:
308+
repository: mozilla/neqo
309+
sparse-checkout: |
310+
.github/actions/rust
311+
path: neqo
312+
persist-credentials: false
313+
314+
- uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
315+
with:
316+
distribution: zulu
317+
java-version: 23
318+
319+
- uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
320+
- env:
321+
NDK_VERSION: ${{ env.NDK_VERSION }}
322+
run: sdkmanager --install "ndk;$NDK_VERSION"
323+
324+
- uses: ./neqo/.github/actions/rust
325+
with:
326+
version: stable
327+
targets: ${{ matrix.target }}
328+
tools: cargo-ndk
329+
token: ${{ secrets.GITHUB_TOKEN }}
330+
331+
- env:
332+
TARGET: ${{ matrix.target }}
333+
run: cargo ndk --bindgen -t "$TARGET" test --no-run
334+
335+
- env:
336+
TARGET: ${{ matrix.target }}
337+
run: |
338+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
339+
sudo udevadm control --reload-rules
340+
sudo udevadm trigger --name-match=kvm
341+
cat <<'EOF' > /tmp/rust-android-run-tests-on-emulator.sh
342+
#!/bin/bash
343+
set -e
344+
adb shell ip addr show
345+
export GITHUB_ACTIONS=1
346+
adb wait-for-device
347+
while [ -z "$(adb shell getprop sys.boot_completed | tr -d '\r')" ]; do sleep 1; done
348+
any_failures=0
349+
for test in $(find target/$TARGET/debug/deps/ -type f -executable ! -name "*.so" -name "*-*"); do
350+
adb push "$test" /data/local/tmp/
351+
adb shell chmod +x /data/local/tmp/$(basename "$test")
352+
# See https://unix.stackexchange.com/a/451140/409256
353+
adb shell "API_LEVEL=$API_LEVEL /data/local/tmp/$(basename "$test") || echo _FAIL_" 2>&1 | tee output
354+
grep _FAIL_ output && any_failures=1
355+
done
356+
exit $any_failures
357+
EOF
358+
chmod a+x /tmp/rust-android-run-tests-on-emulator.sh
359+
360+
- uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0
361+
with:
362+
api-level: ${{ env.API_LEVEL }}
363+
arch: ${{ matrix.emulator-arch == 'arm64-v8' && 'arm64-v8a' || matrix.emulator-arch }}
364+
ndk: ${{ env.NDK_VERSION }}
365+
emulator-boot-timeout: 120
366+
script: /tmp/rust-android-run-tests-on-emulator.sh
367+
env:
368+
TARGET: ${{ matrix.target }}

.github/workflows/check.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
with:
9595
version: ${{ matrix.rust-toolchain }}
9696
components: ${{ matrix.rust-toolchain == 'stable' && 'llvm-tools' || '' }}
97-
tools: ${{ matrix.rust-toolchain == 'stable' && 'cargo-llvm-cov' || '' }}
97+
tools: cargo-hack ${{ matrix.rust-toolchain == 'stable' && ', cargo-llvm-cov' || '' }}
9898
token: ${{ secrets.GITHUB_TOKEN }}
9999

100100
- id: nss-version
@@ -176,7 +176,9 @@ jobs:
176176
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
177177
with:
178178
persist-credentials: false
179-
- run: cargo update -w --locked
179+
- run: |
180+
cargo update -w --locked
181+
cargo hack update -w --locked
180182
181183
check-android:
182184
name: Check Android

0 commit comments

Comments
 (0)