-
Notifications
You must be signed in to change notification settings - Fork 428
272 lines (241 loc) · 9.12 KB
/
e2e-ct.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
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: End-to-End Component Tests
on:
# Build on pushes branches that have a PR (including drafts)
pull_request:
# Build on commits pushed to branches without a PR if it's in the allowlist
push:
branches: [next]
jobs:
install:
timeout-minutes: 30
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
strategy:
fail-fast: false
matrix:
# Be sure to update all instances in this file and `pr-cleanup.yml` if updated
project: [chromium, firefox, webkit]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
v1-${{ runner.os }}-pnpm-store-${{ env.cache-name }}-
v1-${{ runner.os }}-pnpm-store-
v1-${{ runner.os }}-
- name: Install project dependencies
run: pnpm install
- name: Build packages
run: pnpm build --output-logs=full --log-order=grouped
# Caches build from either PR or next
- name: Cache build
id: cache-e2e-build
uses: actions/cache@v4
env:
cache-name: cache-e2e-build
with:
path: |
./*
!**/node_modules/**
# Unique key for a workflow run. Should be invalidated in the next run
key: ${{ runner.os }}-${{ matrix.project }}-${{ env.cache-name }}-${{ github.run_id }}
playwright-ct-test:
timeout-minutes: 30
needs: [install]
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
strategy:
fail-fast: false
matrix:
# Be sure to update all instances in this file and `pr-cleanup.yml` if updated
project: [chromium, firefox, webkit]
# Add more shards here if needed
shardIndex: [1, 2]
shardTotal: [2]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
v1-${{ runner.os }}-pnpm-store-${{ env.cache-name }}-
v1-${{ runner.os }}-pnpm-store-
v1-${{ runner.os }}-
- name: Install project dependencies
run: pnpm install
- name: Store Playwright's Version
run: |
PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/Version //')
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Cache Playwright Browsers for Playwright's Version
id: cache-playwright-browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}
- name: Install Playwright Browsers
# TODO: Fix webkit caching when downloading from cache
# for some reason it doesn't work without installing again
# if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Restore build cache
uses: actions/cache/restore@v4
id: restore-build
env:
cache-name: cache-e2e-build
with:
path: |
./*
!**/node_modules/**
key: ${{ runner.os }}-${{ matrix.project }}-${{ env.cache-name }}-${{ github.run_id }}
# If the cached build from the pervious step is not available. Fail the build
fail-on-cache-miss: true
- name: Run end-to-end tests
env:
PWTEST_BLOB_REPORT_NAME: ${{ matrix.project }}
NODE_OPTIONS: --max_old_space_size=8192
run: pnpm --filter sanity test:ct --project ${{ matrix.project }} --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-ct-report
path: ${{ github.workspace }}/packages/sanity/blob-report
retention-days: 30
merge-reports:
if: always()
needs: [playwright-ct-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
v1-${{ runner.os }}-pnpm-store-${{ env.cache-name }}-
v1-${{ runner.os }}-pnpm-store-
v1-${{ runner.os }}-
- name: Install project dependencies
run: pnpm install
- name: Download blob reports from Github Actions Artifacts
uses: actions/download-artifact@v3
with:
name: playwright-ct-report
path: ${{ github.workspace }}/packages/sanity/playwright-ct/playwright-ct-report
- name: Merge into HTML Report
run: npx playwright merge-reports --reporter json ${{ github.workspace }}/packages/sanity/playwright-ct/playwright-ct-report >> ${{ github.workspace }}/packages/sanity/playwright-ct/playwright-ct-report/playwright-ct-test-results.json
- name: Get Current Job Log URL
uses: Tiryoh/gha-jobid-action@be260d8673c9211a84cdcf37794ebd654ba81eef # v1
id: job_html_url
if: always()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Get the first run's ID even though it might be correct it should bring to the right place
job_name: "playwright-ct-test (chromium, 1, 2)"
- name: Parse playwright report
id: parse-playwright-report
if: always()
run: pnpm --filter sanity write:playwright-report-as-pr-comment
env:
GITHUB_WORKFLOW_URL: "${{ steps.job_html_url.outputs.html_url }}"
- name: PR comment with report
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2
if: ${{ always() && steps.parse-playwright-report.conclusion == 'success' && github.event_name == 'pull_request' }}
with:
comment_tag: "playwright-ct-report"
filePath: ${{ github.workspace }}/packages/sanity/playwright-ct/playwright-ct-report/playwright-report-pr-comment.md
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-ct-report
path: |
${{ github.workspace }}/packages/sanity/playwright-ct/report
${{ github.workspace }}/packages/sanity/playwright-ct/playwright-ct-report
${{ github.workspace }}/packages/sanity/playwright-ct/results
retention-days: 30
cleanup:
permissions:
contents: read
actions: write # needed to delete the cache
timeout-minutes: 30
name: Cleanup (${{ matrix.project }})
runs-on: ubuntu-latest
needs: [playwright-ct-test]
strategy:
# we want to know if a test fails on a specific node version
fail-fast: false
matrix:
# Be sure to update all instances in this file and `pr-cleanup.yml` if updated
project: [chromium, firefox, webkit]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
# Delete the cache so it is only used once
- name: Delete Cache
run: gh cache delete ${{ runner.os }}-${{ matrix.project }}-${{ env.cache-name }}-${{ github.run_id }}
env:
cache-name: cache-e2e-build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}