Skip to content

Commit 6beb54d

Browse files
committed
playwright ci
1 parent 2de82de commit 6beb54d

File tree

4 files changed

+105
-8
lines changed

4 files changed

+105
-8
lines changed

.github/workflows/playwright.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: "Run Playwright tests"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- 'releases/*'
9+
workflow_dispatch:
10+
11+
jobs:
12+
test-linux:
13+
name: Playwright tests on ${{ matrix.os }} (headless=${{ matrix.headless }})
14+
runs-on: ubuntu-20.04
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
headless: [true]
20+
21+
steps:
22+
# 1. Checkout the repository
23+
- uses: actions/checkout@v3
24+
25+
# 2. Setup Node.js
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: 18
30+
31+
# 3. Setup pnpm
32+
- name: Setup pnpm
33+
uses: pnpm/action-setup@v2
34+
with:
35+
version: 7.x
36+
37+
# 4. Cache pnpm dependencies
38+
- name: Cache pnpm dependencies
39+
uses: actions/cache@v3
40+
with:
41+
path: ~/.pnpm-store
42+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
43+
restore-keys: |
44+
${{ runner.os }}-pnpm-store-
45+
46+
# 5. Install dependencies
47+
- name: Install dependencies
48+
run: pnpm install
49+
50+
# 6. Build the @instructure/idb-cache package
51+
- name: Build idb-cache package
52+
run: pnpm --filter @instructure/idb-cache build
53+
54+
# 7. Build the idb-cache-app
55+
- name: Build idb-cache-app
56+
run: pnpm --filter idb-cache-app build
57+
58+
# 8. Install Playwright browsers
59+
- name: Install Playwright browsers
60+
run: pnpm exec playwright install
61+
62+
# 9. Serve the idb-cache-app
63+
- name: Serve idb-cache-app
64+
run: pnpm --filter idb-cache-app preview -- --port 3000 &
65+
# The '&' runs the serve command in the background
66+
67+
# 10. Wait for the server to be ready
68+
- name: Wait for idb-cache-app to be ready
69+
run: |
70+
for i in {1..60}; do
71+
if curl -s http://localhost:3000 > /dev/null; then
72+
echo "Server is ready!"
73+
break
74+
fi
75+
echo "Waiting for server to be ready... ($i/60)"
76+
sleep 1
77+
done
78+
79+
# 11. Run Playwright tests in headless mode
80+
- name: Run Playwright tests (Headless)
81+
if: ${{ matrix.headless == true }}
82+
run: pnpm --filter idb-cache-app test
83+
84+
# 12. Run Playwright tests in headful mode on Linux
85+
- name: Run Playwright tests (Headful)
86+
if: ${{ matrix.headless == false }}
87+
run: |
88+
export HEADFUL=true
89+
xvfb-run --auto-servernum -- pnpm --filter idb-cache-app test

packages/idb-cache-app/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"scripts": {
66
"dev": "rsbuild dev --open",
77
"build": "rsbuild build",
8-
"preview": "rsbuild preview"
8+
"preview": "rsbuild preview",
9+
"test": "playwright test"
910
},
1011
"dependencies": {
1112
"@instructure/idb-cache": "workspace:*",
@@ -14,7 +15,6 @@
1415
"react-dom": "^18.3.1"
1516
},
1617
"devDependencies": {
17-
"@playwright/test": "^1.48.2",
1818
"@instructure/ui": "^9.9.0",
1919
"@instructure/ui-buttons": "^9.9.0",
2020
"@instructure/ui-flex": "^9.9.0",
@@ -23,12 +23,15 @@
2323
"@instructure/ui-number-input": "^9.9.0",
2424
"@instructure/ui-text-input": "^9.9.0",
2525
"@instructure/ui-view": "^9.9.0",
26+
"@playwright/test": "^1.48.2",
2627
"@rsbuild/core": "^1.0.19",
2728
"@rsbuild/plugin-react": "^1.0.6",
2829
"@types/random-seed": "^0.3.5",
2930
"@types/react": "^18.3.12",
3031
"@types/react-dom": "^18.3.1",
3132
"daisyui": "^4.12.14",
33+
"idb": "^8.0.0",
34+
"playwright": "^1.48.2",
3235
"tailwindcss": "^3.4.15",
3336
"typescript": "^5.6.3"
3437
}

packages/idb-cache/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
"biome:check": "biome check . --write"
2727
},
2828
"peerDependencies": {
29-
"@rslib/core": "^0.0.15",
30-
"idb": "^8.0.0"
29+
"@rslib/core": "^0.0.15"
3130
},
3231
"devDependencies": {
3332
"@rslib/core": "^0.0.15",
3433
"@types/node": "^22.9.0",
34+
"idb": "^8.0.0",
3535
"typescript": "^5.6.3"
3636
}
3737
}

pnpm-lock.yaml

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)