-
-
Notifications
You must be signed in to change notification settings - Fork 3
342 lines (312 loc) · 12 KB
/
tests.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
name: Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
branches: [ master ]
repository_dispatch:
types: [ semantic-release ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pages: write
id-token: write
issues: write
pull-requests: write
jobs:
linkspector:
name: linkspector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4
- name: Run linkspector
uses: umbrelladocs/action-linkspector@fc382e19892aca958e189954912fe379a8df270c # pin@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
fail_on_error: true
config_file: .linkspector.yml
installtest:
name: installtest
timeout-minutes: 20
runs-on: ubuntu-24.04
container:
image: mcr.microsoft.com/playwright:v1.48.2-noble
env:
HUSKY: 0
PLAYWRIGHT_BROWSERS_PATH: 0
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
# - uses: google/wireit@setup-github-actions-caching/v2
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: '.nvmrc'
- uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: cache-node-modules
with:
path: |
./node_modules
key: modules-1-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm clean-install && npx playwright install --with-deps
- name: Test exports
run: npm run test:exports
- name: Unit tests
run: npx tsc --noEmit && npx vitest --run --coverage
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@89d6c85cfafaec52c72b6c5e8b2878d33104c699 # v1.3.0
continue-on-error: true
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage-reports/lcov.info
- name: Cache dependencies
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
if: steps.cache-node-modules.outputs.cache-hit != 'true'
with:
path: |
./node_modules
key: modules-1-${{ hashFiles('./package-lock.json') }}
build:
name: build
needs: [ installtest ]
timeout-minutes: 20
runs-on: ubuntu-24.04
container:
image: mcr.microsoft.com/playwright:v1.48.2-noble
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
env:
HUSKY: 0
PLAYWRIGHT_BROWSERS_PATH: 0
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: cache-node-modules
with:
path: |
./node_modules
key: modules-1-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm clean-install && npx playwright install --with-deps
- name: build packages
run: npx cross-env TEST=true npm run build:packages
- name: Cache dependencies
id: cache
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
if: always()
with:
path: |
./dist
./packages/example-react-router6/dist
./packages/example-react-router6/package.json
./packages/example-react/dist
./packages/example-react/package.json
./packages/example-nextjs14/package.json
./packages/example-nextjs14/.next
./packages/example-nextjs15/package.json
./packages/example-nextjs15/.next
key: modules-2-${{ github.sha }}-${{ github.run_id }}
testint:
needs: [ build ]
name: testint
runs-on: ubuntu-24.04
timeout-minutes: 30
container:
image: mcr.microsoft.com/playwright:v1.48.2-noble
strategy:
fail-fast: false
matrix:
shardIndex: [ 1, 2 ]
shardTotal: [ 2 ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: cache-node-modules
with:
path: |
./node_modules
key: modules-1-${{ hashFiles('./package-lock.json') }}
- uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: cache
with:
path: |
./dist
./packages/example-react-router6/dist
./packages/example-react-router6/package.json
./packages/example-react/dist
./packages/example-react/package.json
./packages/example-nextjs14/package.json
./packages/example-nextjs14/.next
./packages/example-nextjs15/package.json
./packages/example-nextjs15/.next
key: modules-2-${{ github.sha }}-${{ github.run_id }}
- name: Run Playwright tests
run: |
npm run start:ci & \
npx wait-on http://localhost:3000 && \
npx wait-on http://localhost:3001 && \
npm run test:int:ci -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: always()
with:
name: blob-report-${{ matrix.shardIndex }}
path: blob-report
retention-days: 5
merge-reports:
# Merge reports after playwright-tests, even if some shards have failed
if: ${{ always() && contains(needs.*.result, 'failure') }}
needs: [ testint ]
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: '.nvmrc'
- uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: cache-node-modules
with:
path: |
./node_modules
key: modules-1-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm clean-install
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
path: all-blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports
- name: Upload HTML report
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 14
release:
name: release
needs: [ testint ]
if: github.ref == 'refs/heads/master'
timeout-minutes: 20
runs-on: ubuntu-24.04
container:
image: mcr.microsoft.com/playwright:v1.48.2-noble
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: cache-node-modules
with:
path: |
./node_modules
key: modules-1-${{ hashFiles('./package-lock.json') }}
- uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: cache
with:
path: |
./dist
./packages/example-react-router6/dist
./packages/example-react-router6/package.json
./packages/example-react/dist
./packages/example-react/package.json
./packages/example-nextjs14/package.json
./packages/example-nextjs14/.next
./packages/example-nextjs15/package.json
./packages/example-nextjs15/.next
key: modules-2-${{ github.sha }}-${{ github.run_id }}
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures
# - name: Debug
# run: echo `pwd` && echo `ls -a`
- name: git config
run: git config --global --add safe.directory /__w/state-in-url/state-in-url
- name: Initialize Git user
run: |
git config --global user.email "github-release-bot@example.com"
git config --global user.name "Release Workflow"
- name: Initialise the NPM config
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
# cleanup:
# name: cleanup
# needs: [release, merge-reports]
# runs-on: ubuntu-24.04
# if: always() && github.ref == 'refs/heads/master'
# timeout-minutes: 10
# permissions:
# # See also: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id
# actions: write
# contents: read
# steps:
# - name: Harden Runner
# uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
# with:
# egress-policy: audit
# - name: Check out code
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# - name: Cleanup
# run: |
# set +e
# echo "Deleting caches..."
# gh cache delete modules-2-${{ github.sha }}-${{ github.run_id }}
# echo "Done"
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}