Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mrc-5445 Make e2e tests run in parallel #42

Merged
merged 13 commits into from
Jun 11, 2024
40 changes: 40 additions & 0 deletions .github/actions/run-e2e-shard/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Run E2E shard

inputs:
shard:
description: "What shard to run, out of 6"
required: true

runs:
using: "composite"
steps:
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install dependencies
run: npm ci
shell: bash

- name: Get installed Playwright version
id: playwright-version
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').packages['node_modules/@playwright/test'].version)")" >> $GITHUB_ENV
shell: bash

- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}

- run: npx playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
shell: bash

- name: Run e2e tests
shell: bash
run: npm run test:e2e:${{ inputs.shard }}
26 changes: 0 additions & 26 deletions .github/workflows/e2e.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/e2e1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: E2E Tests Part 1
on:
push:
branches:
- main
pull_request:
branches:
- main
- "mrc-*"
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run E2E shard
uses: ./.github/actions/run-e2e-shard
with:
shard: 1
20 changes: 20 additions & 0 deletions .github/workflows/e2e2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: E2E Tests Part 2
on:
push:
branches:
- main
pull_request:
branches:
- main
- "mrc-*"
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run E2E shard
uses: ./.github/actions/run-e2e-shard
with:
shard: 2
20 changes: 20 additions & 0 deletions .github/workflows/e2e3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: E2E Tests Part 3
on:
push:
branches:
- main
pull_request:
branches:
- main
- "mrc-*"
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run E2E shard
uses: ./.github/actions/run-e2e-shard
with:
shard: 3
20 changes: 20 additions & 0 deletions .github/workflows/e2e4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: E2E Tests Part 4
on:
push:
branches:
- main
pull_request:
branches:
- main
- "mrc-*"
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run E2E shard
uses: ./.github/actions/run-e2e-shard
with:
shard: 4
20 changes: 20 additions & 0 deletions .github/workflows/e2e5.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: E2E Tests Part 5
on:
push:
branches:
- main
pull_request:
branches:
- main
- "mrc-*"
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run E2E shard
uses: ./.github/actions/run-e2e-shard
with:
shard: 5
20 changes: 20 additions & 0 deletions .github/workflows/e2e6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: E2E Tests Part 6
on:
push:
branches:
- main
pull_request:
branches:
- main
- "mrc-*"
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run E2E shard
uses: ./.github/actions/run-e2e-shard
with:
shard: 6
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dengue-map",
"version": "0.5.0",
"version": "0.7.0",
"type": "module",
"engines": {
"node": "^20.0.0"
Expand All @@ -14,7 +14,13 @@
"lint": "eslint . --ignore-path .gitignore",
"test:unit": "vitest",
"test:coverage": "vitest --coverage",
"test:e2e": "playwright test"
"test:e2e": "playwright test",
"test:e2e:1": "playwright test --shard=1/6",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you actually need these? You can pass command line args through to the npm scripts, so couldn't you just call
npm run test:e2e -- --shard=${{ inputs.shard }}/6 from the action?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, that is much better! also done it in one workflow file!

"test:e2e:2": "playwright test --shard=2/6",
"test:e2e:3": "playwright test --shard=3/6",
"test:e2e:4": "playwright test --shard=4/6",
"test:e2e:5": "playwright test --shard=5/6",
"test:e2e:6": "playwright test --shard=6/6"
},
"dependencies": {
"@mdi/font": "6.2.95",
Expand Down
3 changes: 2 additions & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
testDir: "./tests/e2e",
fullyParallel: true,
/* Maximum time one test can run for. */
timeout: process.env.CI ? 60 * 1000 : 30 * 1000,
timeout: process.env.CI ? 30 * 1000 : 15 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
Expand Down
Loading