From 4e2eccbbc92f3ecaf4cd9863fd34b78ff930169a Mon Sep 17 00:00:00 2001 From: taroj1205 Date: Sun, 22 Jun 2025 18:39:03 +1200 Subject: [PATCH] refactor: use playwright docker image for e2e tests --- .github/workflows/ci-pipeline.yml | 20 ++++---------------- package.json | 1 + turbo.json | 16 +++++++++++----- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 15d4dfa..198c690 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -183,6 +183,9 @@ jobs: needs: [check_changes, setup, build] if: ${{ needs.check_changes.outputs.exists == 'true' }} runs-on: ubuntu-latest + container: + image: mcr.microsoft.com/playwright:v1.53.0-jammy + options: --ipc=host steps: - uses: actions/checkout@v4 with: @@ -211,11 +214,6 @@ jobs: key: ${{ runner.os }}-node-modules-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: ${{ runner.os }}-node-modules- - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Setup pnpm uses: pnpm/action-setup@v4 with: @@ -225,18 +223,8 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' 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) - 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 - name: Upload Playwright Report diff --git a/package.json b/package.json index 0e140cb..464c581 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "test:e2e:shard2": "playwright test --shard=2/4", "test:e2e:shard3": "playwright test --shard=3/4", "test:e2e:shard4": "playwright test --shard=4/4", + "test:e2e:all": "turbo run test:e2e:all", "prepare": "lefthook install" }, "dependencies": { diff --git a/turbo.json b/turbo.json index b42fcbd..5d7d524 100644 --- a/turbo.json +++ b/turbo.json @@ -30,30 +30,36 @@ "inputs": ["src/**/*.{ts,tsx,js,jsx,astro,md,json,yml,yaml}"], "outputs": [] }, - "test:playwright": { + "test:e2e": { "cache": true, "inputs": ["**/*.{ts,tsx,js,jsx,astro}"], "outputs": ["playwright-report/**", "test-results/**"] }, - "test:playwright:shard1": { + "test:e2e:shard1": { "cache": true, "inputs": ["**/*.{ts,tsx,js,jsx,astro}"], "outputs": ["playwright-report/**", "test-results/**"] }, - "test:playwright:shard2": { + "test:e2e:shard2": { "cache": true, "inputs": ["**/*.{ts,tsx,js,jsx,astro}"], "outputs": ["playwright-report/**", "test-results/**"] }, - "test:playwright:shard3": { + "test:e2e:shard3": { "cache": true, "inputs": ["**/*.{ts,tsx,js,jsx,astro}"], "outputs": ["playwright-report/**", "test-results/**"] }, - "test:playwright:shard4": { + "test:e2e:shard4": { "cache": true, "inputs": ["**/*.{ts,tsx,js,jsx,astro}"], "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"