Skip to content

Parallel Test Pipeline

Paulo Gomes da Cruz Junior edited this page Sep 11, 2026 · 3 revisions

Parallel Frontend Test Pipeline

Note: This page describes the Playwright-based parallel test pipeline with SonarCloud coverage merging. For Cypress E2E testing, see Cypress.

Why this change

The previous frontend CI path ran unit tests and end-to-end tests in one sequential job. That increased wall-clock runtime and delayed feedback.

This guide explains how to run those test groups in parallel while still producing a single merged coverage report for Sonar.

Goals

  1. Run frontend unit and end-to-end tests in parallel jobs.
  2. Keep unit tests parallelized with a fixed worker cap.
  3. Keep Playwright project dependencies intact.
  4. Merge all coverage artifacts before Sonar ingestion.
  5. Keep analysis.yml unchanged because it is devops-owned.

Playwright dependency expectations:

  • idir-chromium depends on idir-setup
  • bceid-chromium depends on bceid-setup

Final architecture

flowchart TD
  A[detect-changes] --> B[unit]
  A --> C[e2e-idir]
  A --> D[e2e-bceid]
  B --> E[merge-sonar]
  C --> E
  D --> E
  E --> F[SonarCloud]
Loading

Files changed

  • frontend/package.json
  • .github/workflows/reusable-tests-fe.yml

Step 1: Update package scripts

Edit frontend/package.json.

Set unit workers:

"test:unit": "vitest run --coverage --allowOnly --maxWorkers=2"

Add reusable merge script:

mkdir -p .nyc_output
cp coverage/coverage-final.json .nyc_output/unit-coverage.json
nyc merge .nyc_output .nyc_output/coverage.json
nyc report --reporter=lcov --reporter=cobertura --reporter=text-summary \
  --report-dir=coverage

Point posttest hook to the merge script:

"posttest:coverage": "npm run coverage:merge"

Notes:

  • maxWorkers=2 enforces the worker cap in CI.
  • coverage:merge lets the final merge job produce lcov for Sonar.

Step 2: Split frontend CI into parallel jobs

Replace .github/workflows/reusable-tests-fe.yml with a multi-job workflow.

Job layout

  • detect-changes: checks whether frontend/ changed.
  • unit: runs Vitest unit tests and uploads unit coverage.
  • e2e (matrix): runs Playwright for idir and bceid targets in parallel.
  • merge-sonar: downloads artifacts, merges coverage, and runs Sonar.

Required artifact names

  • coverage-unit from frontend/coverage/coverage-final.json
  • coverage-e2e-idir from frontend/.nyc_output/
  • coverage-e2e-bceid from frontend/.nyc_output/

The merge job downloads e2e artifacts with pattern coverage-e2e-*.

Why e2e artifacts merge safely

Playwright coverage output includes testInfo.testId in file names. That includes project identity and prevents idir/bceid collisions.

Step 3: Merge coverage and run Sonar

In merge-sonar:

  1. Checkout with full history (fetch-depth: 0).
  2. Download unit coverage and all e2e coverage artifacts.
  3. Setup Node 24.
  4. Run npm ci and npm run coverage:merge in frontend.
  5. Run SonarSource/sonarqube-scan-action with the existing frontend sonar args and token.

This keeps coverage assembly explicit and scans the merged lcov report.

Step 4: Keep caller workflow unchanged

No change is required in analysis.yml.

Reason: analysis.yml still calls reusable-tests-fe.yml as one reusable job named tests-frontend. Internal parallelization happens inside that workflow.

Validation checklist

  1. Unit tests run with maxWorkers=2.
  2. unit and both matrix variants of e2e run in parallel in Actions.
  3. merge-sonar starts only after all three test jobs pass.
  4. coverage/lcov.info is generated during merge-sonar.
  5. SonarCloud reports combined unit and e2e coverage.
  6. Backend-only PRs skip frontend tests via trigger detection.

Troubleshooting

merge-sonar cannot find coverage files

  • Confirm upload and download paths match exactly.
  • Confirm artifact names are exact.
  • Confirm the Sonar scan step runs after npm run coverage:merge.

Sonar runs but coverage is empty

  • Confirm npm run coverage:merge runs in frontend.
  • Confirm sonar.javascript.lcov.reportPaths points to coverage/lcov.info.
  • Confirm .nyc_output contains e2e coverage JSON before merge.

Frontend jobs run on backend-only changes

  • Confirm detect-changes uses trigger path ('frontend/').

Waste Plus Wiki

Home

Architecture

Codes

Decisions

Knowledge Base

Development

Changes

Clone this wiki locally