-
Notifications
You must be signed in to change notification settings - Fork 12
220 lines (190 loc) · 7.51 KB
/
playwright.yml
File metadata and controls
220 lines (190 loc) · 7.51 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Playwright Tests
on:
pull_request:
types: [opened, synchronize, edited]
paths:
- 'samples/**'
- 'e2e/samples.spec.ts'
- 'playwright.config.ts'
- 'package.json'
push:
branches:
- main
paths:
- 'samples/**'
- 'e2e/samples.spec.ts'
- 'playwright.config.ts'
- 'package.json'
schedule:
- cron: "0 12 * * *"
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
SKIP_DIST: ${{ github.event_name == 'pull_request' || github.event_name == 'schedule' }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pr_and_push_tests:
name: Playwright PR/Push Tests
if: |
(github.event_name == 'pull_request' && github.event.pull_request.merged == false) ||
(github.event_name == 'push' && !contains(github.event.head_commit.message, 'chore: update dist folder'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Get Changed Workspaces
id: get_workspaces
# For PRs, compare against the origin's version of the base branch.
# For pushes, compare against the commit before the push.
run: |
bash samples/find-changes.sh ${{ github.event_name == 'pull_request' && format('origin/{0}', github.base_ref) || github.event.before }}
- name: Check for changes
id: check_changes
run: |
if [ "${{ steps.get_workspaces.outputs.changed_workspaces }}" != "" ]; then
echo "HAS_CHANGES=true" >> $GITHUB_ENV
else
echo "HAS_CHANGES=false" >> $GITHUB_ENV
fi
- name: Setup Node.js
if: env.HAS_CHANGES == 'true'
uses: actions/setup-node@v4
with:
node-version: '24.x'
- name: Cache npm dependencies
if: env.HAS_CHANGES == 'true'
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Get Playwright Version
id: playwright-version
if: env.HAS_CHANGES == 'true'
run: |
echo "version=$(node -p "require('./package.json').devDependencies['@playwright/test']")" >> $GITHUB_OUTPUT
- name: Cache Playwright browsers
id: playwright-cache
if: env.HAS_CHANGES == 'true'
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright # Default Playwright cache path
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}-${{ hashFiles('playwright.config.ts') }}
restore-keys: |
${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}- # Fallback for lock file changes
${{ runner.os }}-playwright- # Broader fallback
env:
PLAYWRIGHT_BROWSERS_PATH: ~/.cache/ms-playwright
- name: Install dependencies
if: env.HAS_CHANGES == 'true'
run: npm install
- name: Install Playwright Browsers
if: steps.playwright-cache.outputs.cache-hit != 'true' && env.HAS_CHANGES == 'true'
run: npx playwright install chromium --with-deps
- name: Build Changed Workspaces
if: env.HAS_CHANGES == 'true'
run: |
IFS=$'\n'
CHANGED_WORKSPACES_ARRAY=(${STEPS_GET_WORKSPACES_OUTPUTS_CHANGED_WORKSPACES})
echo "Changed Workspaces Array: ${CHANGED_WORKSPACES_ARRAY[@]}"
echo "Building changed workspaces:"
for workspace in "${CHANGED_WORKSPACES_ARRAY[@]}"; do
echo " - samples/$workspace"
npm run build --workspace=samples/$workspace
done
env:
STEPS_GET_WORKSPACES_OUTPUTS_CHANGED_WORKSPACES: ${{ steps.get_workspaces.outputs.changed_workspaces }}
- name: Generate Index (Run Once After Builds)
run: bash samples/generate-index.sh
if: |
env.HAS_CHANGES == 'true' ||
contains(github.event.pull_request.paths.*, 'samples/generate-index.sh')
- name: Run All Playwright Tests
if: env.HAS_CHANGES == 'true'
run: npx playwright test e2e/samples.spec.ts
env:
# Pass the correct base reference for find-changes.sh when called by samples.spec.ts
GIT_BASE_REF: ${{ github.event_name == 'pull_request' && format('origin/{0}', github.base_ref) || github.event.before }}
CI: true
- name: Upload Test Report Artifact
uses: actions/upload-artifact@v4
if: failure()
with:
name: Test Results
path: test-results/
scheduled_full_test:
name: Scheduled Full E2E Tests
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24.x'
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Get Playwright Version
id: playwright-version
run: |
echo "version=$(node -p "require('./package.json').devDependencies['@playwright/test']")" >> $GITHUB_OUTPUT
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright # Default Playwright cache path
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}-${{ hashFiles('playwright.config.ts') }}
restore-keys: |
${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}- # Fallback for lock file changes
${{ runner.os }}-playwright- # Broader fallback
- name: Install dependencies
run: npm ci
- name: Build All Projects
run: npm run build-all
- name: Generate Index (Run Once After Full Builds)
run: bash samples/generate-index.sh
- name: Install Playwright browsers with OS dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install chromium --with-deps
- name: Run Full E2E Tests (Scheduled)
run: npx playwright test e2e/samples.spec.ts
env:
CI: true
- name: Upload Test Report Artifact
uses: actions/upload-artifact@v4
if: failure()
with:
name: Test Results
path: test-results/
- name: Create Issue on Failure
if: failure()
run: |
gh issue create --title "Nightly Playwright Tests Failed" --body "The nightly E2E tests failed. Please check the logs: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
GH_TOKEN: ${{ github.token }}