Advanced
Shard merging
Run Playwright shards in parallel, collect their JSON output, and merge everything into a single PDF in a final job, without re-running any tests.
How it works
- Each shard runs with PLAYWRIGHT_REPORTERS=json and writes a JSON results file.
- The JSON files are uploaded as CI artifacts.
- A merge job downloads all shard artifacts and sets SHARD_RESULTS_GLOB to a glob that matches them.
- The reporter reads the glob, merges results in-memory, and renders a single PDF.
The merge job only runs the PDF renderer; it does not execute any tests. Chrome is launched once.
Reporter config for the merge job
In the merge job, run the reporter in merge mode by pointing it at the collected JSON files. No changes are needed to your existing playwright.config.ts.
# Set this env var before running npx playwright testSHARD_RESULTS_GLOB=results/shard-*.json# Reporter config (same playwright.config.ts, merge-mode is auto-detected)reporter: [['@reportforge/playwright-pdf', { outputFile: 'reports/{date}-{branch}-{status}.pdf', template: 'detailed',}]]When SHARD_RESULTS_GLOB is set, the reporter reads JSON files instead of collecting live test events. Tests are not executed.
GitHub Actions: full workflow
# .github/workflows/test.ymljobs: test: strategy: matrix: shard: [1, 2, 3, 4] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 22 } - run: npm ci - run: npx playwright test --shard=${{ matrix.shard }}/4 env: PLAYWRIGHT_JSON_OUTPUT_NAME: results/shard-${{ matrix.shard }}.json PLAYWRIGHT_REPORTERS: json - uses: actions/upload-artifact@v4 if: always() with: name: shard-${{ matrix.shard }} path: results/shard-${{ matrix.shard }}.json merge-report: needs: test if: always() runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 22 } - run: npm ci - name: Install Chrome run: | wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | \ sudo gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] \ http://dl.google.com/linux/chrome/deb/ stable main" | \ sudo tee /etc/apt/sources.list.d/google-chrome.list sudo apt-get update -qq && sudo apt-get install -y google-chrome-stable - uses: actions/download-artifact@v4 with: pattern: shard-* merge-multiple: true path: results - run: npx playwright test --reporter=@reportforge/playwright-pdf env: PUPPETEER_EXECUTABLE_PATH: /usr/bin/google-chrome-stable RF_LICENSE_KEY: ${{ secrets.RF_LICENSE_KEY }} SHARD_RESULTS_GLOB: results/shard-*.json - uses: actions/upload-artifact@v4 if: always() with: name: playwright-pdf-report path: reports/*.pdfKnown limitation
History trending (historyDir) is not supported in merge mode. The history JSON is written after a merge run but the trend chart will only show the merged run as a single data point, not per-shard history. Run history tracking on your staging or nightly full (non-sharded) run instead.