-
Notifications
You must be signed in to change notification settings - Fork 11
179 lines (154 loc) · 6.01 KB
/
playwright.yml
File metadata and controls
179 lines (154 loc) · 6.01 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
# Copyright 2025 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 * * *"
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: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- 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: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright # Default Playwright cache path
key: ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }}-${{ hashFiles('playwright.config.ts') }}
restore-keys: |
${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }}- # Fallback for lock file changes
${{ runner.os }}-playwright- # Broader fallback
env:
PLAYWRIGHT_BROWSERS_PATH: ~/.cache/ms-playwright
- name: Install dependencies
run: npm install
- name: Install Playwright Browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Build Changed Workspaces
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
- name: Generate Index (Run Once After Builds)
run: bash samples/generate-index.sh
# Consider adding an 'if' condition if it only needs to run when 'samples/' changed at all.
# if: |
# steps.get_workspaces.outputs.changed_workspaces != '' || # If any workspace built
# contains(github.event.pull_request.paths.*, 'samples/generate-index.sh') # Or if the script itself changed
- name: Run All Playwright Tests
if: steps.get_workspaces.outputs.changed_workspaces != ''
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
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- 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: Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright # Default Playwright cache path
key: ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }}-${{ hashFiles('playwright.config.ts') }}
restore-keys: |
${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }}- # 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
run: npx playwright install --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/