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.

CI metrics and failure triage

A minimal set of CI metrics: duration in percentiles p50 and p90/p95, flaky rate from retries, pass rate of main and time to restore a green main. A metric is useful only if it has an owner and a threshold. Mass failures are grouped by message and stack, since 30 red tests usually have two or three causes, and then classified.

CI · Metrics and triage

Nightly: 30 red tests. Open them one by one or is there a faster way?

In the morning the nightly run shows 30 red tests. Opening them one by one takes half a day, and there are usually two or three causes. A pipeline is a product too, and its quality shows in numbers: how long it runs, how often it lies, how fast green is restored on main. The lesson covers a minimal set of CI metrics and the order for investigating mass failures.

Which metrics and why

  • Duration: p50 and p90/p95, not only the average. The average hides the long tail that annoys the team. Runner queue wait is measured separately.
  • Flaky rate: the share of test runs that passed only on a retry out of all test runs in a period. The weekly trend and the top most unstable tests are watched.
  • Pass rate of the main branch and the share of red PRs caused by non-code: infrastructure or flakiness.
  • MTTR of a red main: how fast green is restored.
  • Cost: runner minutes per PR, artifact size.

Where to get the data: the Playwright JSON reporter (stats.flaky is the number of tests with the flaky status) or JUnit XML, plus your CI's API. A metric is useful only if it has an owner and a threshold after which something is done.

Triage: the order

Investigating 30 failures

1. Groupby message and stack: 30 -> 2-3 causes2. When it beganlast green, what changed3. Classifyproduct / test / infrastructure4. Close the loopticket, fix, a check
Figure 1. From the noise of 30 tests to a few causes.

An example: of 30 failures 22 share "net::ERR_CONNECTION_REFUSED on staging", 6 fell on one locator after a button release, 2 are one-off timeouts. That is three causes: infrastructure, a test (or product) defect, flakiness. Tickets and owners differ, and different people should handle them.

// grouping failures from a JSON report: count by the start of the message
type Suite = { specs?: Spec[]; suites?: Suite[] };
type Spec = { tests: { results: { status: string; error?: { message?: string } }[] }[] };

const groups = new Map<string, number>();
const walk = (s: Suite) => {
  for (const spec of s.specs ?? [])
    for (const test of spec.tests)
      for (const r of test.results)
        if (r.status === 'failed' || r.status === 'timedOut') {
          const key = (r.error?.message ?? 'no message').split('\n')[0].slice(0, 80);
          groups.set(key, (groups.get(key) ?? 0) + 1);
        }
  (s.suites ?? []).forEach(walk);
};
report.suites.forEach(walk);
console.table([...groups].sort((a, b) => b[1] - a[1]));

The first rows of the table show the main cause at once. The script is crude: messages with different numbers or ids will fall into different groups, so they are worth normalising (replace numbers and identifiers). Even this version saves most of the time.

What to do with each class

  • Product defect: a ticket to developers with the trace.
  • Test defect: locator, race, data: a fix or quarantine with an owner and a deadline.
  • Infrastructure: a re-run and a ticket to the platform, not "raise the timeout".

Limits and mistakes

  • The difference between "red because of a bug" (the test did its job) and "red because of noise". If they are not told apart, the team learns to ignore red.
  • A retry that "cures" flakiness masks the flaky rate: it must be counted from retries, not only from the final status.
  • Collecting metrics without a threshold and an owner turns into a dashboard nobody opens.

Check yourself

Why is p90/p95 used for pipeline duration instead of the average?

Answer

The average hides the long tail: most runs are fast, but every tenth takes twice as long and that is the one the team remembers. Percentiles show the tail.

30 tests failed after a deploy. What is the first investigation step and why not open them one by one?

Answer

Group by message and stack: 30 failures usually come down to 2-3 causes, so you investigate causes, not tests.

In an interview. Junior: I look at pipeline duration, pass rate and flaky rate. I do not open mass failures one by one but group them by error. Middle/Senior: I measure duration with percentiles, count the flaky rate from retries and watch the trend. Triage: grouping, finding the last green run, classifying into product, test or infrastructure, and closing the loop with a check that prevents recurrence. That keeps red a signal, not noise.