-
Notifications
You must be signed in to change notification settings - Fork 0
288 lines (233 loc) · 10 KB
/
e2e.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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: E2E Test
on:
pull_request:
workflow_call:
workflow_dispatch:
schedule:
- cron: '0 0 * * SUN'
permissions: {}
defaults:
run:
shell: bash
jobs:
list-astro-versions:
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read # for checkout
outputs:
astro-versions: ${{ steps.list.outputs.versions }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install mise
uses: jdx/mise-action@249c01ba271e19fa76eede7f766161cc95ace489 # v2.1.10
with:
experimental: true
install: false
- name: Install mise tools
# cspell:ignore reshim
# reshim is required to avoid "No such file or directory" error
# ref: https://github.com/jdx/mise/issues/2260
run: mise install || (mise reshim && mise install)
- name: Install package.json dependencies
run: mise run buni
- name: List astro versions for E2E tests
id: list
run: |
versions=$(bun run .github/workflows/scripts/list-astro-versions.ts)
echo "versions=$versions" >> "$GITHUB_OUTPUT"
test-e2e-general:
needs:
- list-astro-versions
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read # for checkout
name: test-e2e-general-astro-${{ matrix.version }}
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.list-astro-versions.outputs.astro-versions) }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install mise
uses: jdx/mise-action@249c01ba271e19fa76eede7f766161cc95ace489 # v2.1.10
with:
experimental: true
install: false
- name: Install mise tools
# cspell:ignore reshim
# reshim is required to avoid "No such file or directory" error
# ref: https://github.com/jdx/mise/issues/2260
run: mise install || (mise reshim && mise install)
- name: Install package.json dependencies
run: mise run buni
- name: Build Package
run: mise run build
- name: Install E2E Test Fixtures Dependencies
run: bun install astro@${{ matrix.version }}
working-directory: tests/e2e/fixtures
- name: Build E2E Test Fixtures with astro-better-image-service
run: bun run build
working-directory: tests/e2e/fixtures
- name: Store Dependency Versions
id: dependency-versions
run: |
playwright_version=$(bun pm ls | sed -nE 's/.*@playwright\/test@(.+)/\1/p')
echo "playwright=$playwright_version" >> "$GITHUB_OUTPUT"
- name: Restore Playwright Browsers Cache
id: restore-browsers-cache
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ runner.os }}-${{ steps.dependency-versions.outputs.playwright }}
- name: Install Playwright Browsers and Dependencies
id: playwright-install
if: steps.restore-browsers-cache.outputs.cache-hit != 'true'
run: bun run playwright install chromium --with-deps
- name: Save Playwright Browsers Cache
if: steps.restore-browsers-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ~/.cache/ms-playwright
key: ${{ steps.restore-browsers-cache.outputs.cache-primary-key }}
- name: Install Playwright Dependencies
if: steps.playwright-install.outcome == 'skipped'
run: bun run playwright install-deps chromium
- name: Playwright Test
id: playwright-test
run: mise run test:e2e
- name: Upload the Playwright Report
# use failure() because success() is used implicitly
# ref: https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions
if: failure() && steps.playwright-test.outcome == 'failure'
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: playwright-report-astro-${{ matrix.version }}-${{ github.sha }}
path: playwright-report/
test-e2e-conversion:
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read # for checkout
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install mise
uses: jdx/mise-action@249c01ba271e19fa76eede7f766161cc95ace489 # v2.1.10
with:
experimental: true
install: false
- name: Install mise tools
# cspell:ignore reshim
# reshim is required to avoid "No such file or directory" error
# ref: https://github.com/jdx/mise/issues/2260
run: mise install || (mise reshim && mise install)
- name: Install package.json dependencies
run: mise run buni
- name: Build Package
run: mise run build
- name: Store Dependency Versions
id: dependency-versions
run: |
playwright_version=$(bun pm ls | sed -nE 's/.*@playwright\/test@(.+)/\1/p')
astro_version=$(bun pm ls | sed -nE 's/.*astro@(.+)/\1/p' | uniq)
# throw error if several versions are found
if [[ $(echo "$astro_version" | wc -l) -gt 1 ]]; then
echo "Multiple versions of Astro found: $astro_version"
exit 1
fi
echo "playwright=$playwright_version" >> "$GITHUB_OUTPUT"
echo "astro=$astro_version" >> "$GITHUB_OUTPUT"
- name: Restore Playwright Browsers Cache
id: restore-browsers-cache
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ runner.os }}-${{ steps.dependency-versions.outputs.playwright }}
- name: Install Playwright Browsers and Dependencies
id: playwright-install
if: steps.restore-browsers-cache.outputs.cache-hit != 'true'
run: bun run playwright install chromium --with-deps
- name: Save Playwright Browsers Cache
if: steps.restore-browsers-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ~/.cache/ms-playwright
key: ${{ steps.restore-browsers-cache.outputs.cache-primary-key }}
- name: Install Playwright Dependencies
if: steps.playwright-install.outcome == 'skipped'
run: bun run playwright install-deps chromium
- name: Store Hash of E2E Test Fixtures and Image Service Consistency Test
id: fixtures-hash
run: echo "hash=${{ hashFiles('tests/e2e/fixtures/**/*', 'tests/e2e/conversion.test.ts') }}" >> "$GITHUB_OUTPUT"
- name: Install E2E Test Fixtures Dependencies
run: bun install --frozen-lockfile
working-directory: tests/e2e/fixtures
- name: Restore Snapshots Cache
id: restore-snapshots-cache
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: tests/e2e/conversion.test.ts-snapshots
key: "default-service-snapshots-${{ runner.os }}-${{ steps.dependency-versions.outputs.astro }}-${{ steps.dependency-versions.outputs.playwright }}-${{ steps.fixtures-hash.outputs.hash }}"
- name: Build E2E Test Fixtures with the Default Image Service
if: steps.restore-snapshots-cache.outputs.cache-hit != 'true'
run: bun run build
working-directory: tests/e2e/fixtures
env:
USE_DEFAULT_IMAGE_SERVICE: true
- name: Take Snapshots with the Default Image Service
if: steps.restore-snapshots-cache.outputs.cache-hit != 'true'
run: bun run playwright test conversion --update-snapshots
env:
USE_DEFAULT_IMAGE_SERVICE: true
- name: Save Snapshots Cache
if: steps.restore-snapshots-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: tests/e2e/conversion.test.ts-snapshots
key: ${{ steps.restore-snapshots-cache.outputs.cache-primary-key }}
- name: Build E2E Test Fixtures with astro-better-image-service
run: bun run build
working-directory: tests/e2e/fixtures
- name: Playwright Image Services Consistency Test
id: playwright-test-conversion
run: bun run playwright test conversion
- name: Upload the Playwright Report of Image Services Consistency Test
# use failure() because success() is used implicitly
# ref: https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions
if: failure() && steps.playwright-test-conversion.outcome == 'failure'
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: playwright-report-conversion-${{ github.sha }}
path: playwright-report/
test-e2e-status:
needs:
- test-e2e-general
- test-e2e-conversion
# skip if the workflow is called from another workflow
if: ${{ !cancelled() && contains(github.workflow_ref, '/e2e.yml') }}
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Check the status of the jobs
run: |
if [[ $(echo '${{ toJson(needs.*.result) }}' | jq 'all(. == "success")') == "false" ]]; then
echo 'Some jobs are failed, cancelled, or skipped.'
exit 1
fi
echo 'All jobs are successful.'
actions-timeline:
needs:
- test-e2e-status
if: needs.test-e2e-status.result == 'success' || needs.test-e2e-status.result == 'failure'
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
actions: read
steps:
- name: actions-timeline
# cspell:ignore kesin
uses: Kesin11/actions-timeline@3046833d9aacfd7745c5264b7f3af851c3e2a619 # v2.2.1