-
Notifications
You must be signed in to change notification settings - Fork 2
115 lines (98 loc) · 3.5 KB
/
playwright.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: "Playwright"
on:
pull_request:
push:
branches:
- main
- 'releases/*'
workflow_dispatch:
jobs:
test-linux:
name: Playwright (headless=${{ matrix.headless }}, browser=${{ matrix.browser }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
headless: [true]
browser: [chromium, firefox]
steps:
# 1. Checkout the repository
- uses: actions/checkout@v3
# 2. Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
# 3. Setup pnpm
- name: Setup pnpm
id: setup-pnpm
uses: pnpm/action-setup@v2
with:
version: 7.x
# 4. Cache pnpm dependencies
- name: Cache pnpm dependencies
uses: actions/cache@v3
with:
path: |
~/.pnpm-store
node_modules
key: ${{ runner.os }}-pnpm-store-${{ steps.setup-pnpm.outputs.pnpm-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-${{ steps.setup-pnpm.outputs.pnpm-version }}-
${{ runner.os }}-pnpm-store-
# 5. Cache Playwright browsers
- name: Cache Playwright browsers
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ matrix.browser }}-${{ hashFiles('**/package.json', '**/playwright.config.*') }}
restore-keys: |
${{ runner.os }}-playwright-${{ matrix.browser }}-
# 6. Install dependencies
- name: Install dependencies
run: pnpm install
# 7. Cache build output for idb-cache package
- name: Cache idb-cache build output
uses: actions/cache@v3
with:
path: packages/idb-cache/dist
key: ${{ runner.os }}-idb-cache-build-${{ hashFiles('packages/idb-cache/**/*.ts') }}
restore-keys: |
${{ runner.os }}-idb-cache-build-
# 8. Build the @instructure/idb-cache package
- name: Build idb-cache package
run: pnpm --filter @instructure/idb-cache build
# 9. Cache build output for idb-cache-app
- name: Cache idb-cache-app build output
uses: actions/cache@v3
with:
path: apps/idb-cache-app/dist
key: ${{ runner.os }}-idb-cache-app-build-${{ hashFiles('apps/idb-cache-app/**/*.ts') }}
restore-keys: |
${{ runner.os }}-idb-cache-app-build-
# 10. Build the idb-cache-app
- name: Build idb-cache-app
run: pnpm --filter idb-cache-app build
# 11. Install Playwright browsers
- name: Install Playwright browsers
run: pnpm --filter idb-cache-app exec playwright install ${{ matrix.browser }}
# 12. Serve the idb-cache-app
- name: Serve idb-cache-app
run: pnpm --filter idb-cache-app preview -- --port 3000 &
# The '&' runs the serve command in the background
# 13. Wait for the server to be ready
- name: Wait for idb-cache-app to be ready
run: |
for i in {1..60}; do
if curl -s http://localhost:3000 > /dev/null; then
echo "Server is ready!"
exit 0
fi
echo "Waiting for server to be ready... ($i/60)"
sleep 1
done
echo "Server failed to start in time."
exit 1
# 14. Run Playwright tests
- name: Run Playwright tests
run: pnpm --filter idb-cache-app test -- --project=${{ matrix.browser }}