From 9091b8c74a6ffb128913420d10a1e28e19090439 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Thu, 12 Nov 2026 04:25:09 +0800 Subject: [PATCH 1/4] ci: shared workflows, CI images, hardening; Rust 1.99.1 --- .github/workflows/bench.yml | 93 ++++++----- .github/workflows/build_test.yml | 176 ++++++++++---------- .github/workflows/fuzz.yml | 271 ++++++++----------------------- .github/workflows/reports.yml | 64 +++++--- renovate.json | 4 + rust-toolchain.toml | 2 +- 6 files changed, 250 insertions(+), 360 deletions(-) create mode 100644 renovate.json diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index fc91e36..b5ec1e8 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -34,6 +34,10 @@ name: Benchmarks # annotated on the diff. Nothing is accepted by a label, a setting or a # default. See CONTRIBUTING.md. # +# Not the org's reusable bench workflow: valgrind needs the container started +# with `--security-opt seccomp=unconfined`, and that workflow has no input for +# container options. The jobs below are its steps, in the same image. +# # Plain `pull_request`, not `pull_request_target`: a fork's pull request runs # with a read-only token and no secrets, and the acceptance it can carry is # its own diff, which a maintainer reviews before merging. @@ -53,11 +57,19 @@ on: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + env: CARGO_TERM_COLOR: always - # Must match the `iai-callgrind` dev-dependency of every bench target + # The CI image's toolchain, whatever the root rust-toolchain.toml (and the + # base's, which a pull request's base may still pin differently) says: base + # and head are built by the same compiler, and the file's clippy and rustfmt + # aren't fetched. The image has iai-callgrind-runner 0.16.1, which must + # match the `iai-callgrind` dev-dependency of every bench target # (runtime/core/Cargo.toml, runtime/ffi/bench/Cargo.toml). - IAI_CALLGRIND_RUNNER_VERSION: 0.16.1 + RUSTUP_TOOLCHAIN: stable # A benchmark fails when its instruction count grows by more than this many # percent, unless the ledger accepts it (see the top). Measured when the # gate was set up: the same commit, run twice, differs by 0 instructions on @@ -74,39 +86,40 @@ env: # request both are in $RUNNER_TEMP, with paths of the same length (see # "Bench the head"). They share # iai-callgrind's output directory, where it keeps the base's counts for the - # head to compare with. - CARGO_TARGET_DIR: ${{ github.workspace }}/target - IAI_CALLGRIND_HOME: ${{ github.workspace }}/target-iai + # head to compare with. (CARGO_TARGET_DIR and IAI_CALLGRIND_HOME are set by + # each job's Settings step: `github.workspace` is the host's path, not the + # container's.) + jobs: + # In the bench image (valgrind 3.24, iai-callgrind-runner 0.16.1, the stable + # toolchain, python3). The container's seccomp profile is off, which valgrind + # needs. No harden-runner here: it hardens the VM, not a job container. instructions: name: instruction counts if: github.event_name == 'pull_request' - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 60 + container: + image: ghcr.io/comlineproject/ci-bench@sha256:0b1226fbc0867f4042a9af87b57311a259f12c5308a62469c4efd24fc0f78382 + options: --security-opt seccomp=unconfined steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 + persist-credentials: false - - name: Install Valgrind - run: sudo apt-get update && sudo apt-get install -y valgrind + - name: Settings + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + git config --global --add safe.directory "$RUNNER_TEMP/base" + echo "IAI_CALLGRIND_HOME=$GITHUB_WORKSPACE/target-iai" >> "$GITHUB_ENV" - name: Toolchain id: toolchain - # `rust-toolchain` picks it; base and head build with the same one. + # The image's; base and head build with the same one. run: echo "version=$(rustc --version)" >> "$GITHUB_OUTPUT" - - name: Cache iai-callgrind-runner - id: runner-cache - uses: actions/cache@v4 - with: - path: ~/.cargo/bin/iai-callgrind-runner - key: iai-callgrind-runner-${{ env.IAI_CALLGRIND_RUNNER_VERSION }}-${{ runner.os }} - - - name: Install iai-callgrind-runner - if: steps.runner-cache.outputs.cache-hit != 'true' - run: cargo install iai-callgrind-runner --version "$IAI_CALLGRIND_RUNNER_VERSION" --locked - - name: Bench the base id: base env: @@ -199,7 +212,7 @@ jobs: fi exit "$verdict" - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 if: always() && hashFiles('runtime/conformance/reports/rust.bench.json') != '' with: name: rust.bench.json @@ -208,37 +221,31 @@ jobs: main: name: publish instruction counts if: github.event_name != 'pull_request' - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 60 permissions: contents: write - # A newer push to `main` supersedes this one's numbers. - concurrency: - group: bench-publish-${{ github.ref }} - cancel-in-progress: true + container: + image: ghcr.io/comlineproject/ci-bench@sha256:0b1226fbc0867f4042a9af87b57311a259f12c5308a62469c4efd24fc0f78382 + options: --security-opt seccomp=unconfined steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: # The publish checks the report is newer than the published one. fetch-depth: 0 + # This job pushes to the reports branch with the checkout's token. + persist-credentials: true - - name: Install Valgrind - run: sudo apt-get update && sudo apt-get install -y valgrind + - name: Settings + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + echo "IAI_CALLGRIND_HOME=$GITHUB_WORKSPACE/target-iai" >> "$GITHUB_ENV" + echo "CARGO_TARGET_DIR=$GITHUB_WORKSPACE/target" >> "$GITHUB_ENV" - name: Toolchain id: toolchain run: echo "version=$(rustc --version)" >> "$GITHUB_OUTPUT" - - name: Cache iai-callgrind-runner - id: runner-cache - uses: actions/cache@v4 - with: - path: ~/.cargo/bin/iai-callgrind-runner - key: iai-callgrind-runner-${{ env.IAI_CALLGRIND_RUNNER_VERSION }}-${{ runner.os }} - - - name: Install iai-callgrind-runner - if: steps.runner-cache.outputs.cache-hit != 'true' - run: cargo install iai-callgrind-runner --version "$IAI_CALLGRIND_RUNNER_VERSION" --locked - - name: Bench run: | listed=$(python3 .github/scripts/bench-report.py --targets) @@ -262,13 +269,13 @@ jobs: --markdown "$RUNNER_TEMP/bench.md" cat "$RUNNER_TEMP/bench.md" >> "$GITHUB_STEP_SUMMARY" - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: rust.bench.json path: runtime/conformance/reports/rust.bench.json - name: Publish to the reports branch - uses: ComlineProject/observatory/.github/actions/publish-report@v1 + uses: ComlineProject/observatory/.github/actions/publish-report@8d21b1fbe68f8b639676153ce1a308eaafdcc6a7 # v1 with: reports: runtime/conformance/reports/rust.bench.json readme: .github/reports-branch.md diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 71ed2f5..49b7828 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -4,99 +4,66 @@ 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' }} + env: CARGO_TERM_COLOR: always jobs: - build_and_test: - name: Rust project - ${{ matrix.toolchain }} - runs-on: ubuntu-latest - strategy: - matrix: - toolchain: - - stable - - beta - - nightly - env: - # The root rust-toolchain.toml pins a toolchain and overrides - # `rustup default`; this variable overrides the file in turn. - RUSTUP_TOOLCHAIN: ${{ matrix.toolchain }} - steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install ${{ matrix.toolchain }} --profile minimal - - uses: Swatinem/rust-cache@v2 - # Cargo.lock is committed and must match the manifests: every build - # below, and every other workflow, resolves from it. - - run: cargo metadata --locked --format-version 1 > /dev/null - - run: cargo build --verbose - - run: cargo test --verbose - - run: cargo test --verbose -p comline-runtime --features tokio - - # The workspace on the other platforms, on stable only. Separate from the - # job above so its check names (required on main) stay as they are. - build_and_test_platforms: - name: Rust project - stable (${{ matrix.os }}) - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: - - windows-latest - - macos-latest - - ubuntu-24.04-arm - env: - RUSTUP_TOOLCHAIN: stable - steps: - - uses: actions/checkout@v6 - - run: rustup toolchain install stable --profile minimal - - uses: Swatinem/rust-cache@v2 - - run: cargo build --verbose --locked - - run: cargo test --verbose --locked - - run: cargo test --verbose --locked -p comline-runtime --features tokio + # 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@6bfbbcc9bccd25b44c06dbf41408885bb29aafe6 # 2026-11-11 + 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. + # 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-latest - env: - # Keep in step with runtime/conformance/spec/cue.mod/module.cue. - CUE_VERSION: v0.17.1 + runs-on: ubuntu-24.04 + timeout-minutes: 15 + container: ghcr.io/comlineproject/ci-tools@sha256:324a7d7e0fc5101cc21d2b1794b29c8c8a67e4eb1f9df7fafb91cfa627748035 steps: - - uses: actions/checkout@v4 - # The release download fails now and then (GitHub answering 504), so - # cue is cached per version, and fetched with retries only on a miss. - - name: Cache cue - id: cue-cache - uses: actions/cache@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - path: ~/.local/cue - key: cue-${{ env.CUE_VERSION }}-linux-amd64 - - name: Install cue - if: steps.cue-cache.outputs.cache-hit != 'true' - # To a file, not piped into tar: a retry would append to a half-read - # stream. - run: | - mkdir -p ~/.local/cue - curl -fsSL --retry 5 --retry-all-errors --retry-delay 5 -o cue.tar.gz \ - "https://github.com/cue-lang/cue/releases/download/$CUE_VERSION/cue_${CUE_VERSION}_linux_amd64.tar.gz" - tar -xzf cue.tar.gz -C ~/.local/cue cue - rm cue.tar.gz - - run: echo "$HOME/.local/cue" >> "$GITHUB_PATH" + 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. + # on the host. In the wasm image, which has the wasm32 target. wasm32_core: name: wasm32 core - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 30 + container: ghcr.io/comlineproject/ci-wasm@sha256:742fbab34886e53d099c7faee9ffa9cd9c53cda085f8139eb112106f9be1e0e5 + 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@v4 - # The toolchain is the root rust-toolchain.toml's. - - run: rustup target add wasm32-unknown-unknown - - uses: Swatinem/rust-cache@v2 + - 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 @@ -110,24 +77,29 @@ jobs: # 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-latest + runs-on: ubuntu-24.04 + timeout-minutes: 45 + container: ghcr.io/comlineproject/ci-tools@sha256:324a7d7e0fc5101cc21d2b1794b29c8c8a67e4eb1f9df7fafb91cfa627748035 env: - # Keep in step with runtime/ffi/cbindgen.toml. - CBINDGEN_VERSION: 0.29.2 + RUSTUP_TOOLCHAIN: stable steps: - - uses: actions/checkout@v4 - # The toolchain is the root rust-toolchain.toml's. + - 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@v2 - - run: cargo install cbindgen --version "$CBINDGEN_VERSION" --locked + - 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 $CBINDGEN_VERSION)" + 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 @@ -149,7 +121,7 @@ jobs: 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@v4 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 22 - name: Node harness (wasm32) @@ -158,17 +130,19 @@ jobs: # 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. + # no sanitizers on Windows) and the Node harness. Not in a container (the + # images are Linux), and the hardening runner is Linux's. ffi_platforms: name: ffi (${{ matrix.os }}) runs-on: ${{ matrix.os }} + timeout-minutes: 45 strategy: fail-fast: false matrix: include: - - os: windows-latest + - os: windows-2025 cc: clang - - os: macos-latest + - os: macos-15 cc: clang - os: ubuntu-24.04-arm cc: gcc @@ -178,9 +152,15 @@ jobs: env: CBINDGEN_VERSION: 0.29.2 steps: - - uses: actions/checkout@v6 + - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + if: runner.os == 'Linux' + 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@v2 + - 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 @@ -198,12 +178,14 @@ jobs: - 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 + # The one package install that stays: a hosted Windows runner has no CI + # image to run in, and installs `make` only when its image lacks it. - name: make (Windows) if: runner.os == 'Windows' run: command -v make || choco install make --no-progress -y - name: C harness run: make -C runtime/ffi/tests/c check CC=${{ matrix.cc }} - - uses: actions/setup-node@v6 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 22 - name: Node harness (wasm32) @@ -211,14 +193,20 @@ jobs: # 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). + # leaks, panics caught at the boundary). On the VM: no CI image has miri. ffi_miri: name: ffi miri - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 45 steps: - - uses: actions/checkout@v4 + - 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@v2 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 with: key: miri - run: cargo +nightly miri setup diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 798f09e..53e99ab 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -17,6 +17,12 @@ name: Fuzz # the `reports` branch, which the docs and the Observatory read, with its # `publish-report` action. Only the `publish` job can write, and never on a # pull request; other runs do a dry run of the publish. +# +# The fuzz jobs, the report and the publish are the org's reusable fuzz +# workflow (`fuzz` below), in the CI fuzz image. The property tests and the +# size tests are this repository's own jobs, in the same image; the property +# tests' verdicts reach the report as a `fuzz-stats-proptest` fragment, so the +# `fuzz` call waits for that job (the nightly runs it; a pull request doesn't). on: pull_request: @@ -24,158 +30,77 @@ on: - cron: "17 3 * * *" workflow_dispatch: +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + env: CARGO_TERM_COLOR: always - # cargo-fuzz needs nightly; this overrides any rust-toolchain file. - RUSTUP_TOOLCHAIN: nightly - CARGO_FUZZ_VERSION: 0.13.2 jobs: # The targets, from runtime/fuzz/Cargo.toml's [[bin]]s: the one list, which - # the matrix and the report's `expect` read. Fails when the README's targets - # table differs. + # the reusable workflow's matrix and the report's `expect` read. Fails when + # the README's targets table differs. targets: name: fuzz targets - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 10 outputs: list: ${{ steps.targets.outputs.list }} steps: - - uses: actions/checkout@v4 + - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - id: targets run: echo "list=$(.github/scripts/fuzz-targets.py)" >> "$GITHUB_OUTPUT" fuzz: - name: fuzz (${{ matrix.target }}) - needs: targets - runs-on: ubuntu-latest + name: fuzz + needs: [targets, properties] + # The property tests are skipped on a pull request, which would skip this. + if: ${{ !cancelled() && needs.targets.result == 'success' }} + # contents: write for the publish job, issues: write for the fuzz jobs; + # inside the reusable workflow each is on that job alone. permissions: - contents: read + contents: write issues: write - strategy: - fail-fast: false - matrix: - target: ${{ fromJSON(needs.targets.outputs.list) }} - env: - NIGHTLY: ${{ github.event_name != 'pull_request' }} - SECONDS_PER_TARGET: ${{ github.event_name == 'pull_request' && 60 || 600 }} - steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install nightly --profile minimal - - - name: Cache cargo-fuzz - id: cargo-fuzz - uses: actions/cache@v4 - with: - path: ~/.cargo/bin/cargo-fuzz - key: cargo-fuzz-${{ env.CARGO_FUZZ_VERSION }}-${{ runner.os }} - - if: steps.cargo-fuzz.outputs.cache-hit != 'true' - run: cargo install cargo-fuzz --locked --version "$CARGO_FUZZ_VERSION" - - - name: Cache the corpus - if: env.NIGHTLY == 'true' - uses: actions/cache@v4 - with: - path: runtime/fuzz/corpus/${{ matrix.target }} - key: fuzz-corpus-${{ matrix.target }}-${{ github.run_id }} - restore-keys: fuzz-corpus-${{ matrix.target }}- - - - name: Seed the corpus from the vectors - run: sh runtime/fuzz/seed-corpus.sh - - - name: Build - id: build - run: | - cargo fuzz build --fuzz-dir runtime/fuzz ${{ matrix.target }} - echo "toolchain=$(rustc --version)" >> "$GITHUB_OUTPUT" - - - name: Fuzz for ${{ env.SECONDS_PER_TARGET }}s - id: run - shell: bash - run: | - set -o pipefail - start=$(date +%s) - trap 'echo "seconds=$(( $(date +%s) - start ))" >> "$GITHUB_OUTPUT"' EXIT - # The nightly forks a process per core; fork mode stops at the first - # crash, as a single process does. - fork=() - [ "$NIGHTLY" = true ] && fork=("-fork=$(nproc)") - cargo fuzz run --fuzz-dir runtime/fuzz ${{ matrix.target }} -- \ - -max_total_time=${{ env.SECONDS_PER_TARGET }} "${fork[@]}" \ - -rss_limit_mb=2048 -malloc_limit_mb=512 -print_final_stats=1 \ - 2>&1 | tee "$RUNNER_TEMP/fuzz.log" - - # Before minimizing, which adds its own files next to the finding. - - name: Record the run - if: always() && steps.build.outcome == 'success' - uses: ComlineProject/observatory/.github/actions/report-fuzz@v1 - with: - mode: target - name: ${{ matrix.target }} - toolchain: ${{ steps.build.outputs.toolchain }} - log: ${{ runner.temp }}/fuzz.log - corpus: runtime/fuzz/corpus/${{ matrix.target }} - artifacts: runtime/fuzz/artifacts/${{ matrix.target }} - wall-seconds: ${{ steps.run.outputs.seconds || 0 }} - fragment: ${{ runner.temp }}/stats/${{ matrix.target }}.json - - if: always() && steps.build.outcome == 'success' - uses: actions/upload-artifact@v4 - with: - name: fuzz-stats-${{ matrix.target }} - path: ${{ runner.temp }}/stats - - - name: Minimize the crash - if: failure() - run: | - for crash in runtime/fuzz/artifacts/${{ matrix.target }}/*; do - [ -f "$crash" ] || continue - cargo fuzz tmin --fuzz-dir runtime/fuzz ${{ matrix.target }} "$crash" -r 2000 || true - done - - name: Upload the crash - if: failure() - uses: actions/upload-artifact@v4 - with: - name: fuzz-${{ matrix.target }} - path: runtime/fuzz/artifacts/${{ matrix.target }} - if-no-files-found: ignore - - - name: Open an issue - if: failure() && env.NIGHTLY == 'true' - env: - GH_TOKEN: ${{ github.token }} - TITLE: "Nightly fuzzing failed: ${{ matrix.target }}" - RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - run: | - open=$(gh issue list --repo "$GITHUB_REPOSITORY" --state open --limit 200 \ - --json title --jq "map(select(.title == env.TITLE)) | length") - if [ "$open" != "0" ]; then - echo "An issue titled '$TITLE' is already open." - exit 0 - fi - { - echo "The nightly fuzz run failed: $RUN" - echo - echo "The crash and its minimized form are the run's \`fuzz-${{ matrix.target }}\` artifact. As hex:" - echo - for crash in runtime/fuzz/artifacts/${{ matrix.target }}/*; do - [ -f "$crash" ] || continue - echo "- \`$(basename "$crash")\`: \`$(od -An -v -tx1 "$crash" | tr -d ' \n' | cut -c1-2000)\`" - done - echo - echo "Reproduce with \`cargo +nightly fuzz run --fuzz-dir runtime/fuzz ${{ matrix.target }} \`." - echo "A real bug becomes a \`found-*\` vector; see runtime/fuzz/README.md." - } > body.md - gh issue create --repo "$GITHUB_REPOSITORY" --title "$TITLE" --body-file body.md + uses: ComlineProject/.github/.github/workflows/fuzz.yml@6bfbbcc9bccd25b44c06dbf41408885bb29aafe6 # 2026-11-11 + with: + image: ghcr.io/comlineproject/ci-fuzz@sha256:85c9577ed3350d729d4d9261307fd3075735dba44edae895baa241e3fac89fea + targets: ${{ needs.targets.outputs.list }} + fuzz-dir: runtime/fuzz + duration: 600 + pr-duration: 60 + crash-format: hex + report-path: runtime/conformance/reports/rust.fuzz.json + report-subject: rust + publish: true properties: name: proptest (100000 cases) if: github.event_name != 'pull_request' - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 120 permissions: contents: read issues: write + container: ghcr.io/comlineproject/ci-fuzz@sha256:85c9577ed3350d729d4d9261307fd3075735dba44edae895baa241e3fac89fea + env: + # The image's nightly, over the root rust-toolchain.toml. + RUSTUP_TOOLCHAIN: nightly steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install nightly --profile minimal + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + mkdir -p fuzz-out/stats - name: Property tests id: properties shell: bash @@ -186,26 +111,26 @@ jobs: set -o pipefail status=0 cargo test --release -p comline-runtime-conformance --test properties \ - 2>&1 | tee "$RUNNER_TEMP/proptest.log" || status=1 + 2>&1 | tee fuzz-out/proptest.log || status=1 cargo test --release -p comline-runtime-ffi --test differential the_abi_agrees_with_the_core \ - 2>&1 | tee -a "$RUNNER_TEMP/proptest.log" || status=1 + 2>&1 | tee -a fuzz-out/proptest.log || status=1 exit $status - name: Record the run if: always() - uses: ComlineProject/observatory/.github/actions/report-fuzz@v1 + uses: ComlineProject/observatory/.github/actions/report-fuzz@8d21b1fbe68f8b639676153ce1a308eaafdcc6a7 # v1 with: mode: proptest - log: ${{ runner.temp }}/proptest.log + log: fuzz-out/proptest.log cases: 100000 - fragment: ${{ runner.temp }}/stats/proptest.json + fragment: fuzz-out/stats/proptest.json - if: always() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: fuzz-stats-proptest - path: ${{ runner.temp }}/stats + path: fuzz-out/stats - name: Upload the failing seeds if: failure() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: proptest-regressions path: | @@ -235,23 +160,27 @@ jobs: # on a failure. sizes: name: sizes (proptest) - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 timeout-minutes: 120 permissions: contents: read issues: write + container: ghcr.io/comlineproject/ci-fuzz@sha256:85c9577ed3350d729d4d9261307fd3075735dba44edae895baa241e3fac89fea env: + RUSTUP_TOOLCHAIN: nightly NIGHTLY: ${{ github.event_name != 'pull_request' }} steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install nightly --profile minimal + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Size tests env: PROPTEST_CASES: ${{ github.event_name == 'pull_request' && '256' || '20000' }} run: cargo test --release --manifest-path runtime/fuzz/Cargo.toml --test sizes - name: Upload the failing seeds if: failure() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: sizes-proptest-regressions path: runtime/fuzz/tests/sizes.proptest-regressions @@ -271,65 +200,3 @@ jobs: fi gh issue create --repo "$GITHUB_REPOSITORY" --title "$TITLE" --body \ "The nightly size tests (runtime/fuzz/tests/sizes.rs, PROPTEST_CASES=20000) failed: $RUN. The minimal failing input is in the job log; the seed is the run's \`sizes-proptest-regressions\` artifact." - - report: - name: fuzz report - needs: [targets, fuzz, properties] - if: ${{ !cancelled() }} - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - uses: actions/checkout@v4 - with: - # The dry run checks the report is newer than the published one. - fetch-depth: 0 - - uses: actions/download-artifact@v4 - with: - pattern: fuzz-stats-* - path: ${{ runner.temp }}/stats - - name: Report - uses: ComlineProject/observatory/.github/actions/report-fuzz@v1 - with: - mode: combine - subject: rust - fragments: ${{ runner.temp }}/stats - expect: ${{ join(fromJSON(needs.targets.outputs.list), ' ') }} - output: runtime/conformance/reports/rust.fuzz.json - markdown: ${{ runner.temp }}/fuzz.md - - run: cat "$RUNNER_TEMP/fuzz.md" >> "$GITHUB_STEP_SUMMARY" - - uses: actions/upload-artifact@v4 - with: - name: rust.fuzz.json - path: runtime/conformance/reports/rust.fuzz.json - - name: Publish (dry run) - if: github.ref != 'refs/heads/main' || github.event_name == 'pull_request' - uses: ComlineProject/observatory/.github/actions/publish-report@v1 - with: - reports: runtime/conformance/reports/rust.fuzz.json - readme: .github/reports-branch.md - dry-run: 'true' - - publish: - name: publish fuzz report - needs: report - if: ${{ !cancelled() && needs.report.result == 'success' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }} - runs-on: ubuntu-latest - permissions: - contents: write - concurrency: - group: fuzz-publish - cancel-in-progress: false - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/download-artifact@v4 - with: - name: rust.fuzz.json - path: ${{ runner.temp }}/report - - name: Publish to the reports branch - uses: ComlineProject/observatory/.github/actions/publish-report@v1 - with: - reports: ${{ runner.temp }}/report/rust.fuzz.json - readme: .github/reports-branch.md diff --git a/.github/workflows/reports.yml b/.github/workflows/reports.yml index 284a344..4e90c77 100644 --- a/.github/workflows/reports.yml +++ b/.github/workflows/reports.yml @@ -19,8 +19,8 @@ permissions: contents: read concurrency: - group: reports-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} env: CARGO_TERM_COLOR: always @@ -28,18 +28,24 @@ env: jobs: size: name: size - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 60 steps: - - uses: actions/checkout@v7 + - 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@v2 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 - id: rustc run: echo "version=$(rustc --version)" >> "$GITHUB_OUTPUT" - name: Build run: | cargo build --locked -p comline-runtime-ffi --release cargo build --locked -p comline-runtime-ffi --profile wasm --target wasm32-unknown-unknown - - uses: ComlineProject/observatory/.github/actions/report-size@v1 + - uses: ComlineProject/observatory/.github/actions/report-size@8d21b1fbe68f8b639676153ce1a308eaafdcc6a7 # v1 with: output: reports/rust.size.json toolchain: ${{ steps.rustc.outputs.version }} @@ -47,7 +53,7 @@ jobs: ffi/cdylib/x86_64-linux-release=target/release/libcomline_runtime_ffi.so ffi/staticlib/x86_64-linux-release=target/release/libcomline_runtime_ffi.a ffi/wasm32=target/wasm32-unknown-unknown/wasm/comline_runtime_ffi.wasm - - uses: actions/upload-artifact@v7 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: report-size path: reports/rust.size.json @@ -55,15 +61,21 @@ jobs: coverage: name: coverage - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 60 steps: - - uses: actions/checkout@v7 - - uses: Swatinem/rust-cache@v2 - - uses: ComlineProject/observatory/.github/actions/report-rust-coverage@v1 + - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 + - uses: ComlineProject/observatory/.github/actions/report-rust-coverage@8d21b1fbe68f8b639676153ce1a308eaafdcc6a7 # v1 with: output: reports/rust.coverage.json args: --workspace - - uses: actions/upload-artifact@v7 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: report-coverage path: reports/rust.coverage.json @@ -71,14 +83,20 @@ jobs: compile: name: compile time - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 60 steps: - - uses: actions/checkout@v7 - - uses: ComlineProject/observatory/.github/actions/report-rust-compile@v1 + - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: ComlineProject/observatory/.github/actions/report-rust-compile@8d21b1fbe68f8b639676153ce1a308eaafdcc6a7 # v1 with: output: reports/rust.compile.json args: --workspace --release - - uses: actions/upload-artifact@v7 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: report-compile path: reports/rust.compile.json @@ -88,19 +106,25 @@ jobs: name: publish needs: [size, coverage, compile] if: github.event_name != 'pull_request' - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 60 permissions: contents: write steps: - - uses: actions/checkout@v7 + - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 - - uses: actions/download-artifact@v8 + # This job pushes to the reports branch with the checkout's token. + persist-credentials: true + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: pattern: report-* path: reports merge-multiple: true - - uses: ComlineProject/observatory/.github/actions/publish-report@v1 + - uses: ComlineProject/observatory/.github/actions/publish-report@8d21b1fbe68f8b639676153ce1a308eaafdcc6a7 # v1 with: reports: reports/rust.size.json reports/rust.coverage.json reports/rust.compile.json readme: .github/reports-branch.md diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..f8b00a1 --- /dev/null +++ b/renovate.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["github>ComlineProject/.github:renovate-config"] +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml index aa20bc9..9ec55b3 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.98.0" +channel = "1.99.1" components = ["rustfmt", "clippy"] From 385b82647124a39fca77b324c496b287ac46f207 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Thu, 12 Nov 2026 05:33:33 +0800 Subject: [PATCH 2/4] ci: bash as the default shell, for the container jobs --- .github/workflows/bench.yml | 5 +++++ .github/workflows/build_test.yml | 5 +++++ .github/workflows/fuzz.yml | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index b5ec1e8..310b121 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -61,6 +61,11 @@ 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 # The CI image's toolchain, whatever the root rust-toolchain.toml (and the diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 49b7828..1b7e7cb 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -11,6 +11,11 @@ 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 diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 53e99ab..0a55ef5 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -37,6 +37,11 @@ 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 From 4d503279ddb911de671b679e14eff2ed6ae8e419 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Thu, 12 Nov 2026 05:46:55 +0800 Subject: [PATCH 3/4] ci: check for make on Windows instead of installing it --- .github/workflows/build_test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 1b7e7cb..e92d770 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -183,11 +183,10 @@ jobs: - 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 - # The one package install that stays: a hosted Windows runner has no CI - # image to run in, and installs `make` only when its image lacks it. + # GitHub's Windows image has make (MinGW's); fail plainly if it goes. - name: make (Windows) if: runner.os == 'Windows' - run: command -v make || choco install make --no-progress -y + 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 From 2f09062085a7c1840b8090169f7cc8d82a698d18 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Thu, 12 Nov 2026 06:27:34 +0800 Subject: [PATCH 4/4] ci: new reusable pins and images; bench and lint on the shared workflows --- .github/workflows/bench.yml | 253 ++++--------------------------- .github/workflows/build_test.yml | 13 +- .github/workflows/fuzz.yml | 8 +- .github/workflows/lint.yml | 28 ++++ 4 files changed, 66 insertions(+), 236 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 310b121..4e8fb14 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -34,15 +34,20 @@ name: Benchmarks # annotated on the diff. Nothing is accepted by a label, a setting or a # default. See CONTRIBUTING.md. # -# Not the org's reusable bench workflow: valgrind needs the container started -# with `--security-opt seccomp=unconfined`, and that workflow has no input for -# container options. The jobs below are its steps, in the same image. +# The gate itself is the org's reusable bench workflow (`bench` below), run in +# the CI bench image. `bench-command: cargo +stable bench` makes base and head +# build with the image's stable toolchain whatever rust-toolchain.toml says +# (a pull request's base may still pin another one, and a different compiler +# moves counts by far more than the limit), and keeps the file's clippy and +# rustfmt from being fetched. The image's iai-callgrind-runner must match the +# `iai-callgrind` dev-dependency of every bench target +# (runtime/core/Cargo.toml, runtime/ffi/bench/Cargo.toml). # # Plain `pull_request`, not `pull_request_target`: a fork's pull request runs # with a read-only token and no secrets, and the acceptance it can carry is # its own diff, which a maintainer reviews before merging. # -# Publishing: on every push to `main`, the `main` job benches the new head's +# Publishing: on every push to `main`, the `publish` job benches the new head's # targets alone (nothing to gate) and commits its `rust.bench.json` to the `reports` # branch, which the docs fetch from; see the shared publish-report action (ComlineProject/observatory). # Only that job can write, and only from `main`: a manual run from another @@ -61,227 +66,25 @@ 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 - # The CI image's toolchain, whatever the root rust-toolchain.toml (and the - # base's, which a pull request's base may still pin differently) says: base - # and head are built by the same compiler, and the file's clippy and rustfmt - # aren't fetched. The image has iai-callgrind-runner 0.16.1, which must - # match the `iai-callgrind` dev-dependency of every bench target - # (runtime/core/Cargo.toml, runtime/ffi/bench/Cargo.toml). - RUSTUP_TOOLCHAIN: stable - # A benchmark fails when its instruction count grows by more than this many - # percent, unless the ledger accepts it (see the top). Measured when the - # gate was set up: the same commit, run twice, differs by 0 instructions on - # every benchmark, and with one codegen unit - # (`[profile.bench]` in Cargo.toml) a change to one function leaves the - # others' counts alone. 1% is above that, and catches a few instructions on - # the smallest benchmarks. - BENCH_LIMIT_PERCENT: 1 - # The ledger of accepted regressions (see the top). - LEDGER: runtime/core/benches/accepted-regressions.toml - # Base and head build into separate target directories: in a shared one, - # Cargo names a workspace's path packages the same from either checkout, and - # the head's older source mtimes make it reuse the base's build. On a pull - # request both are in $RUNNER_TEMP, with paths of the same length (see - # "Bench the head"). They share - # iai-callgrind's output directory, where it keeps the base's counts for the - # head to compare with. (CARGO_TARGET_DIR and IAI_CALLGRIND_HOME are set by - # each job's Settings step: `github.workspace` is the host's path, not the - # container's.) - - jobs: - # In the bench image (valgrind 3.24, iai-callgrind-runner 0.16.1, the stable - # toolchain, python3). The container's seccomp profile is off, which valgrind - # needs. No harden-runner here: it hardens the VM, not a job container. - instructions: - name: instruction counts - if: github.event_name == 'pull_request' - runs-on: ubuntu-24.04 - timeout-minutes: 60 - container: - image: ghcr.io/comlineproject/ci-bench@sha256:0b1226fbc0867f4042a9af87b57311a259f12c5308a62469c4efd24fc0f78382 - options: --security-opt seccomp=unconfined - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Settings - run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - git config --global --add safe.directory "$RUNNER_TEMP/base" - echo "IAI_CALLGRIND_HOME=$GITHUB_WORKSPACE/target-iai" >> "$GITHUB_ENV" - - - name: Toolchain - id: toolchain - # The image's; base and head build with the same one. - run: echo "version=$(rustc --version)" >> "$GITHUB_OUTPUT" - - - name: Bench the base - id: base - env: - BASE_SHA: ${{ github.event.pull_request.base.sha }} - run: | - git worktree add "$RUNNER_TEMP/base" "$BASE_SHA" - cd "$RUNNER_TEMP/base" - # The base's own targets. A base from before the list had the - # runtime's alone, or, earlier still, no benches. - if ! python3 .github/scripts/bench-report.py --targets > "$RUNNER_TEMP/base-targets" 2>/dev/null; then - if [ -f runtime/core/benches/runtime.rs ]; then - echo "comline-runtime runtime" > "$RUNNER_TEMP/base-targets" - else - : > "$RUNNER_TEMP/base-targets" - fi - fi - if [ ! -s "$RUNNER_TEMP/base-targets" ]; then - echo "The base ($BASE_SHA) has no benches; recording head only." - echo "compare=false" >> "$GITHUB_OUTPUT" - exit 0 - fi - mapfile -t targets < "$RUNNER_TEMP/base-targets" - for target in "${targets[@]}"; do - read -r package bench <<< "$target" - echo "::group::Base: $package --bench $bench" - CARGO_TARGET_DIR="$RUNNER_TEMP/base-target" cargo bench -p "$package" --bench "$bench" -- \ - --save-baseline=base --save-summary=json - echo "::endgroup::" - done - # The base's own summaries, kept apart from the head's: they say - # which benchmarks the base had, so one the head drops or renames - # is noticed, and give a renamed one its old count. - mkdir -p "$RUNNER_TEMP/base-iai" - (cd "$IAI_CALLGRIND_HOME" && find . -name summary.json -exec cp --parents {} "$RUNNER_TEMP/base-iai" \;) - echo "compare=true" >> "$GITHUB_OUTPUT" - - - name: Bench the head - env: - COMPARE: ${{ steps.base.outputs.compare }} - run: | - find "$IAI_CALLGRIND_HOME" -name summary.json -delete 2>/dev/null || true - # Beside the base's, and as long a path: a bench binary's path is - # in its arguments, and its length moves the heap, which moves some - # counts by a few instructions (16 of the ffi target's 102, when - # measured with paths 16 bytes apart). Same length, same counts. - export CARGO_TARGET_DIR="$RUNNER_TEMP/head-target" - # No --callgrind-limits: the gate is the Report step's, which knows - # the ledger. So this step fails only when a benchmark can't run. - # A target the base ran is compared with its baseline; one the base - # doesn't have is recorded only. - listed=$(python3 .github/scripts/bench-report.py --targets) - mapfile -t targets <<< "$listed" - for target in "${targets[@]}"; do - read -r package bench <<< "$target" - echo "::group::Head: $package --bench $bench" - if [ "$COMPARE" = "true" ] && grep -qxF "$target" "$RUNNER_TEMP/base-targets"; then - cargo bench -p "$package" --bench "$bench" -- --baseline=base --save-summary=json - else - echo "The base doesn't have this target; recording head only." - cargo bench -p "$package" --bench "$bench" -- --save-summary=json - fi - echo "::endgroup::" - done - - - name: Report and gate - env: - HEAD_SHA: ${{ github.event.pull_request.head.sha }} - PR: ${{ github.event.pull_request.number }} - TOOLCHAIN: ${{ steps.toolchain.outputs.version }} - run: | - # The base's ledger tells this pull request's entries from history; - # a base without one has none. The script's exit status is the - # verdict, given after the summary is written. - set +e - python3 .github/scripts/bench-report.py \ - --home "$IAI_CALLGRIND_HOME" \ - --commit "$HEAD_SHA" \ - --toolchain "$TOOLCHAIN" \ - --limit "$BENCH_LIMIT_PERCENT" \ - --pr "$PR" \ - --base-home "$RUNNER_TEMP/base-iai" \ - --ledger "$LEDGER" \ - --base-ledger "$RUNNER_TEMP/base/$LEDGER" \ - --report runtime/conformance/reports/rust.bench.json \ - --markdown "$RUNNER_TEMP/bench.md" - verdict=$? - cat "$RUNNER_TEMP/bench.md" >> "$GITHUB_STEP_SUMMARY" - if [ "$verdict" != 0 ]; then - echo "::error::The instruction-count gate failed; see the job summary." - fi - exit "$verdict" - - - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - if: always() && hashFiles('runtime/conformance/reports/rust.bench.json') != '' - with: - name: rust.bench.json - path: runtime/conformance/reports/rust.bench.json - - main: - name: publish instruction counts - if: github.event_name != 'pull_request' - runs-on: ubuntu-24.04 - timeout-minutes: 60 + bench: + name: bench + # contents: write is for the publish job alone (never on a pull request); + # the gate job asks for contents: read. permissions: contents: write - container: - image: ghcr.io/comlineproject/ci-bench@sha256:0b1226fbc0867f4042a9af87b57311a259f12c5308a62469c4efd24fc0f78382 - options: --security-opt seccomp=unconfined - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - # The publish checks the report is newer than the published one. - fetch-depth: 0 - # This job pushes to the reports branch with the checkout's token. - persist-credentials: true - - - name: Settings - run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - echo "IAI_CALLGRIND_HOME=$GITHUB_WORKSPACE/target-iai" >> "$GITHUB_ENV" - echo "CARGO_TARGET_DIR=$GITHUB_WORKSPACE/target" >> "$GITHUB_ENV" - - - name: Toolchain - id: toolchain - run: echo "version=$(rustc --version)" >> "$GITHUB_OUTPUT" - - - name: Bench - run: | - listed=$(python3 .github/scripts/bench-report.py --targets) - mapfile -t targets <<< "$listed" - for target in "${targets[@]}"; do - read -r package bench <<< "$target" - echo "::group::$package --bench $bench" - cargo bench -p "$package" --bench "$bench" -- --save-summary=json - echo "::endgroup::" - done - - - name: Report - env: - TOOLCHAIN: ${{ steps.toolchain.outputs.version }} - run: | - python3 .github/scripts/bench-report.py \ - --home "$IAI_CALLGRIND_HOME" \ - --commit "$GITHUB_SHA" \ - --toolchain "$TOOLCHAIN" \ - --report runtime/conformance/reports/rust.bench.json \ - --markdown "$RUNNER_TEMP/bench.md" - cat "$RUNNER_TEMP/bench.md" >> "$GITHUB_STEP_SUMMARY" - - - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: rust.bench.json - path: runtime/conformance/reports/rust.bench.json - - - name: Publish to the reports branch - uses: ComlineProject/observatory/.github/actions/publish-report@8d21b1fbe68f8b639676153ce1a308eaafdcc6a7 # v1 - with: - reports: runtime/conformance/reports/rust.bench.json - readme: .github/reports-branch.md - dry-run: ${{ github.ref != 'refs/heads/main' && 'true' || 'false' }} + uses: ComlineProject/.github/.github/workflows/bench.yml@797d473553d7f2fc50895bb2573acb83ac63c7cb # 2026-11-12 + with: + image: ghcr.io/comlineproject/ci-bench@sha256:235555448c3c6027960cd95c0b2974014484e0c4f2808f064eb4cb3df91cebc0 + bench-command: cargo +stable bench + ledger: runtime/core/benches/accepted-regressions.toml + report-path: runtime/conformance/reports/rust.bench.json + # A benchmark fails when its instruction count grows by more than this + # many percent, unless the ledger accepts it (see the top). Measured when + # the gate was set up: the same commit, run twice, differs by 0 + # instructions on every benchmark, and with one codegen unit + # (`[profile.bench]` in Cargo.toml) a change to one function leaves the + # others' counts alone. 1% is above that, and catches a few instructions + # on the smallest benchmarks. + limit-percent: '1' + publish: true diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index e92d770..56b300d 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -29,7 +29,7 @@ jobs: name: ci permissions: contents: read - uses: ComlineProject/.github/.github/workflows/rust-ci.yml@6bfbbcc9bccd25b44c06dbf41408885bb29aafe6 # 2026-11-11 + uses: ComlineProject/.github/.github/workflows/rust-ci.yml@797d473553d7f2fc50895bb2573acb83ac63c7cb # 2026-11-12 with: build-args: --locked test-args: --locked @@ -43,7 +43,7 @@ jobs: name: conformance specs runs-on: ubuntu-24.04 timeout-minutes: 15 - container: ghcr.io/comlineproject/ci-tools@sha256:324a7d7e0fc5101cc21d2b1794b29c8c8a67e4eb1f9df7fafb91cfa627748035 + container: ghcr.io/comlineproject/ci-tools@sha256:bf98b8798137193a49d1e1952a5b5f87e3d59a31729028c001bcd7883a22f71b steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -59,7 +59,7 @@ jobs: name: wasm32 core runs-on: ubuntu-24.04 timeout-minutes: 30 - container: ghcr.io/comlineproject/ci-wasm@sha256:742fbab34886e53d099c7faee9ffa9cd9c53cda085f8139eb112106f9be1e0e5 + 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. @@ -88,7 +88,7 @@ jobs: name: ffi runs-on: ubuntu-24.04 timeout-minutes: 45 - container: ghcr.io/comlineproject/ci-tools@sha256:324a7d7e0fc5101cc21d2b1794b29c8c8a67e4eb1f9df7fafb91cfa627748035 + container: ghcr.io/comlineproject/ci-tools@sha256:bf98b8798137193a49d1e1952a5b5f87e3d59a31729028c001bcd7883a22f71b env: RUSTUP_TOOLCHAIN: stable steps: @@ -135,8 +135,8 @@ jobs: # 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), and the hardening runner is Linux's. + # 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 }} @@ -158,7 +158,6 @@ jobs: CBINDGEN_VERSION: 0.29.2 steps: - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 - if: runner.os == 'Linux' with: egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 0a55ef5..8f411d8 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -75,9 +75,9 @@ jobs: permissions: contents: write issues: write - uses: ComlineProject/.github/.github/workflows/fuzz.yml@6bfbbcc9bccd25b44c06dbf41408885bb29aafe6 # 2026-11-11 + uses: ComlineProject/.github/.github/workflows/fuzz.yml@797d473553d7f2fc50895bb2573acb83ac63c7cb # 2026-11-12 with: - image: ghcr.io/comlineproject/ci-fuzz@sha256:85c9577ed3350d729d4d9261307fd3075735dba44edae895baa241e3fac89fea + image: ghcr.io/comlineproject/ci-fuzz@sha256:d18222e3007d318c73b1df500d997222ff6dca536b4b0e89e6ab7e55fc81326a targets: ${{ needs.targets.outputs.list }} fuzz-dir: runtime/fuzz duration: 600 @@ -95,7 +95,7 @@ jobs: permissions: contents: read issues: write - container: ghcr.io/comlineproject/ci-fuzz@sha256:85c9577ed3350d729d4d9261307fd3075735dba44edae895baa241e3fac89fea + container: ghcr.io/comlineproject/ci-fuzz@sha256:d18222e3007d318c73b1df500d997222ff6dca536b4b0e89e6ab7e55fc81326a env: # The image's nightly, over the root rust-toolchain.toml. RUSTUP_TOOLCHAIN: nightly @@ -170,7 +170,7 @@ jobs: permissions: contents: read issues: write - container: ghcr.io/comlineproject/ci-fuzz@sha256:85c9577ed3350d729d4d9261307fd3075735dba44edae895baa241e3fac89fea + container: ghcr.io/comlineproject/ci-fuzz@sha256:d18222e3007d318c73b1df500d997222ff6dca536b4b0e89e6ab7e55fc81326a env: RUSTUP_TOOLCHAIN: nightly NIGHTLY: ${{ github.event_name != 'pull_request' }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..0cc6dd2 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +name: Lint + +# actionlint on the workflows, and the Renovate config checked with +# `--strict`: the org's reusable lint workflow. + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +# The reusable workflow has a group of its own, `lint-`, and group +# names are case-insensitive: this one is named differently so they don't +# clash. +concurrency: + group: lint-caller-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + lint: + name: lint + permissions: + contents: read + uses: ComlineProject/.github/.github/workflows/lint.yml@797d473553d7f2fc50895bb2573acb83ac63c7cb # 2026-11-12 + with: + renovate-config: renovate.json