From f2d7122a4f55f42a90512b4074e2e148ae4c7eb3 Mon Sep 17 00:00:00 2001 From: Andrii Tsok Date: Sat, 18 Apr 2026 17:02:49 +0000 Subject: [PATCH] fix(nx-ci): coverage=true still runs `test` on every affected project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously when `coverage: true`, the workflow REPLACED the `test` target with `test:coverage`. That meant only projects with a `test:coverage` target got tested at all — everything else was silently skipped. In the MCPG workspace that's catastrophic: 27 of 28 Rust crates have `test` but no `test:coverage`, so CI was effectively only running the main app's tests. Plugins, libraries, and the other app were not being exercised at all when coverage was enabled. Fix: when coverage is on, run BOTH `-t test,test:coverage`. Nx gracefully skips projects that don't define the target, so only projects with a dedicated coverage runner (e.g. cargo-llvm-cov) run the instrumented pass. Everything else still gets a plain test run. Projects that define both (like apps/mcpg) will run their tests twice — once plain, once instrumented. That's fine: tests are fast vs compile time, and the duplication is only on projects that opted into both. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/nx-ci.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nx-ci.yml b/.github/workflows/nx-ci.yml index 0b98eec..528030a 100644 --- a/.github/workflows/nx-ci.yml +++ b/.github/workflows/nx-ci.yml @@ -437,13 +437,21 @@ jobs: CMD="$CMD run-many" fi - # When coverage: true, run the project's `test:coverage` target - # (e.g., `cargo llvm-cov` for Rust, `jest --coverage` for TS) - # instead of the plain `test` target. This avoids the old - # approach of appending `--coverage` to the test command, which - # broke for cargo (cargo test has no --coverage flag). + # Always run `test` on every affected project so no crate is skipped. + # When coverage: true, ALSO run `test:coverage` on any project that + # has that target defined — that's the project-specific instrumented + # test run (e.g. `cargo llvm-cov` for Rust) which produces lcov.info. + # + # Nx's comma-separated target list runs both in one invocation; + # projects without `test:coverage` just skip that half. A project + # like Rust's mcpg with both targets will run tests twice — once + # plain and once instrumented — which is fast and correct. + # + # Prior behavior replaced `test` with `test:coverage` when coverage + # was true; that silently skipped every crate without a dedicated + # coverage target (e.g. 27 of 28 crates in the MCPG workspace). if [ "${{ inputs.coverage }}" == "true" ]; then - CMD="$CMD -t test:coverage --parallel=${{ inputs.parallel }}" + CMD="$CMD -t test,test:coverage --parallel=${{ inputs.parallel }}" else CMD="$CMD -t test --parallel=${{ inputs.parallel }}" fi