refactor: use playwright docker image for e2e tests

This commit is contained in:
taroj1205 2025-06-22 18:39:03 +12:00
parent c540cc914e
commit 4e2eccbbc9
No known key found for this signature in database
GPG key ID: 0FCB6CFFE0981AB7
3 changed files with 16 additions and 21 deletions

View file

@ -183,6 +183,9 @@ jobs:
needs: [check_changes, setup, build] needs: [check_changes, setup, build]
if: ${{ needs.check_changes.outputs.exists == 'true' }} if: ${{ needs.check_changes.outputs.exists == 'true' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.53.0-jammy
options: --ipc=host
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
@ -211,11 +214,6 @@ jobs:
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/pnpm-lock.yaml') }} key: ${{ runner.os }}-node-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-node-modules- restore-keys: ${{ runner.os }}-node-modules-
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Setup pnpm - name: Setup pnpm
uses: pnpm/action-setup@v4 uses: pnpm/action-setup@v4
with: with:
@ -225,18 +223,8 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true' if: steps.cache.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
- name: Cache Playwright Browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-playwright-
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright Tests (4 Shards) - name: Run Playwright Tests (4 Shards)
run: pnpm exec turbo run test:e2e:shard1 test:e2e:shard2 test:e2e:shard3 test:e2e:shard4 run: pnpm exec turbo run test:e2e:all
timeout-minutes: 10 timeout-minutes: 10
- name: Upload Playwright Report - name: Upload Playwright Report

View file

@ -26,6 +26,7 @@
"test:e2e:shard2": "playwright test --shard=2/4", "test:e2e:shard2": "playwright test --shard=2/4",
"test:e2e:shard3": "playwright test --shard=3/4", "test:e2e:shard3": "playwright test --shard=3/4",
"test:e2e:shard4": "playwright test --shard=4/4", "test:e2e:shard4": "playwright test --shard=4/4",
"test:e2e:all": "turbo run test:e2e:all",
"prepare": "lefthook install" "prepare": "lefthook install"
}, },
"dependencies": { "dependencies": {

View file

@ -30,30 +30,36 @@
"inputs": ["src/**/*.{ts,tsx,js,jsx,astro,md,json,yml,yaml}"], "inputs": ["src/**/*.{ts,tsx,js,jsx,astro,md,json,yml,yaml}"],
"outputs": [] "outputs": []
}, },
"test:playwright": { "test:e2e": {
"cache": true, "cache": true,
"inputs": ["**/*.{ts,tsx,js,jsx,astro}"], "inputs": ["**/*.{ts,tsx,js,jsx,astro}"],
"outputs": ["playwright-report/**", "test-results/**"] "outputs": ["playwright-report/**", "test-results/**"]
}, },
"test:playwright:shard1": { "test:e2e:shard1": {
"cache": true, "cache": true,
"inputs": ["**/*.{ts,tsx,js,jsx,astro}"], "inputs": ["**/*.{ts,tsx,js,jsx,astro}"],
"outputs": ["playwright-report/**", "test-results/**"] "outputs": ["playwright-report/**", "test-results/**"]
}, },
"test:playwright:shard2": { "test:e2e:shard2": {
"cache": true, "cache": true,
"inputs": ["**/*.{ts,tsx,js,jsx,astro}"], "inputs": ["**/*.{ts,tsx,js,jsx,astro}"],
"outputs": ["playwright-report/**", "test-results/**"] "outputs": ["playwright-report/**", "test-results/**"]
}, },
"test:playwright:shard3": { "test:e2e:shard3": {
"cache": true, "cache": true,
"inputs": ["**/*.{ts,tsx,js,jsx,astro}"], "inputs": ["**/*.{ts,tsx,js,jsx,astro}"],
"outputs": ["playwright-report/**", "test-results/**"] "outputs": ["playwright-report/**", "test-results/**"]
}, },
"test:playwright:shard4": { "test:e2e:shard4": {
"cache": true, "cache": true,
"inputs": ["**/*.{ts,tsx,js,jsx,astro}"], "inputs": ["**/*.{ts,tsx,js,jsx,astro}"],
"outputs": ["playwright-report/**", "test-results/**"] "outputs": ["playwright-report/**", "test-results/**"]
},
"test:e2e:all": {
"cache": true,
"dependsOn": ["test:e2e:shard1", "test:e2e:shard2", "test:e2e:shard3", "test:e2e:shard4"],
"inputs": ["**/*.{ts,tsx,js,jsx,astro}"],
"outputs": ["playwright-report/**", "test-results/**"]
} }
}, },
"ui": "tui" "ui": "tui"