Skip to content

Commit 3e426ce

Browse files
committed
ci: integrate playwrite into ci workflow
1 parent ef212f8 commit 3e426ce

File tree

14 files changed

+146
-57
lines changed

14 files changed

+146
-57
lines changed

.github/actions/install-dependencies/action.yaml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ description: "Prepare repository and all dependencies"
44
inputs:
55
node-version:
66
description: "Node.js version to use"
7-
default: "18"
7+
default: "24"
8+
install-playwright:
9+
description: "Install Playwright browsers"
10+
default: true
11+
required: false
12+
type: boolean
813

914
runs:
1015
using: "composite"
@@ -15,14 +20,34 @@ runs:
1520
node-version: ${{ inputs.node-version }}
1621
cache: "npm"
1722

18-
- name: Cache dependencies
23+
- name: Install dependencies
24+
run: npm ci --ignore-scripts --audit=false
25+
shell: bash
26+
27+
- name: Get playwright version
28+
if: inputs.install-playwright == 'true'
29+
id: playwright-version
30+
run: |
31+
version=$(npx --no-install playwright --version)
32+
echo "playwright_version=$version" >> $GITHUB_OUTPUT
33+
shell: bash
34+
35+
- name: Cache playwright browsers
36+
if: inputs.install-playwright == 'true'
37+
id: cache-playwright
1938
uses: actions/cache@v4
2039
with:
21-
path: ~/.npm
22-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
40+
path: ~/.cache/ms-playwright
41+
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.playwright_version }}
2342
restore-keys: |
24-
${{ runner.os }}-node-
43+
${{ runner.os }}-playwright-
2544
26-
- name: Install dependencies
27-
run: npm ci --ignore-scripts
45+
- name: Install Playwright browsers and dependencies
46+
if: inputs.install-playwright == 'true'
47+
run: |
48+
if [ "${{ steps.cache-playwright.outputs.cache-hit }}" == "true" ]; then
49+
npx --no-install playwright install-deps
50+
else
51+
npx --no-install playwright install --with-deps
52+
fi
2853
shell: bash

.github/actions/test/action.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ runs:
1515
using: "composite"
1616
steps:
1717
- name: Run tests
18-
run: npm run test:all
18+
run: |
19+
export CI=true
20+
npm run test:all
1921
shell: bash
2022

2123
- name: Upload tests (lib only) coverage to Coveralls
@@ -24,3 +26,11 @@ runs:
2426
with:
2527
github-token: ${{ inputs.github-token }}
2628
base-path: "lib"
29+
30+
- uses: actions/upload-artifact@v4
31+
if: ${{ !cancelled() }}
32+
with:
33+
name: playwright-report
34+
path: examples/tests/e2e/output/playwright-report
35+
if-no-files-found: "warn"
36+
retention-days: 30

.github/workflows/build.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
steps:
1919
- name: Clone repository
2020
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: ${{ github.event_name == 'pull_request' && 0 || 1 }}
2123

2224
- name: Install dependencies
2325
uses: ./.github/actions/install-dependencies

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.rslib
22
lib/CHANGELOG.md
33
lib/tests/readme/extracted-snippets
4+
examples/tests/e2e/output

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default [
1515
"**/dist",
1616
"**/coverage/",
1717
"**/.rslib",
18-
"examples/tests/e2e/test-results",
18+
"examples/tests/e2e/output",
1919
"lib/tests/readme/extracted-snippets",
2020
],
2121
},

examples/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html lang="en">
33

44
<head>
5+
<title></title>
56
</head>
67

78
<body>

examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"build": "vite build",
1111
"preview": "vite preview",
1212
"test:e2e": "playwright test",
13+
"test:e2e:ui": "playwright test --ui",
1314
"test:all": "npm run test:e2e"
1415
},
1516
"devDependencies": {
16-
"@playwright/test": "^1.52.0",
1717
"@vitejs/plugin-react": "^4.4.1",
1818
"dayjs": "^1.11.13",
1919
"vite-plugin-checker": "^0.9.3",

examples/playwright.config.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
import path from "node:path";
2+
import { fileURLToPath } from "node:url";
13
import { defineConfig, devices } from "@playwright/test";
4+
import dotenv from "dotenv";
5+
6+
const __filename = fileURLToPath(import.meta.url);
7+
dotenv.config({ path: path.join(path.dirname(__filename), ".env"), quiet: true });
28

3-
/**
4-
* See https://playwright.dev/docs/test-configuration.
5-
*/
69
export default defineConfig({
7-
testDir: "./e2e",
8-
fullyParallel: true,
10+
testDir: "./tests/e2e",
911
retries: process.env.CI ? 2 : 0,
1012
workers: process.env.CI ? 1 : undefined,
11-
reporter: "html",
12-
snapshotDir: "tests/e2e/snapshots",
13-
outputDir: "tests/e2e/test-results",
13+
snapshotDir: "tests/e2e/output/snapshots",
14+
outputDir: "tests/e2e/output/test-results",
15+
fullyParallel: true,
1416
use: {
1517
baseURL: "http://localhost:5173",
1618
trace: "on-first-retry",
@@ -28,13 +30,25 @@ export default defineConfig({
2830
name: "webkit",
2931
use: { ...devices["Desktop Safari"] },
3032
},
33+
{
34+
name: "Microsoft Edge",
35+
use: { ...devices["Desktop Edge"] },
36+
},
37+
{
38+
name: "Mobile Chrome",
39+
use: { ...devices["Pixel 5"] },
40+
},
41+
],
42+
reporter: [
43+
["html", { open: "never", outputFolder: "tests/e2e/output/playwright-report" }],
44+
["list"],
3145
],
32-
3346
webServer: {
3447
command: "npm run dev",
3548
url: "http://localhost:5173",
3649
reuseExistingServer: !process.env.CI,
3750
stdout: "ignore",
3851
stderr: "pipe",
52+
timeout: 120 * 1000,
3953
},
4054
});

examples/tests/e2e/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
output/

0 commit comments

Comments
 (0)