Skip to content

Commit

Permalink
feat(roll): roll to ToT Playwright (09-08-23) (#1118)
Browse files Browse the repository at this point in the history
  • Loading branch information
playwrightmachine authored Aug 9, 2023
1 parent 2c2ce58 commit 2da2558
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 34 deletions.
50 changes: 19 additions & 31 deletions nodejs/docs/ci.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,13 @@ on:
branches: [ main, master ]
jobs:
playwright:
name: 'Playwright Tests - ${{ matrix.project }} - Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }}'
name: 'Playwright Tests - ${{ matrix.project }} - Shard ${{ matrix.shard }}'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: [chromium, webkit]
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
shardTotal: [10]
shard: [1/10, 2/10, 3/10, 4/10, 5/10, 6/10, 7/10, 8/10, 9/10, 10/10]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -110,7 +109,7 @@ jobs:
- name: Install browsers
run: npx playwright install --with-deps
- name: Run your tests
run: npx playwright test --project=${{ matrix.project }} --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
run: npx playwright test --project=${{ matrix.project }} --shard=${{ matrix.shard }}
```
> Note: The `${{ <expression> }}` is the [expression](https://docs.github.com/en/actions/learn-github-actions/expressions) syntax that allows accessing the current [context](https://docs.github.com/en/actions/learn-github-actions/contexts). In this example, we are using the [`matrix`](https://docs.github.com/en/actions/learn-github-actions/contexts#matrix-context) context to set the job variants.
Expand Down Expand Up @@ -156,16 +155,15 @@ on:
branches: [ main, master ]
jobs:
playwright:
name: 'Playwright Tests - ${{ matrix.project }} - Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }}'
name: 'Playwright Tests - ${{ matrix.project }} - Shard ${{ matrix.shard }}'
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.36.2-jammy
strategy:
fail-fast: false
matrix:
project: [chromium, webkit]
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
shardTotal: [10]
shard: [1/10, 2/10, 3/10, 4/10, 5/10, 6/10, 7/10, 8/10, 9/10, 10/10]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -174,7 +172,7 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Run your tests
run: npx playwright test --project=${{ matrix.project }} --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
run: npx playwright test --project=${{ matrix.project }} --shard=${{ matrix.shard }}
```
#### On deployment
Expand Down Expand Up @@ -313,40 +311,31 @@ strategy:
matrix:
chromium-1:
project: chromium
shardIndex: 1
shardTotal: 3
shard: 1/3
chromium-2:
project: chromium
shardIndex: 2
shardTotal: 3
shard: 2/3
chromium-3:
project: chromium
shardIndex: 3
shardTotal: 3
shard: 3/3
firefox-1:
project: firefox
shardIndex: 1
shardTotal: 3
shard: 1/3
firefox-2:
project: firefox
shardIndex: 2
shardTotal: 3
shard: 2/3
firefox-3:
project: firefox
shardIndex: 3
shardTotal: 3
shard: 3/3
webkit-1:
project: webkit
shardIndex: 1
shardTotal: 3
shard: 1/3
webkit-2:
project: webkit
shardIndex: 2
shardTotal: 3
shard: 2/3
webkit-3:
project: webkit
shardIndex: 3
shardTotal: 3
shard: 3/3
steps:
- task: NodeTool@0
inputs:
Expand All @@ -357,7 +346,7 @@ steps:
displayName: 'npm ci'
- script: npx playwright install --with-deps
displayName: 'Install Playwright browsers'
- script: npx playwright test --project=$(project) --shard=$(shardIndex)/$(shardTotal)
- script: npx playwright test --project=$(project) --shard=$(shard)
displayName: 'Run Playwright tests'
env:
CI: 'true'
Expand Down Expand Up @@ -470,7 +459,7 @@ tests:
- npx playwright test --shard=$CI_NODE_INDEX/$CI_NODE_TOTAL
```
GitLab CI also supports sharding tests between multiple jobs using the [parallel:matrix](https://docs.gitlab.com/ee/ci/yaml/index.html#parallelmatrix) option. The test job will run multiple times in parallel in a single pipeline, but with different variable values for each instance of the job. In the example below, we have 2 `PROJECT` values, 10 `SHARD_INDEX` values and 1 `SHARD_TOTAL` value, resulting in a total of 20 jobs to be run.
GitLab CI also supports sharding tests between multiple jobs using the [parallel:matrix](https://docs.gitlab.com/ee/ci/yaml/index.html#parallelmatrix) option. The test job will run multiple times in parallel in a single pipeline, but with different variable values for each instance of the job. In the example below, we have 2 `PROJECT` values and 10 `SHARD` values, resulting in a total of 20 jobs to be run.
```yml
stages:
Expand All @@ -482,11 +471,10 @@ tests:
parallel:
matrix:
- PROJECT: ['chromium', 'webkit']
SHARD_INDEX: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
SHARD_TOTAL: 10
SHARD: ['1/10', '2/10', '3/10', '4/10', '5/10', '6/10', '7/10', '8/10', '9/10', '10/10']
script:
- npm ci
- npx playwright test --project=$PROJECT --shard=$SHARD_INDEX/$SHARD_TOTAL
- npx playwright test --project=$PROJECT --shard=$SHARD
```
## Caching browsers
Expand Down
6 changes: 3 additions & 3 deletions nodejs/docs/test-sharding.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
shard: [1/4, 2/4, 3/4, 4/4]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -74,7 +74,7 @@ jobs:
run: npx playwright install

- name: Run Playwright tests
run: npx playwright test --shard ${{ matrix.shard }}/4
run: npx playwright test --shard ${{ matrix.shard }}

- name: Upload blob report to GitHub Actions Artifacts
if: always()
Expand Down Expand Up @@ -158,7 +158,7 @@ Supported options:
Example: `npx playwright merge-reports --reporter=html,github ./blob-reports`
- `--config path/to/config/file`

Takes reporters from Playwright configuration file.
Specifies the Playwright configuration file with output reporters. Use this option to pass additional configuration to the output reporter. This configuration file can differ from the one used during the creation of blob reports.

Example: `npx playwright merge-reports --config=merge.config.ts ./blob-reports`

Expand Down

0 comments on commit 2da2558

Please sign in to comment.