Skip to content

ci: consolidate and speed up CI - #564

Merged
JP-Ellis merged 15 commits into
masterfrom
ci/overhaul
Oct 17, 2026
Merged

JP-Ellis merged 15 commits into
masterfrom
ci/overhaul

Conversation

@JP-Ellis

@JP-Ellis JP-Ellis commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Goal

Make CI fast, cache-efficient and deterministic. This PR changes no library behaviour, and adds no lint or formatting gates.

Baseline

A recent master run had these problems:

  • Double triggers. build.yml ran on both push: '**' and pull_request, so every PR commit built twice.
  • Release matrix on every PR. release.yml built all 8 release targets for each PR commit.
  • FFI legs took 41 min on Windows. Corrosion built pact_ffi in release once per C project, so each OS built it twice.
  • Compatibility suite: 12 cold builds. v1–v4 ran as separate jobs on each of 3 OSes.
  • Cache thrash. Caches used 12.1 GB against the 10 GB limit. PR refs wrote caches no other PR could read.
  • Floating toolchains. Tests used stable, FFI used nightly, and the release workflow pinned 1.98.1. The C examples tested a library built by a different compiler from the one that ships.
  • Stale actions. checkout@v2 to v5, install-action@main and github-script@v5 were in use.
  • Coverage gaps.
    • The pact_ffi/examples never ran.
    • Feature checks ran only workspace-wide with --no-default-features.
    • Windows and macOS ran only after merge.

What changes

One test.yml replaces build.yml, build-ffi.yml and compatability-suite.yml. A single CI complete sentinel needs every job.

  • Triggers. It runs on push to master and on PRs to master, so each PR commit gets one run. Draft PRs skip every heavy job, and marking a PR ready starts the full run.
  • Toolchain. A root rust-toolchain.toml pins 1.99.1, which carries the fix for 1.99.0's C bool return miscompilation. Tests, FFI builds and releases all read it. Nightly is installed only for cbindgen.
  • Tools. mise manages the dev tooling and reads Rust's version from rust-toolchain.toml. jdx/mise-action installs only what each job needs.
  • Caches. Caches save only from master. PR runs restore master's entries and write nothing.
  • Tests.
    • nextest runs the suite. Doctests run separately.
    • The V2 matching engine run stays advisory.
  • Compatibility suite. v1–v4 share one compile per OS.
  • FFI.
    • pact_ffi builds once per OS, in release, with the pinned toolchain.
    • The five pact_ffi/examples and both c/ projects run against that one build.
    • Conan packages are restored on every run and saved only from master.
  • Windows. The Windows legs build on a Dev Drive.
  • Feature checks. cargo hack check --workspace --each-feature replaces the single --no-default-features check.
  • Release workflow. release.yml no longer runs on pull requests. PR 2 replaces it. Until then it takes its toolchain from rust-toolchain.toml.
  • Actions. Every action is pinned by commit SHA, and each workflow declares its token permissions.

Commit sequence

  1. chore: pin Rust 1.99.1 and declare CI tools in mise: the toolchain file, mise.toml and the nextest ci profile. mise reads Rust from the toolchain file, so the version lives in one place.
  2. test: install the rustls crypto provider in tests that build HTTP clients:
    • Nextest runs each test in its own process. That exposed 26 tests that built a reqwest client and passed only because an earlier test in the same binary had installed the rustls provider.
    • A helper in each test module now installs the provider.
  3. build(ffi): build with the pinned toolchain, keep nightly for cbindgen:
    • The CMake project no longer refuses to configure without nightly.
    • cbindgen still needs nightly, because its macro expansion passes -Zunpretty=expanded.
  4. test(ffi): build and run the C examples against one release build: .github/scripts/ffi-examples.sh replaces rust/pact_ffi/ci-build.sh. It installs one release build under rust/pact_ffi/build/install and runs every example against it. Only CI runs it, so it sits with the workflows.
  5. build(c): accept a prebuilt pact_ffi through PACT_FFI_PREBUILT_DIR:
    • With the variable set, the c/ projects link the install from step 4.
    • Without it, local builds keep using Corrosion. The justfiles default RUSTUP_TOOLCHAIN to nightly, which the READMEs already required. Step 13 removes that default.
  6. ci: consolidate testing into one draft-aware workflow: adds test.yml.
  7. fix(ci): keep issue text out of shell commands in the Jira workflow:
    • The issue title was interpolated into a run: script.
    • The job runs for anyone who comments /jira ticket, on a runner that holds the Jira credentials.
  8. ci: retire superseded workflows and pin remaining actions
  9. docs: describe the consolidated CI and nextest workflow
  10. ci: build releases with the toolchain from rust-toolchain.toml:
    • dtolnay/rust-toolchain named its own compiler, and added the matrix targets only to that one. The toolchain file overrode it, so the aarch64 Windows cross-compile could build without its standard library.
    • setup-rust-toolchain, given no toolchain, installs the pinned one and adds target to it.
    • The pact_ffi README's "Release compiler" section goes with the separate pin.
  11. ci: report every failure and cache the musl job:
    • Steps after nextest run even when it fails, and --no-fail-fast keeps one failing binary from hiding the rest.
    • The musl job installs GNU tar, because busybox tar broke its cache.
  12. ci: install cbindgen from prebuilt binaries only:
    • The FFI job installs cargo-binstall, so mise's cargo: backend downloads cbindgen in seconds and doesn't compile it.
    • mise.toml enables cargo-quickinstall and binstall_only, so a missing binary fails loudly.
    • mise's cargo: backend requires mise's rust tool, so the FFI job installs it too. It resolves to the toolchain already installed.
  13. build(c): generate pact.h on nightly, build pact_ffi with the pinned toolchain:
    • mise exports RUSTUP_TOOLCHAIN, so the justfiles' nightly default stopped applying, and Corrosion's cbindgen step would have run on 1.99.1 and failed.
    • That default had also built the whole library on nightly.
    • Each C CMakeLists.txt now runs rustup run nightly cbindgen for the header, as rust/pact_ffi's CMake project does. Corrosion builds the library with the pinned toolchain.
  14. build: update pact-plugin-driver and check `plugins` alone again:
    • pact-plugins 801c1433 enables chrono's clock feature, so pact_matching builds with plugins alone.
    • The lock moves the driver to 7a290b6b, which also moves to zip 9.
    • The features job drops its plugins exclusion.
  15. test: run pact_verifier's pact-writing tests one at a time under nextest:
    • pact_verifier's unit tests merge mock-server interactions into shared pact files. write_pact locks only within a process, and its new-file branch truncates before taking the file lock.
    • Under nextest, eleven pact_broker tests failed on macOS after reading a file another process had just truncated.
    • A one-thread nextest test group covers those modules. Fixing the race in write_pact is a library change, left for its own PR.

Alternatives weighed

  • A composite setup action. It would have saved about 25 lines across 8 jobs. Readers would then have had to open a second file to understand any job.
  • A shared Cargo target directory for the c/ projects. Corrosion always passes its own --target-dir, so the projects import the prebuilt library instead.
  • Dropping nightly entirely. cbindgen on stable works only with RUSTC_BOOTSTRAP=1. Nightly stays, installed with --profile minimal, for header generation only.
  • A rust entry in mise.toml. It would repeat the version in rust-toolchain.toml. mise's idiomatic_version_file_enable_tools reads the toolchain file instead.
  • build-warnings: allow. warn keeps today's behaviour, where warnings print and don't fail. setup-rust-toolchain defaults to deny.
  • setup-conan's package cache. It saved on every run, which took 571 s on Windows. Explicit restore and save on master replace it.

Gaps recorded, not filled

  • Cross-process pact writes. write_pact can let one process read a file another has just truncated. Commit 15 works around it for pact_verifier's tests only.
  • MSRV. No crate declares rust-version, and adding one changes what users' resolvers see.
  • WASM tests. Running them needs a wasmtime runner.
  • Semver checks. release-plz runs them in PR 2.

Maintainer action after merge

  • Branch protection: require CI complete in place of the old job names.

Rust 1.99.0 miscompiled C `bool` returns from the FFI library; 1.99.1
carries the fix. A root toolchain file makes the test, FFI and release
jobs build with the same compiler as each other and as local builds.

mise pins the dev tooling CI installs, so local runs can use the same
versions. It reads Rust itself from rust-toolchain.toml, so the version
lives in one file.

The nextest `ci` profile reports every failure and kills hung tests.

Assisted-by: Claude Code:claude-opus-5-5
…ents

reqwest is built with `rustls-no-provider`, so building a client panics
unless a rustls crypto provider has been installed for the process.
Library entry points install the ring provider before building their own
clients. Several tests build their own client to call a mock server or
to feed a request into the code under test. Those tests passed only when
an earlier test in the same binary had already installed the provider.

Under nextest, which runs each test in its own process, and under
`cargo test <filter>`, those tests panic with "No rustls crypto
provider is configured". A small helper in each test module now
installs the provider before building the client.

Assisted-by: Claude Code:claude-opus-5-5
The CMake project refused to configure unless `cargo +nightly` existed,
and FindCargo reported nightly's version even though the library builds
with whichever toolchain `cargo` resolves to. With `rust-toolchain.toml`
pinning stable, FindCargo now reports the cargo that actually builds the
library, and the nightly gate is gone.

Header generation still needs nightly. cbindgen's macro expansion passes
`-Zunpretty=expanded`, which stable rejects, so the `rustup run nightly`
call sites stay.

Assisted-by: Claude Code:claude-opus-5-5
The examples under rust/pact_ffi/examples had no CI coverage.
.github/scripts/ffi-examples.sh builds pact_ffi once in release, the
profile that ships, and installs it under rust/pact_ffi/build/install.
Each example then runs against that install, and the C projects under
c/ reuse the same install.

The script replaces rust/pact_ffi/ci-build.sh. Only CI runs it, so it
sits with the workflows, not in the crate.

Assisted-by: Claude Code:claude-opus-5-5
Corrosion builds pact_ffi in release inside each project's own build
directory, so CI compiled the library twice per OS. With the variable
set, both projects link the install produced by
rust/pact_ffi/ci-build.sh and copy the library beside the executable,
where the run recipe expects it. Without it, local builds keep using
Corrosion.

The new root rust-toolchain.toml pins stable, which would otherwise
apply to the local Corrosion build. Corrosion runs cbindgen with no
toolchain override, and cbindgen's macro expansion needs nightly. The
justfiles therefore default RUSTUP_TOOLCHAIN to nightly, as the READMEs
already required; a caller's own RUSTUP_TOOLCHAIN still wins.

Assisted-by: Claude Code:claude-opus-5-5
Build, FFI and compatibility runs move into test.yml, gated by a single
`CI complete` check:

- Pull requests run once per commit, on Linux, macOS and Windows.
- Draft PRs run nothing heavy until marked ready.
- Caches save only from master, so PR runs restore master's entries
  without filling the repository's 10 GB budget.
- nextest runs the suite, with doctests run separately.
- The V2 matching engine and the ignored mock-server-log test reuse the
  same build.
- Compatibility v1-v4 share one compile per OS.
- pact_ffi builds once per OS, in release with the pinned toolchain, for
  every C example. Nightly is installed only for cbindgen.
- Windows legs build on a Dev Drive.
- A per-feature check replaces the single --no-default-features check.
  It skips pact_matching with `plugins` alone, which pact-plugin-driver
  currently breaks by using chrono's clock without enabling it.

Assisted-by: Claude Code:claude-opus-5-5
The issue title was interpolated straight into a `run:` script. The job
runs for anyone who comments `/jira ticket`, so anyone could open an
issue with a crafted title and execute commands on the runner, which
holds the Jira credentials. The title and the comment body now reach
the shell through environment variables.

Assisted-by: Claude Code:claude-opus-5-5
test.yml replaces the build, FFI and compatibility workflows.

The release build no longer runs on pull requests. Release PRs will
trigger it once the release process moves to PRs.

The remaining workflows pin actions by commit SHA and declare the
token permissions they use.

Assisted-by: Claude Code:claude-opus-5-5
The README badge points at test.yml, and the AppVeyor badge for a
service the repository no longer uses is gone. CLAUDE.md and the
Copilot instructions describe the pinned toolchain, the mise-managed
tools, nextest, and what test.yml covers.

Assisted-by: Claude Code:claude-opus-5-5
The release workflow named its own compiler, so it could drift from the
pin in rust-toolchain.toml. dtolnay/rust-toolchain also adds the matrix
`targets` only to the toolchain named in the action. The
aarch64-pc-windows-msvc leg cross-compiles on an x64 runner, so a
mismatch would leave the toolchain that builds without its standard
library.

actions-rust-lang/setup-rust-toolchain, given no `toolchain`, installs
the one rust-toolchain.toml names and adds `target` to it. The pin now
lives in one file. The action's caching stays off because the workflow
already runs Swatinem/rust-cache.

The pact_ffi README's "Release compiler" section went with the separate
pin. Its Dependencies section already says the library builds with the
pinned toolchain.

Assisted-by: Claude Code:claude-opus-5-5
The steps after nextest now run even when nextest fails. The
compatibility suite, the musl job and the doctests pass
`--no-fail-fast`, so one failing test binary no longer hides the
results of later ones.

@actions/cache passes GNU tar options such as `--posix`, which Alpine's
busybox tar rejects. rust-cache reports the failure as a warning, so the
musl job always built cold. The job now installs GNU tar.

Assisted-by: Claude Code:claude-opus-5-5
@JP-Ellis
JP-Ellis marked this pull request as ready for review October 16, 2026 23:03
mise pinned cargo-binstall, but the FFI job never installed it, so the
`cargo:` backend fell back to compiling cbindgen from source on every
cold run. The job now installs cargo-binstall alongside cbindgen.

mise.toml enables cargo-quickinstall as a binary source and sets
`binstall_only`, so a missing prebuilt binary fails the install instead
of silently compiling.

Assisted-by: Claude Code:claude-opus-5-5
…toolchain

Without PACT_FFI_PREBUILT_DIR, the C projects build pact_ffi through
Corrosion. Corrosion's cbindgen helper runs cbindgen with whatever
toolchain the environment selects, and cbindgen's macro expansion needs
nightly. The justfiles worked around this by defaulting
RUSTUP_TOOLCHAIN to nightly. Corrosion then built the whole library on
nightly too, unlike every other build in the repository.

mise now exports RUSTUP_TOOLCHAIN from rust-toolchain.toml, so the
justfile default no longer applied inside a mise environment, and the
header step would have run on the pinned toolchain and failed.

Each CMakeLists.txt now generates the header with its own
`rustup run nightly cbindgen` command, the same way rust/pact_ffi's
CMake project does. Corrosion builds the library with whichever
toolchain rust-toolchain.toml selects. The justfiles no longer set
RUSTUP_TOOLCHAIN.

Assisted-by: Claude Code:claude-opus-5-5
pact-plugin-driver called `Utc::now()` without enabling chrono's
`clock` feature, so pact_matching failed to build with `plugins` as its
only feature. The features job skipped that combination.
pact-plugins 801c1433 enables `clock`, and the lock now resolves the
driver to 7a290b6b, which carries that fix and moves to zip 9. Every
zip 8 release is yanked.

The features job now runs one `cargo hack check --each-feature` over
the whole workspace.

Assisted-by: Claude Code:claude-opus-5-5
pact_verifier's unit tests start mock servers that merge their
interactions into shared pact files, such as
RustPactVerifier-PactBrokerStub.json. `write_pact` serialises writers
with an in-process mutex only. Its new-file branch also truncates the
file before taking the file lock. `cargo test` runs these tests as
threads of one process, so the mutex was enough. nextest runs each test
in its own process, and on macOS CI eleven pact_broker tests failed
with "Failed to parse Pact JSON" after reading a file another process
had just truncated.

A nextest test group with one thread covers the `tests` and
`pact_broker::tests` modules of the pact_verifier library. That is
about 150 tests, and serialised they still take about 15 s. The race
in `write_pact` itself is left for a library change.

Assisted-by: Claude Code:claude-opus-5-5
@JP-Ellis
JP-Ellis merged commit 078e705 into master Oct 17, 2026
14 checks passed
@JP-Ellis
JP-Ellis deleted the ci/overhaul branch October 17, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant