Repository navigation
ci: shared workflows, CI images, hardening (phase 4) #454
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Cargo Build & Test | |
| on: | |
| push: | |
| pull_request: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| # Container jobs default to `sh`; the steps are bash (arrays, mapfile, pipefail). | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # The workspace's toolchain matrix (stable, beta, nightly on ubuntu-24.04), | |
| # stable on the other platforms, and stable on the ubuntu-26.04 canary | |
| # (which may fail without failing the run): the org's reusable workflow. | |
| # `--locked` on every build and test also checks Cargo.lock matches the | |
| # manifests, which a separate `cargo metadata --locked` step used to. | |
| ci: | |
| name: ci | |
| permissions: | |
| contents: read | |
| uses: ComlineProject/.github/.github/workflows/rust-ci.yml@797d473553d7f2fc50895bb2573acb83ac63c7cb # 2026-11-12 | |
| with: | |
| build-args: --locked | |
| test-args: --locked | |
| features: tokio | |
| features-package: comline-runtime | |
| # spec/ is the pinned specification, unchanged, and this runtime's support | |
| # claims and report match its specs. In the tools image, which has cue | |
| # (v0.17.1: keep in step with runtime/conformance/spec/cue.mod/module.cue). | |
| specs: | |
| name: conformance specs | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 15 | |
| container: ghcr.io/comlineproject/ci-tools@sha256:bf98b8798137193a49d1e1952a5b5f87e3d59a31729028c001bcd7883a22f71b | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| - run: runtime/conformance/vendor-spec.sh --check | |
| - run: runtime/conformance/check.sh | |
| # `comline-runtime` without `std`: the `alloc` tier, and `alloc` plus the | |
| # JSON-RPC framing, built for wasm32 (no `std` there to lean on) and tested | |
| # on the host. In the wasm image, which has the wasm32 target. | |
| wasm32_core: | |
| name: wasm32 core | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 | |
| container: ghcr.io/comlineproject/ci-wasm@sha256:badd6af13cee6c459c9284de8ef0ef4a1667ed7e35582f87d1afb08f3c30fd8f | |
| env: | |
| # The image's toolchain (the root rust-toolchain.toml's pin, 1.99.1), | |
| # without the file's clippy and rustfmt, which this job doesn't use. | |
| RUSTUP_TOOLCHAIN: stable | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 | |
| - run: cargo build --verbose -p comline-runtime --no-default-features --features alloc,jsonrpc --target wasm32-unknown-unknown | |
| - run: cargo test --verbose -p comline-runtime --no-default-features --features alloc,jsonrpc | |
| - run: cargo build --verbose -p comline-runtime --no-default-features --features alloc --target wasm32-unknown-unknown | |
| - run: cargo test --verbose -p comline-runtime --no-default-features --features alloc | |
| # `comline-runtime-ffi`, the C ABI: `include/comline.h` matches what the | |
| # pinned cbindgen generates from the source, and the crate builds as a | |
| # cdylib and a staticlib natively and as a wasm32 module. The conformance | |
| # vectors are replayed through it from Rust (`cargo test`), from C against | |
| # the staticlib and the cdylib (gcc, and ASan + UBSan), and from Node | |
| # against the wasm32 build, each on the same cases. The Node tests also | |
| # hold the JS glue to its own rules: a trap poisons the instance (against | |
| # a `test-hooks` wasm32 build), one crossing per call, and `encodeBound`. | |
| # In the tools image, which has cbindgen (0.29.2: keep in step with | |
| # runtime/ffi/cbindgen.toml), make and gcc; the wasm32 target is added here. | |
| ffi: | |
| name: ffi | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 45 | |
| container: ghcr.io/comlineproject/ci-tools@sha256:bf98b8798137193a49d1e1952a5b5f87e3d59a31729028c001bcd7883a22f71b | |
| env: | |
| RUSTUP_TOOLCHAIN: stable | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| - run: rustup target add wasm32-unknown-unknown | |
| - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 | |
| - name: comline.h matches the source | |
| working-directory: runtime/ffi | |
| run: | | |
| cbindgen --version | |
| cbindgen --config cbindgen.toml --output include/comline.h | |
| git diff --exit-code -- include/comline.h || { | |
| echo "::error file=runtime/ffi/include/comline.h::comline.h is out of date: run cbindgen --config cbindgen.toml --output include/comline.h in runtime/ffi (cbindgen 0.29.2)" | |
| exit 1 | |
| } | |
| - name: cdylib and staticlib | |
| run: | | |
| cargo build --verbose -p comline-runtime-ffi --release | |
| ls -l target/release/libcomline_runtime_ffi.so target/release/libcomline_runtime_ffi.a | |
| - name: wasm32 | |
| run: | | |
| cargo build --verbose -p comline-runtime-ffi --profile wasm --target wasm32-unknown-unknown | |
| ls -l target/wasm32-unknown-unknown/wasm/comline_runtime_ffi.wasm | |
| # Into a target directory of its own, so it doesn't replace the build | |
| # above; js/test/poison.test.mjs looks for it there. | |
| - name: wasm32 with test hooks | |
| run: | | |
| cargo build --verbose -p comline-runtime-ffi --profile wasm --target wasm32-unknown-unknown --features test-hooks --target-dir target/test-hooks | |
| ls -l target/test-hooks/wasm32-unknown-unknown/wasm/comline_runtime_ffi.wasm | |
| - run: cargo test --verbose -p comline-runtime-ffi | |
| - name: export the vectors for C and Node | |
| run: cargo run -p comline-runtime-ffi --example export_vectors -- target/ffi-vectors | |
| - name: C harness (staticlib, cdylib, sanitizers) | |
| run: make -C runtime/ffi/tests/c check CC=gcc | |
| - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 | |
| with: | |
| node-version: 22 | |
| - name: Node harness (wasm32) | |
| run: node --test runtime/ffi/js/test/*.test.mjs | |
| # The `ffi` job on the other platforms (its name, required on main, stays | |
| # Linux's): the header, the libraries (`.dll`/`.lib` on Windows, `.dylib` | |
| # on macOS), the Rust replay, the C harness (clang on macOS and Windows; | |
| # no sanitizers on Windows) and the Node harness. Not in a container: the | |
| # images are Linux. | |
| ffi_platforms: | |
| name: ffi (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 45 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: windows-2025 | |
| cc: clang | |
| - os: macos-15 | |
| cc: clang | |
| - os: ubuntu-24.04-arm | |
| cc: gcc | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| CBINDGEN_VERSION: 0.29.2 | |
| steps: | |
| - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 | |
| with: | |
| egress-policy: audit | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - run: rustup target add wasm32-unknown-unknown | |
| - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 | |
| - run: cargo install cbindgen --version "$CBINDGEN_VERSION" --locked | |
| - name: comline.h matches the source | |
| working-directory: runtime/ffi | |
| run: | | |
| cbindgen --config cbindgen.toml --output include/comline.h | |
| git diff --exit-code -- include/comline.h | |
| - name: cdylib and staticlib | |
| run: | | |
| cargo build --verbose -p comline-runtime-ffi --release | |
| ls -l target/release/*comline_runtime_ffi* | |
| - name: wasm32 | |
| run: cargo build --verbose -p comline-runtime-ffi --profile wasm --target wasm32-unknown-unknown | |
| - name: wasm32 with test hooks | |
| run: cargo build --verbose -p comline-runtime-ffi --profile wasm --target wasm32-unknown-unknown --features test-hooks --target-dir target/test-hooks | |
| - run: cargo test --verbose -p comline-runtime-ffi | |
| - name: export the vectors for C and Node | |
| run: cargo run -p comline-runtime-ffi --example export_vectors -- target/ffi-vectors | |
| # GitHub's Windows image has make (MinGW's); fail plainly if it goes. | |
| - name: make (Windows) | |
| if: runner.os == 'Windows' | |
| run: command -v make | |
| - name: C harness | |
| run: make -C runtime/ffi/tests/c check CC=${{ matrix.cc }} | |
| - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 | |
| with: | |
| node-version: 22 | |
| - name: Node harness (wasm32) | |
| run: node --test runtime/ffi/js/test/*.test.mjs | |
| # The C ABI under Miri: the replay and the rule tests, checked for | |
| # undefined behaviour at the `extern "C"` boundary (aliasing, bounds, | |
| # leaks, panics caught at the boundary). On the VM: no CI image has miri. | |
| ffi_miri: | |
| name: ffi miri | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 45 | |
| steps: | |
| - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 | |
| with: | |
| egress-policy: audit | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - run: rustup toolchain install nightly --profile minimal --component miri | |
| - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 | |
| with: | |
| key: miri | |
| - run: cargo +nightly miri setup | |
| - run: cargo +nightly miri test -p comline-runtime-ffi --features test-hooks |