QA Interview Hub · Knowledge base · Quizzes · Українська

CI/CD › CI reports, artifacts and metrics

Reports and artifacts: what to keep and how to share

CI keeps an HTML report for people and JUnit XML for machines, and trace, video and screenshots only for failed tests and retries. Artifacts get a limited retention-days. In a sharded run each shard uploads a blob report and a separate job merges them into one HTML, both steps with !cancelled(). The report is published on a server, because a trace does not open from file://.

CI · Reports and artifacts

The run went red at 3 a.m. What must be in the run to investigate it in five minutes?

The nightly run failed, the shards finished, and the run has only a log of thousands of lines. To understand what broke you have to reproduce the failure locally, which takes an hour. If the run has a report, a trace and a screenshot, the cause is visible in minutes. The lesson covers which reports and artifacts to keep in CI, how to assemble them from sharded runs and how to share them with the team.

How it works and why

Reports are for people and for machines. The Playwright HTML report (playwright-report/) is for people: steps, screenshots, trace. JUnit XML is for machines: CI and third-party services show tests in their own UI, draw history and annotate PRs. Usually both are enabled, and in CI github (annotations in logs) or dot (compact output) is added.

// playwright.config.ts
export default defineConfig({
  reporter: process.env.CI
    ? [['blob'], ['junit', { outputFile: 'results/junit.xml' }], ['github']]
    : [['html', { open: 'never' }]],
  retries: process.env.CI ? 1 : 0,
  use: {
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
  },
});

Heavy diagnostics (trace, video, screenshots) are written only for failed tests and retries: on green ones they just add size. Artifacts get a retention-days (7–14 days is usually enough), otherwise storage grows endlessly. On sharded runs the blob reporter stores each shard's raw data so they can be merged into one report later.

From shard to a single report

Shards 1..Nblob-report-1 … blob-report-NMerge jobneeds: [e2e], if: !cancelled()merge-reportsone HTML reportPublishingartifact / Pages + a link in the PR
Figure 1. The path of a report in a sharded run.

Example: merging reports

Each shard uploads its blob and a separate job gathers them. The key places: if: ${{ !cancelled() }} on the shards and on the merge, otherwise after a red shard nothing is saved or merged, and merge-multiple: true puts the files of all shards in one folder.

  e2e:
    # ... shard matrix, install and run steps
    steps:
      - run: npx playwright test --shard=${{ matrix.shard }}
      - uses: actions/upload-artifact@v7
        if: ${{ !cancelled() }}
        with:
          name: blob-report-${{ strategy.job-index }}
          path: blob-report
          retention-days: 7

  merge-reports:
    needs: [e2e]
    if: ${{ !cancelled() }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with: { node-version: lts/* }
      - run: npm ci
      - uses: actions/download-artifact@v8
        with:
          path: all-blob-reports
          pattern: blob-report-*
          merge-multiple: true
      - run: npx playwright merge-reports --reporter html ./all-blob-reports
      - uses: actions/upload-artifact@v7
        with:
          name: html-report
          path: playwright-report
          retention-days: 14

An artifact name must be unique within a run because upload-artifact artifacts (since v4) are immutable: that is why the name includes the shard index.

How to share a report

A zip artifact has to be downloaded and unpacked. Traces in the HTML report do not open from file://: they need a server (npx playwright show-report or hosting). It is easier to publish the report on GitHub Pages or static hosting and put the link in a PR comment. For a short summary on the run page, write Markdown to the $GITHUB_STEP_SUMMARY file.

Notifications, limits and mistakes

  • Send to Slack/Teams only what matters: failures of nightly and main, not of every PR. In the message: the suite name, the failure count, links to the run and the report.
  • A report on public hosting can contain screenshots with data and headers: do not publish a report with secrets or real personal data.
  • Without if: !cancelled() the report disappears exactly when it is needed: after a red run.
  • A trace on every test "just in case" bloats storage and slows the run.

Check yourself

One shard is red and the report was not merged. What to check in the workflow?

Answer

Whether the merge job and the shard's upload step have if: !cancelled(). By default a step after a failure is skipped, so the blob is not uploaded or the merge does not start.

Why does the blob artifact name include the shard index?

Answer

upload-artifact artifacts (since v4) are immutable, so two shards with the same name conflict. Unique names with a shared prefix are gathered by pattern.

In an interview. Junior: I keep the HTML report for people and JUnit XML for CI, and trace and screenshots only for failed tests, with a limited retention. Middle/Senior: In a sharded run each shard produces a blob and a separate job with needs and if !cancelled() merges them via merge-reports into one HTML. I publish the report on a server because a trace does not open from file://, and add the link to the PR. Notifications only for nightly and main so the channel does not turn into noise.

More articles in this chapter