Skip to content

ci: Reuse the workspace build for the pwsh integration tests - #1690

Merged
coroiu merged 2 commits into
mainfrom
ci/integration-tests-reuse-build
Oct 29, 2026
Merged

coroiu merged 2 commits into
mainfrom
ci/integration-tests-reuse-build

Conversation

@coroiu

@coroiu coroiu commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-46492

📔 Objective

The pwsh integration step in rust-test.yml recompiled about 219 crates before running about 25 s of tests. -p bitwarden-access-connector --all-features resolves a different feature set than the --workspace --all-features step before it, so cargo can't reuse that build. On Windows the compile took 339 s. Linux and macOS spend 2-4 min on the step.

Selecting the test target under the workspace feature set compiles in 0.9 s on Windows and runs the same 5 tests.

The step now only runs tests/scripting_integration.rs. All #[ignore]d tests in the crate are in that file, and the workflow comment says new ones belong there too.

If #1691 merges as well, this step also needs ${{ matrix.exclude }}, so its features match the trimmed build on Windows and macOS.

🤖 AI-assisted review

Local review (code-review-local) of the branch diff: 0 findings, none deferred.

`cargo test -p bitwarden-access-connector --all-features` resolves a
different feature set than the `--workspace --all-features` step before
it, so it recompiled about 219 crates before running about 25 s of tests.
That took 339 s on Windows and 2-4 min on Linux and macOS. Selecting the
test target under the workspace feature set reuses the existing build
(0.9 s on Windows) and runs the same 5 tests.
@coroiu coroiu added the ai-review Request a Claude code review label Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

I re-reviewed the PR after main was merged in (8c223b7). The PR diff has not changed: it is still the single pwsh integration step in .github/workflows/rust-test.yml, which now runs cargo test --workspace --all-features --test scripting_integration. The commits merged from main touch only bitwarden-pam, lint.yml, and a TypeScript integration test, and they add no #[ignore]d tests to bitwarden-access-connector. Every ignored test in that crate is still in tests/scripting_integration.rs, and no other workspace crate has a test target with that name, so the step still runs the same tests and reuses the workspace build.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🔍 SDK Breaking Change Detection

SDK Version: ci/integration-tests-reuse-build (46e1f5d)

⚠️ If breaking changes are detected, a corresponding pull request addressing them must be ready for merge in the affected client repository.

Client Status Details
android ✅ No breaking changes detected Compilation passed with new SDK version - View Details
typescript ✅ No breaking changes detected Compilation passed with new SDK version - View Details

Breaking change detection uses the build of the SDK from this branch, including any incompatibities pre-existing on or merged into this branch. Check the workflow logs to confirm.
Results update as workflows complete.

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.60%. Comparing base (4d983d7) to head (8c223b7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1690   +/-   ##
=======================================
  Coverage   87.60%   87.60%           
=======================================
  Files         682      682           
  Lines      105107   105107           
=======================================
  Hits        92079    92079           
  Misses      13028    13028           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coroiu
coroiu requested a review from Hinton October 28, 2026 15:16
@coroiu
coroiu marked this pull request as ready for review October 28, 2026 15:16
@coroiu
coroiu requested a review from a team as a code owner October 28, 2026 15:16
@coroiu
coroiu requested a review from djsmith85 October 28, 2026 15:16
@coroiu
coroiu merged commit 7179491 into main Oct 29, 2026
70 of 73 checks passed
@coroiu
coroiu deleted the ci/integration-tests-reuse-build branch October 29, 2026 08:06
bw-ghapp Bot added a commit to bitwarden/sdk-swift that referenced this pull request Oct 29, 2026
coroiu added a commit that referenced this pull request Oct 29, 2026
## 🎟️ Tracking

No ticket. Stacked on #1683. The measurements are in runs 40668535016
and 40677921684 on the throwaway branch `ci/windows-speed-experiments`.

## 📔 Objective

On the 4-vCPU runners, the Windows test build is CPU-bound, so compiling
less makes the job shorter. Each change was measured as an A/B on the
same Windows runner, in both orders, with dependencies already built as
with a warm cache:

| Change | Workspace rebuild on Windows |
|---|---|
| `opt-level = 0` for `bitwarden-api-api` and `bitwarden-api-identity`,
in CI only | 13-16% faster, test run time unchanged |
| Skip `bitwarden-uniffi`, `uniffi-bindgen`, `bitwarden-wasm-internal`
and `wasm-bindgen-cli-runner` on Windows and macOS | 12-13% faster |

The `opt-level` override is appended to `.cargo/config.toml` on the
runner, so local dev and debug WASM builds keep `opt-level = 1`. Cargo
ignores per-package `opt-level` from environment variables, and a config
file reaches every cargo command in the job.

The skipped crates' native tests are platform-independent and still run
on Linux. The uniffi code that differs per platform is gated on Android
and iOS, which no test job runs. The Swift, Android and WASM workflows
build those targets.

Together with #1690, the Windows job went from about 24.8 to 16 min in
the same A/B setup. The build-side savings don't fully add up (about 200
s combined against 280 s measured one by one). With #1683's cache, most
PRs rebuild fewer crates, so the saving per PR is smaller. It matters
most when a core crate changes. I did not measure macOS.

The pwsh step from #1690 uses `${{ matrix.exclude }}` as well. It has to
build the same packages as the test step, or it rebuilds the workspace
crates on Windows and macOS.

## 🤖 AI-assisted review

Local review (`code-review-local`) of the branch diff: 0 findings, none
deferred.
coroiu added a commit that referenced this pull request Nov 3, 2026
**TL;DR: The build and lint workflows only rebuild what a PR changed.**
With the Rust tests fixed in #1683, the slowest checks on a PR were the
WASM build (19.6 min median), Android (16.4), Swift (16.4) and Lint
(14.8). Each now uses the build cache from #1683, through a shared
action in bitwarden/gh-actions, and drops duplicate work, so a typical
PR's checks should finish in about 10 minutes, and much of that is the
clients and Android breaking-change checks.

## 🎟️ Tracking

No ticket. Follow-up to #1683, #1690 and #1691. Uses the
`cargo-build-cache` action from bitwarden/gh-actions#1006.

## 📔 Objective

Each workflow was measured on its own experiment branch with
`workflow_dispatch`, against the latest successful PR run on `main`.
Single runs per scenario.

| Workflow | PR median on `main` (before) | Leaf-crate change |
`bitwarden-core` change |
|---|---|---|---|
| Lint | 14.8 min | 1.9 min | 3.1 min |
| WASM build | 19.6 min | 4.4 min (PR mode) | 8.9 min (full build) |
| Swift | 16.4 min | Build job 4.2 min | 9.3 min (whole run) |
| Android | 16.4 min | Build jobs about 2 min, Combine about 2 min |
Build jobs about 2.5-3 min |

The clients and Android breaking-change checks (about 5 min each) wait
on the other repo and are unchanged. I haven't measured a full PR end to
end, since the experiments ran as dispatches.

One commit per fix:

**Swift**
- Build the three Apple targets in one cargo call. Each target ended
with a single-threaded LTO step, and now those steps overlap. Output is
byte-identical.
- Build cache in the Build job.

**Android**
- Build cache per ABI. rust-cache did restore, but its cleanup deletes
`target/<triple>/release` before saving, so about 318 dependencies
compiled in every run. The `cross` image digest is part of the key,
because the NDK and linker are not in cargo's fingerprints. The
workspace is mounted at the same path inside the container, so the mtime
marking works there too.
- Cache `cross` itself (`.bin`), which was compiled from git on every
run (42 s). This cache has no restore keys, because cargo-run-bin stores
`cross` under its version, not its git rev.
- Gradle build cache for the demo app build. Tasks with unchanged inputs
come from the cache. A PR that changes the uniffi API changes the
bindings, so those PRs get less out of it.

**Lint**
- Run clippy once. `lint.sh` set `RUSTFLAGS="-D warnings"`, so its
clippy run after the SARIF step rechecked all ~630 crates. The SARIF
step is now the gate, with `pipefail`, and findings are still uploaded
when it fails.
- Build cache for clippy, doc and udeps. Before, the shared rust-cache
key held no `target/` at all.
- Keep udeps fresh across toolchain installs. cargo-udeps records the
nightly sysroot files in every crate's dep-info, and a fresh toolchain
install gives them new mtimes, so all 547 dependencies were checked
again.

**WASM**
- `fix:` The `bitwarden-wasm-internal` build script reran on any file
change but not on a changed `SDK_VERSION` or a new commit. With a cached
`target/`, the package could embed an old version string. It now reruns
on those.
- Build cache per license.
- Keep the rust-src mtimes stable. `-Zbuild-std` compiles the standard
library from rust-src, which gets new mtimes on every toolchain install,
so all 364 crates rebuilt even with the cache.
- Run `wasm-opt` once. The bundler and nodejs `.wasm` files were
byte-identical in every run, so the second is a copy. The script checks
this each time and falls back to optimizing both.
- Build the MVP/wasm2js fallback in parallel with the SIMD build
(`build.sh -p`, used in CI). Local `./build.sh -r` stays sequential.
- On pull requests, skip `wasm-opt`, `wasm2js` and `terser` for the
fallback (`build.sh -s`). Nothing in the PR flow loads the fallback: the
clients check only type-checks the package, and the integration tests
load the Node build. The MVP cargo build and the check that both builds
share one glue file still run. `main` builds the full package as before.

### What a PR no longer checks

- `wasm-opt`, `wasm2js` and `terser` on the WASM fallback. Failures
there show up on `main`.
- The PR package's fallback file is a stub, the same as in debug builds.

### Output

- WASM: all 751 package files are byte-identical between a clean build
and a cached build, except `VERSION` (the commit hash).
- Swift: the `.a` files and all generated `.swift`, `.h` and
`.modulemap` files are byte-identical to `main`. The xcframework's
`Info.plist` differs only in the order of `AvailableLibraries`, which
also changes between runs on `main`.

### Good to know

- Builds on `main`, including the ones that publish, also use the cache.
The comparisons above showed no difference from clean builds.
- The first run of each workflow after merge has no cache yet and takes
about as long as before this change.
- The last two commits replace the cache steps in all workflows,
including `rust-test.yml` from #1683, with one
`bitwarden/gh-actions/cargo-build-cache` step, and delete
`scripts/ci-build-cache.sh`. The action uses the same logic, and is
measured as fast as the copies in all five workflows. Its cache keys
start with `cargo-build-`, so the first run of each workflow after merge
is cold, including Rust tests.
- The action saves through `actions/cache` at the end of the job, which
only happens when the job succeeded. A job that fails after a successful
build, for example on a failing test, no longer saves its build output,
and the next run falls back to an older cache. Lint already behaved that
way.
- Pre-existing and out of scope here: the `cross` images (`:main`),
`binaryen` and `terser` are unpinned.

## 🤖 AI-assisted review

- Multi-agent review (architecture, code quality, bug analysis,
security, then validation and severity audit). Two Refactor findings, no
Blockers or Important ones.
- Fixed: the Android `.bin` cache had a prefix restore key.
cargo-run-bin stores `cross` under its version only, not its git rev, so
after a rev bump the old binary would have been restored and used on
`main`. The cache now has no restore keys.
- Addressed: the cache steps were copied into six places. The last
commit replaces them with the shared action from
bitwarden/gh-actions#1006.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants