name: CI on: pull_request: types: ["labeled", "unlabeled", "opened", "synchronize", "reopened"] merge_group: push: branches: - main concurrency: group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true env: RUST_BACKTRACE: 1 RUSTFLAGS: -Dwarnings RUSTDOCFLAGS: -Dwarnings MSRV: "1.91" SCCACHE_CACHE_SIZE: "10G" IROH_FORCE_STAGING_RELAYS: "1" # Default to read-only; jobs that need more grant it explicitly. permissions: contents: read jobs: tests: name: CI Test Suite if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')" uses: "$/.github/workflows/tests.yaml" min-crates: name: Min Crates uses: "n0-computer/workflows/.github/workflows/minimal-crates.yaml@v1" cross_build: name: Cross Build Only if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')" timeout-minutes: 30 runs-on: blacksmith-8vcpu-ubuntu-2404 env: RUSTFLAGS: "-Dwarnings --cfg skip_patchbay" strategy: fail-fast: false matrix: target: # cross tests are currently broken vor armv7 and aarch64 # see https://github.com/cross-rs/cross/issues/1311 # - armv7-linux-androideabi # - aarch64-linux-android # Freebsd execution fails in cross # - i686-unknown-freebsd # Linking fails :/ - x86_64-unknown-freebsd # Netbsd execution fails to link in cross # - x86_64-unknown-netbsd steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false submodules: recursive - name: Install rust stable uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1 with: toolchain: stable - name: Cleanup Docker continue-on-error: true run: | docker kill $(docker ps -q) # See https://github.com/cross-rs/cross/issues/1222 - name: Cache cross id: cache-cross uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.cargo/bin/cross key: cross-${{ runner.os }}-${{ runner.arch }} - name: Install cross if: steps.cache-cross.outputs.cache-hit != 'true' uses: taiki-e/install-action@f7e5d7c961414b23f5b25b2da9294395d08513ad # v2.87.26 with: tool: cross - name: build # cross tests are currently broken vor armv7 and aarch64 # see https://github.com/cross-rs/cross/issues/1311. So on # those platforms we only build but do not run tests. run: cross build --all --target ${{ matrix.target }} env: RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}} CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: cc android: name: Android Build & Test if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')" timeout-minutes: 30 runs-on: [self-hosted, linux, X64] strategy: fail-fast: false matrix: include: - target: aarch64-linux-android - target: armv7-linux-androideabi - target: x86_64-linux-android api-level: 35 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Enable KVM for nested virtualization if: matrix.target == 'x86_64-linux-android' run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666"' \ | sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm - name: Set up Rust uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1 with: toolchain: stable target: ${{ matrix.target }} - name: Setup Java uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1 with: distribution: "temurin" java-version: "17" - name: Setup Android SDK uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4.0.4 # Pinned to a release tag (rather than @main) for supply-chain hygiene. - name: Setup Android NDK uses: nttld/setup-ndk@ed92fe6cadad69be94a966a7ee3271275e62f779 # v1.6.0 id: setup-ndk with: ndk-version: r25c add-to-path: true - name: Install cargo-ndk run: cargo install --locked --version 4.1.2 cargo-ndk # Replace cargo-ndk-runner with a wrapper that forwards RUST_LOG # and RUST_BACKTRACE into the emulator shell. The upstream binary # does `adb shell ` without inheriting any host env. # # The wrapper also removes each binary from the guest once it has run. # A full run pushes ~1.25GB of debug test binaries into /data/local/tmp # and the guest data partition is only ~5.8GB, so leaving them behind # accumulates across jobs (see the sweep in the emulator script below). - name: Wrap cargo-ndk-runner to forward logging env if: matrix.target == 'x86_64-linux-android' run: | cat > "$(which cargo-ndk-runner)" <<'WRAPPER' #!/bin/sh set -e dev=/data/local/tmp/$(basename "$1") adb push "$1" "$dev" >/dev/null adb shell chmod 755 "$dev" shift set +e adb shell "RUST_LOG=$RUST_LOG RUST_BACKTRACE=$RUST_BACKTRACE $dev $*" rc=$? adb shell rm -f "$dev" >/dev/null 2>&1 exit $rc WRAPPER chmod +x "$(which cargo-ndk-runner)" - name: Build if: matrix.target != 'x86_64-linux-android' env: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} run: cargo ndk --target ${{ matrix.target }} build --locked # Build all the test binaries up front so the emulator boot can # overlap with compilation. cargo-ndk runs `cargo test --no-run` # against each crate; the binaries land in # target/$CARGO_NDK_TARGET/debug/deps/. - name: Build workspace test binaries if: matrix.target == 'x86_64-linux-android' env: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} CARGO_NDK_TARGET: ${{ matrix.target }} run: | cargo ndk test --locked --no-run -p iroh-base --all-features cargo ndk test --locked --no-run -p iroh-dns --features tls-ring cargo ndk test --locked --no-run -p iroh-relay --features tls-ring,metrics cargo ndk test --locked --no-run -p iroh --features tls-ring,metrics,portmapper,test-utils - name: Run workspace tests on Android emulator if: matrix.target == 'x86_64-linux-android' timeout-minutes: 30 uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 env: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} # Forwarded into the emulator by the cargo-ndk-runner wrapper. RUST_LOG: trace RUST_BACKTRACE: "1" CARGO_NDK_TARGET: ${{ matrix.target }} with: api-level: ${{ matrix.api-level }} arch: x86_64 target: google_apis force-avd-creation: false # `-dns-server` + `-netfast` + `-no-metrics` is the combination reported to give # working public-internet connectivity on the GH-hosted runner; without them wlan0 # stays NO-CARRIER and every connect() to a public IP fails with ENETUNREACH. # See https://github.com/ReactiveCircus/android-emulator-runner/issues/348#issuecomment-2578082030 # # `-no-snapshot`: on persistent self-hosted runners the AVD survives between jobs, # so the emulator quickboot-resumes from the previous run's snapshot. Resumed guests # have broken networking (UDP DNS times out), failing DNS tests. Always cold boot # and never save state. emulator-options: -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -dns-server 8.8.8.8 -netfast -no-metrics -no-snapshot disable-animations: true script: | adb wait-for-device # Wait for full boot and a working outbound TCP. `sys.boot_completed=1` fires # before the radio/Wi-Fi stack comes up, and `ip route get 8.8.8.8` reports # success while the kernel's per-network fwmark route is still missing. Probe # an actual TCP connect to 8.8.8.8:53 instead - it exercises the same path # the test sockets will use. adb shell 'i=0; while [ -z "$(getprop sys.boot_completed | tr -d "\r")" ]; do i=$((i+1)); if [ $i -gt 300 ]; then exit 1; fi; sleep 2; done' adb shell 'i=0; while ! nc -w 2 8.8.8.8 53 /dev/null 2>&1; do i=$((i+1)); if [ $i -gt 30 ]; then exit 1; fi; sleep 2; done' # Disable IPv6: the emulator has site-local + link-local v6 but no global v6 # route, so connect() to a global v6 address hangs instead of returning ENETUNREACH. adb root && adb wait-for-device adb shell sysctl -w net.ipv6.conf.all.disable_ipv6=1 || true adb shell sysctl -w net.ipv6.conf.default.disable_ipv6=1 || true adb shell sysctl -w net.ipv6.conf.lo.disable_ipv6=1 || true adb shell ip addr # Sweep leftover test binaries out of the guest. `force-avd-creation: false` # keeps the AVD between jobs, and `-no-snapshot` only disables the *RAM* # quickboot snapshot - the userdata qcow2 overlay still persists on disk. A # job that is cancelled or times out leaves its pushed binaries behind, so # without this they accumulate until /data (~5.8G) fills and every `adb push` # fails with ENOSPC. The runner wrapper deletes binaries as it goes; this # catches what it could not. adb shell 'rm -rf /data/local/tmp/*' || true adb shell df -h /data cargo ndk test --locked -p iroh-base --all-features cargo ndk test --locked -p iroh-dns --features tls-ring cargo ndk test --locked -p iroh-relay --features tls-ring,metrics cargo ndk test --locked -p iroh --features tls-ring,metrics,portmapper,test-utils cross_test: name: Cross Test if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')" timeout-minutes: 30 runs-on: blacksmith-8vcpu-ubuntu-2404 strategy: fail-fast: false matrix: target: - i686-unknown-linux-gnu env: RUSTFLAGS: "-Dwarnings --cfg skip_patchbay" steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false submodules: recursive - name: Install rust stable uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1 with: toolchain: stable - name: Cleanup Docker continue-on-error: true run: | docker kill $(docker ps -q) # See https://github.com/cross-rs/cross/issues/1222 - name: Cache cross id: cache-cross uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.cargo/bin/cross key: cross-${{ runner.os }}-${{ runner.arch }} - name: Install cross if: steps.cache-cross.outputs.cache-hit != 'true' uses: taiki-e/install-action@f7e5d7c961414b23f5b25b2da9294395d08513ad # v2.87.26 with: tool: cross - name: test run: cross test --all --target ${{ matrix.target }} -- --test-threads=12 env: RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG' }} CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: cc wasm_test: name: Build & test wasm32 for browsers runs-on: blacksmith-8vcpu-ubuntu-2404 env: RUSTFLAGS: '--cfg getrandom_backend="wasm_js"' steps: - name: Checkout sources uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup node.js version 22.5 # needed for browser-like websocket API support in node.js uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 22.5 - name: Install stable toolchain uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1 with: toolchain: stable - name: Add wasm target run: rustup target add wasm32-unknown-unknown - name: Install wasm-bindgen-test-runner uses: taiki-e/install-action@f7e5d7c961414b23f5b25b2da9294395d08513ad # v2.87.26 with: # Match the version of wasm-bindgen used in Cargo.lock tool: wasm-bindgen-cli@0.2.128 - name: Install wasm-tools uses: bytecodealliance/actions/wasm-tools/setup@9152e710e9f7182e4c29ad218e4f335a7b203613 # v1.1.3 - name: wasm32 build (iroh-base) run: cargo build --locked --target wasm32-unknown-unknown -p iroh-base --all-features - name: wasm32 build (iroh-relay) run: cargo build --locked --target wasm32-unknown-unknown -p iroh-relay - name: wasm32 build (iroh) run: cargo build --locked --target wasm32-unknown-unknown -p iroh # If the Wasm file contains any 'import "env"' declarations, then # some non-Wasm-compatible code made it into the final code. - name: Ensure no 'import "env"' in iroh-relay Wasm run: | ! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/iroh_relay.wasm | grep 'import "env"' - name: Ensure no 'import "env"' in iroh Wasm run: | ! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/iroh.wasm | grep 'import "env"' - name: Run integration test in wasm run: cargo test --locked -p iroh --test integration --target=wasm32-unknown-unknown check_semver: runs-on: blacksmith-8vcpu-ubuntu-2404 env: RUSTC_WRAPPER: "sccache" SCCACHE_GHA_ENABLED: "on" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false fetch-depth: 0 - name: Install sccache uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11 continue-on-error: true - uses: $/.github/workflows/sccache-probe - name: Check semver # uses: obi1kenobi/cargo-semver-checks-action@6b69fcf40e9b5fb17adeb57e4b6ecd020649a239 # v2 uses: n0-computer/cargo-semver-checks-action@b49de9133f8849bb51cae32c6bdeb19a5c37e61f # feat-baseline with: package: iroh, iroh-base, iroh-dns, iroh-dns-server, iroh-relay check_external_types: timeout-minutes: 30 name: Check external types in public API if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')" runs-on: blacksmith-8vcpu-ubuntu-2404 env: RUSTC_WRAPPER: "sccache" SCCACHE_GHA_ENABLED: "on" # The tool drives an internal rustdoc invocation that only emits JSON # for the analyzer, so the workflow-wide `-Dwarnings` would just turn # unrelated rustdoc lints (e.g. `private-intra-doc-links`) into hard # failures here. Clear it for this job. RUSTDOCFLAGS: "" # Pin to the nightly that the pinned `cargo-check-external-types` # release was last tested against. Update both together. CARGO_CHECK_EXTERNAL_TYPES_VERSION: "0.5.0" TOOLCHAIN: "nightly-2026-03-20" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1 with: toolchain: ${{ env.TOOLCHAIN }} - name: Install sccache uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11 - name: Install cargo-check-external-types uses: taiki-e/install-action@f7e5d7c961414b23f5b25b2da9294395d08513ad # v2.87.26 with: tool: | cargo-make cargo-check-external-types@${{ env.CARGO_CHECK_EXTERNAL_TYPES_VERSION }} - name: Check external types run: cargo make check-external-types - name: Lockfile must not have moved # cargo make takes no --locked; assert the lockfile instead. run: git diff --exit-code Cargo.lock check_fmt: timeout-minutes: 30 name: Checking fmt runs-on: ubuntu-latest env: RUSTC_WRAPPER: "sccache" SCCACHE_GHA_ENABLED: "on" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1 with: toolchain: stable components: rustfmt - uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11 continue-on-error: true - uses: $/.github/workflows/sccache-probe - uses: taiki-e/install-action@f7e5d7c961414b23f5b25b2da9294395d08513ad # v2.87.26 with: tool: cargo-make - run: cargo make format-check - name: Lockfile must not have moved # cargo make takes no --locked; assert the lockfile instead. run: git diff --exit-code Cargo.lock check_docs: timeout-minutes: 30 name: Checking docs runs-on: blacksmith-8vcpu-ubuntu-2404 env: RUSTC_WRAPPER: "sccache" SCCACHE_GHA_ENABLED: "on" RUSTDOCFLAGS: --cfg docsrs steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1 with: toolchain: nightly-2025-10-09 - name: Install sccache uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11 continue-on-error: true - uses: $/.github/workflows/sccache-probe - name: Docs run: cargo doc --locked --workspace --all-features --no-deps --document-private-items clippy_check: timeout-minutes: 30 runs-on: blacksmith-8vcpu-ubuntu-2404 env: RUSTC_WRAPPER: "sccache" SCCACHE_GHA_ENABLED: "on" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1 with: toolchain: stable components: clippy - name: Install sccache uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11 continue-on-error: true - uses: $/.github/workflows/sccache-probe # TODO: We have a bunch of platform-dependent code so should # probably run this job on the full platform matrix - name: clippy check (all features) run: cargo clippy --locked --workspace --all-features --all-targets --lib --bins --tests --benches --examples - name: clippy check (no features) run: cargo clippy --locked --workspace --no-default-features --all-targets --lib --bins --tests --benches --examples - name: clippy check (default features) run: cargo clippy --locked --workspace --all-targets --lib --bins --tests --benches --examples check_optional_deps: timeout-minutes: 10 name: Check optional deps are absent without features runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1 with: toolchain: stable - name: Verify optional deps are absent without features run: | fail=0 for dep in portmapper igd-next swarm-discovery ring aws-lc-rs; do echo "cargo tree --locked -p iroh --no-default-features --edges normal --target all -i $dep"; output=$(cargo tree --locked -p iroh --no-default-features --edges normal --target all -i "$dep" 2>&1) || true if ! echo "$output" | grep -qE "(nothing to print|did not match any packages)"; then echo "ERROR: $dep should not be in the dependency tree without its feature" echo "$output" fail=1 fi done exit $fail msrv: if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')" timeout-minutes: 30 name: Minimal Supported Rust Version runs-on: blacksmith-8vcpu-ubuntu-2404 env: RUSTC_WRAPPER: "sccache" SCCACHE_GHA_ENABLED: "on" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1 with: toolchain: ${{ env.MSRV }} - name: Install sccache uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11 continue-on-error: true - uses: $/.github/workflows/sccache-probe - name: Check MSRV all features run: | cargo +$MSRV check --locked --workspace --all-targets cargo_deny: timeout-minutes: 30 name: cargo deny runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2.1.1 with: arguments: --workspace --all-features command: check command-arguments: "-Dwarnings" netsim-integration-tests: permissions: contents: read pull-requests: write # netsim_runner posts the report comment if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')" uses: "$/.github/workflows/netsim_runner.yaml" secrets: S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }} S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} S3_BUCKET: ${{ secrets.S3_BUCKET }} S3_REPORT_BUCKET: ${{ secrets.S3_REPORT_BUCKET }} METRO_TOKEN: ${{ secrets.METRO_TOKEN }} METRO_ENDPOINT: ${{ secrets.METRO_ENDPOINT }} with: branch: ${{ github.ref }} max_workers: 6 netsim_branch: "main" sim_paths: ${{ github.event_name == 'pull_request' && 'sims/integration' || 'sims/iroh/iroh.json,sims/integration' }} pr_number: ${{ github.event.pull_request.number || '' }} filter: ${{ github.event_name == 'pull_request' && 'skip:intg_iroh_full__1_to_3,intg_iroh_full__1_to_1x3,intg_iroh_relay_only__1_to_3' || '' }} codespell: timeout-minutes: 30 runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Cache pip uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.cache/pip key: pip-codespell-2.4.1 - run: pip install --user codespell[toml]==2.4.1 - run: codespell --ignore-words-list=ans,atmost,crate,inout,ratatui,ser,stayin,swarmin,worl,keep-alives --skip=CHANGELOG.md