Sharding Usage in CI/CD

Why Sharding Matters

The merge-pulse-report utility simplifies the aggregation of test results from multiple parallel CI nodes.

The "One-Command" Logic

The complexity of merging distributed reports is hidden behind a single command.

  • Auto-Discovery: Just place your shard report folders into a single directory and run merge-pulse-report -o all-reports. The script finds every partial JSON automatically.
  • Attachment Synchronization: It intelligently collects screenshots, videos, and traces from all shards into one central attachments/ folder.
  • Clean Workspace: After a successful merge, it automatically cleans up temporary shard directories, leaving you with a production-ready report folder.

CI/CD Workflow for Sharding

# .github/workflows/pytest-sharding.yml
name: Distributed Pytest Runs
on: [push]

jobs:
  test:
    strategy:
      matrix:
        shard: [1, 2, 3, 4]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.14'
      - run: pip install pytest-pulse-report playwright
      - run: playwright install --with-deps
      # Run a subset of tests on each shard
      - run: pytest --shard-id=${{ matrix.shard }} --total-shards=4
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: pulse-report-shard-${{ matrix.shard }}
          path: pulse-report/

  merge-report:
    needs: test
    if: always()
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pip install pytest-pulse-report
      
      # Download all artifacts into 'all-reports'
      - uses: actions/download-artifact@v4
        with:
          path: all-reports
          pattern: pulse-report-shard-*

      # Merge and Generate final report
      - run: merge-pulse-report -o all-reports
      - run: generate-pulse-report -o all-reports

      - uses: actions/upload-artifact@v4
        with:
          name: final-pulse-report
          path: all-reports/