From fad703d4eef4c1ecb9ae57c20e249b52589c6191 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Thu, 4 Jan 2024 16:03:22 -0800 Subject: [PATCH] docs: update merge example to upload-artifact@v4 (#28849) Artifacts in upload-artifact@v4 are [immutable](https://github.com/actions/upload-artifact/tree/main?tab=readme-ov-file#breaking-changes), so we cannot simply copy reports into single artifact. Fixes https://github.com/microsoft/playwright/issues/28800 --- docs/src/test-sharding-js.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/src/test-sharding-js.md b/docs/src/test-sharding-js.md index 3522251593..3be5b3bcc8 100644 --- a/docs/src/test-sharding-js.md +++ b/docs/src/test-sharding-js.md @@ -51,9 +51,9 @@ GitHub Actions supports [sharding tests between multiple jobs](https://docs.gith The following example shows you how to configure a job to run your tests on four machines in parallel and then merge the reports into a single report. Don't forget to add `reporter: process.env.CI ? 'blob' : 'html',` to your `playwright.config.ts` file as in the example above. -1. First we add a `matrix` option to our job configuration with the `shard` option containing the number of shards we want to create. `shard: [1/4, 2/4, 3/4, 4/4]` will create four shards, each with a different shard number. +1. First we add a `matrix` option to our job configuration with the `shardTotal: [4]` option containing the total number of shards we want to create and `shardIndex: [1, 2, 3, 4]` with an array of the shard numbers. -1. Then we run our Playwright tests with the `--shard ${{ matrix.shard }}` option. This will our test command for each shard. +1. Then we run our Playwright tests with the `--shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}` option. This will run our test command for each shard. 1. Finally we upload our blob report to the GitHub Actions Artifacts. This will make the blob report available to other jobs in the workflow. @@ -73,7 +73,8 @@ jobs: strategy: fail-fast: false matrix: - shard: [1/4, 2/4, 3/4, 4/4] + shardIndex: [1, 2, 3, 4] + shardTotal: [4] steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 @@ -85,13 +86,13 @@ jobs: run: npx playwright install --with-deps - name: Run Playwright tests - run: npx playwright test --shard ${{ matrix.shard }} + run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} - name: Upload blob report to GitHub Actions Artifacts if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: all-blob-reports + name: blob-report-${{ matrix.shardIndex }} path: blob-report retention-days: 1 ``` @@ -116,16 +117,17 @@ jobs: run: npm ci - name: Download blob reports from GitHub Actions Artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: all-blob-reports path: all-blob-reports + pattern: blob-report-* + merge-multiple: true - name: Merge into HTML Report run: npx playwright merge-reports --reporter html ./all-blob-reports - name: Upload HTML report - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: html-report--attempt-${{ github.run_attempt }} path: playwright-report