1
- name : Run next .js tests
1
+ name : Run Next .js repo tests
2
2
3
3
on :
4
- workflow_dispatch :
5
4
workflow_call :
6
5
pull_request :
7
- types : [opened, synchronize, reopened, labeled]
6
+ branches : [main]
7
+ schedule :
8
+ - cron : ' 0 3 * * *' # Run every day at 3am UTC
9
+ workflow_dispatch :
10
+ inputs :
11
+ versions :
12
+ description : ' The versions of Next.js to test against (quoted and comma separated)'
13
+ required : false
14
+ default : " \" latest\" "
15
+ concurrency :
16
+ group : ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
17
+ cancel-in-progress : true
8
18
9
19
env :
10
20
NODE_VERSION : 18.17.1
11
21
PNPM_VERSION : 8.9.0
12
22
NEXT_REPO : vercel/next.js
13
23
NEXT_TEST_MODE : deploy
14
24
NEXT_JUNIT_TEST_REPORT : true
25
+ # In older versions of Next.js both of these need to be set to enable junit reporting
26
+ DATADOG_TRACE_NEXTJS_TEST : true
27
+ DATADOG_API_KEY : foo
15
28
TEST_CONCURRENCY : 2
16
29
NEXT_E2E_TEST_TIMEOUT : 300000
17
30
NEXT_TELEMETRY_DISABLED : 1
26
39
next-path : next.js
27
40
runtime-path : next-runtime-minimal
28
41
jobs :
29
- e2e :
42
+ setup :
43
+ runs-on : ubuntu-latest
30
44
if :
31
- ${{ github.event_name == ('workflow_dispatch' || 'workflow_call') ||
45
+ ${{ github.event_name == ('workflow_dispatch' || 'workflow_call' || 'schedule' ) ||
32
46
contains(github.event.pull_request.labels.*.name, 'run-e2e-tests') }}
33
- name : Test group ${{ matrix.group }}/12
47
+ outputs :
48
+ version : ${{ steps.set-matrix.outputs.version }}
49
+ group : ${{ steps.set-matrix.outputs.group }}
50
+ total : ${{ steps.set-matrix.outputs.total }}
51
+ steps :
52
+
53
+ - name : Set Next.js versions to test
54
+ id : set-matrix
55
+ run : |
56
+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
57
+ echo "version=[${{ github.event.inputs.versions }}]" >> $GITHUB_OUTPUT
58
+ echo "group=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]" >> $GITHUB_OUTPUT
59
+ echo "total=12" >> $GITHUB_OUTPUT
60
+ elif [ "${{ github.event_name }}" == "pull_request" ]; then
61
+ echo "version=[\"latest\"]" >> $GITHUB_OUTPUT
62
+ echo "group=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]" >> $GITHUB_OUTPUT
63
+ echo "total=12" >> $GITHUB_OUTPUT
64
+ else
65
+ echo "version=[\"canary\",\"latest\",\"13.5.1\"]" >> $GITHUB_OUTPUT
66
+ echo "group=[1, 2, 3, 4]" >> $GITHUB_OUTPUT
67
+ echo "total=4" >> $GITHUB_OUTPUT
68
+ fi
69
+ e2e :
70
+ needs : setup
34
71
runs-on : ubuntu-latest
72
+ name : Test next@${{ matrix.version }} group ${{ matrix.group }}/${{ needs.setup.outputs.total }}
35
73
timeout-minutes : 120
36
74
strategy :
37
75
fail-fast : false
38
76
matrix :
39
- group : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
77
+ version : ${{ fromJson(needs.setup.outputs.version) }}
78
+ group : ${{ fromJson(needs.setup.outputs.group) }}
40
79
41
80
outputs :
42
81
tag : ${{ steps.next-release.outputs.tag }}
@@ -45,10 +84,20 @@ jobs:
45
84
- name : Get Latest Next.js Release
46
85
id : next-release
47
86
run : |
48
- LATEST_RELEASE=$(curl -s https://api.github.com/repos/vercel/next.js/releases/latest | jq -r .tag_name)
49
- echo "Latest release tag is $LATEST_RELEASE"
50
- echo "tag=$LATEST_RELEASE" >> $GITHUB_OUTPUT
51
-
87
+ if [ "${{ matrix.version }}" == "latest" ]; then
88
+ LATEST_RELEASE_TAG=$(curl -s https://api.github.com/repos/vercel/next.js/releases/latest | jq -r .tag_name)
89
+ echo "Latest release tag is $LATEST_RELEASE_TAG"
90
+ echo "tag=$LATEST_RELEASE_TAG" >> $GITHUB_OUTPUT
91
+ echo "version=$(npm view next@latest version)" >> $GITHUB_OUTPUT
92
+ elif [ "${{ matrix.version }}" == "canary" ]; then
93
+ LATEST_CANARY_TAG=$(curl -s https://api.github.com/repos/vercel/next.js/releases | jq -r '.[] | select(.prerelease == true) | .tag_name' | head -n 1)
94
+ echo "Latest canary tag is $LATEST_CANARY_TAG"
95
+ echo "tag=$LATEST_CANARY_TAG" >> $GITHUB_OUTPUT
96
+ echo "version=$(npm view next@canary version)" >> $GITHUB_OUTPUT
97
+ else
98
+ echo "tag=v${{ matrix.version }}" >> $GITHUB_OUTPUT
99
+ echo "version=$(npm view next@${{ matrix.version }} version)" >> $GITHUB_OUTPUT
100
+ fi
52
101
- name : checkout Next.js repo
53
102
uses : actions/checkout@v4
54
103
with :
@@ -69,6 +118,18 @@ jobs:
69
118
- name : setup pnpm/yarn
70
119
run : corepack enable
71
120
121
+ - name : get pnpm store
122
+ id : pnpm-store
123
+ run : echo "PATH=$(pnpm store path --silent)" >> ${GITHUB_OUTPUT}
124
+
125
+ - name : cache pnpm deps
126
+ uses : actions/cache@v4
127
+ with :
128
+ path : ${{ steps.pnpm-store.outputs.PATH }}
129
+ key : pnpm-store-${{ hashFiles('next.js/pnpm-lock.yaml') }}
130
+ restore-keys : |
131
+ pnpm-store-
132
+
72
133
- name : get npm cache
73
134
id : npm-cache
74
135
run : echo "PATH=$(npm config get cache)" >> ${GITHUB_OUTPUT}
77
138
uses : actions/cache@v4
78
139
with :
79
140
path : ${{ steps.npm-cache.outputs.PATH }}
80
- key : node-cache-${{ hashFiles('** /package-lock.json') }}
141
+ key : node-cache-${{ hashFiles('next-runtime-minimal /package-lock.json') }}
81
142
restore-keys : |
82
143
node-cache-
83
144
96
157
working-directory : ${{ env.next-path }}
97
158
98
159
- name : install swc
99
- run : pnpm add --workspace-root @next/swc-linux-x64-gnu@${{ env.NEXT_VERSION }}
160
+ run : pnpm add --workspace-root @next/swc-linux-x64-gnu@${{ steps.next-release.outputs.version }}
100
161
working-directory : ${{ env.next-path }}
101
162
102
163
- name : Install Deno
@@ -116,33 +177,50 @@ jobs:
116
177
- name : add netlify cli
117
178
run : npm install -g netlify-cli
118
179
119
- - name : install playwright
120
- run : npx playwright install
180
+ - name : Install Playwright Browsers
181
+ run : npx playwright install --with-deps
121
182
working-directory : ${{ env.next-path }}
122
183
184
+ - name : Get test filters
185
+ id : test-filters
186
+ run : |
187
+ # This is when the manifest version was changed
188
+ if [ `npx semver -p -r ">=14.0.4-canary.26" ${{ steps.next-release.outputs.version }}` ]; then
189
+ echo "filters=../next-runtime-minimal/tests/netlify-e2e.cjs" >> $GITHUB_OUTPUT
190
+ echo "skip-retry=../next-runtime-minimal/tests/e2e-skip-retry.json" >> $GITHUB_OUTPUT
191
+ else
192
+ echo "filters=../next-runtime-minimal/tests/netlify-e2e-legacy.json" >> $GITHUB_OUTPUT
193
+ echo "skip-retry=../next-runtime-minimal/tests/e2e-skip-retry-legacy.json" >> $GITHUB_OUTPUT
194
+ fi
195
+
123
196
- name : run tests
124
197
env :
125
198
NODE_ENV : production
126
- NEXT_EXTERNAL_TESTS_FILTERS : ../next-runtime-minimal/tests/netlify-e2e.json
127
- NEXT_TEST_SKIP_RETRY_MANIFEST : ../next-runtime-minimal/tests/e2e- skip-retry.json
128
- run : node run-tests.js -g ${{ matrix.group }}/12 -c ${TEST_CONCURRENCY} --type e2e
199
+ NEXT_EXTERNAL_TESTS_FILTERS : ${{ steps.test-filters.outputs.filters }}
200
+ NEXT_TEST_SKIP_RETRY_MANIFEST : ${{ steps.test-filters.outputs. skip-retry }}
201
+ run : node run-tests.js -g ${{ matrix.group }}/${{ needs.setup.outputs.total }} -c ${TEST_CONCURRENCY} --type e2e --timings
129
202
working-directory : ${{ env.next-path }}
130
203
131
204
- name : Upload Test Results
132
205
if : success() || failure()
133
- uses : actions/upload-artifact@v3
206
+ uses : actions/upload-artifact@v4
134
207
with :
135
- name : Test Results ( ${{ matrix.group }})
208
+ name : test-result- ${{matrix.version}}-${{ matrix.group }}
136
209
path : ${{ env.next-path }}/test/test-junit-report/*.xml
137
210
publish-test-results :
138
- name : ' E2E Test Summary'
139
- needs : e2e
211
+ name : ' E2E Test Summary (${{matrix.version}})'
212
+ needs :
213
+ - e2e
214
+ - setup
140
215
runs-on : ubuntu-latest
141
216
permissions :
142
217
checks : write
143
218
contents : read
144
219
issues : read
145
220
if : success() || failure()
221
+ strategy :
222
+ matrix :
223
+ version : ${{ fromJson(needs.setup.outputs.version) }}
146
224
147
225
steps :
148
226
- name : checkout runtime repo
@@ -152,17 +230,31 @@ jobs:
152
230
uses : denoland/setup-deno@v1
153
231
154
232
- name : Download Artifacts
155
- uses : actions/download-artifact@v3
233
+ uses : actions/download-artifact@v4
156
234
with :
235
+ pattern : test-result-${{matrix.version}}-*
157
236
path : artifacts
158
237
159
238
- name : Publish Test Report
239
+ id : publish-test-results
160
240
if : success() || failure()
161
241
run : |
162
242
deno run -A tools/deno/junit2md.ts artifacts >> $GITHUB_STEP_SUMMARY
243
+ echo "slackEvent<<NETLIFY_EOF" >> $GITHUB_OUTPUT
244
+ deno run -A tools/deno/junit2slack.ts --dir artifacts --version ${{matrix.version}} --runUrl ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} >> $GITHUB_OUTPUT
245
+ echo "NETLIFY_EOF" >> $GITHUB_OUTPUT
163
246
164
- - name : Publish test site
247
+ - name : Notify Slack
165
248
if : success() || failure()
249
+
250
+ env :
251
+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
252
+ SLACK_WEBHOOK_TYPE : INCOMING_WEBHOOK
253
+ with :
254
+ payload : ${{ steps.publish-test-results.outputs.slackEvent }}
255
+
256
+ - name : Publish test site
257
+ if : (success() || failure()) && matrix.version == 'latest' && github.event_name == ('schedule' || 'workflow_dispatch') && github.head_ref == 'main'
166
258
run : |
167
259
deno run -A tools/deno/junit2html.ts artifacts ${{needs.e2e.outputs.tag}} > report/index.html
168
260
npx --yes netlify-cli@latest deploy --prod --cwd report
0 commit comments