1- name : Run next .js tests
1+ name : Run Next .js repo tests
22
33on :
4- workflow_dispatch :
54 workflow_call :
65 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
818
919env :
1020 NODE_VERSION : 18.17.1
1121 PNPM_VERSION : 8.9.0
1222 NEXT_REPO : vercel/next.js
1323 NEXT_TEST_MODE : deploy
1424 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
1528 TEST_CONCURRENCY : 2
1629 NEXT_E2E_TEST_TIMEOUT : 300000
1730 NEXT_TELEMETRY_DISABLED : 1
2639 next-path : next.js
2740 runtime-path : next-runtime-minimal
2841jobs :
29- e2e :
42+ setup :
43+ runs-on : ubuntu-latest
3044 if :
31- ${{ github.event_name == ('workflow_dispatch' || 'workflow_call') ||
45+ ${{ github.event_name == ('workflow_dispatch' || 'workflow_call' || 'schedule' ) ||
3246 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
3471 runs-on : ubuntu-latest
72+ name : Test next@${{ matrix.version }} group ${{ matrix.group }}/${{ needs.setup.outputs.total }}
3573 timeout-minutes : 120
3674 strategy :
3775 fail-fast : false
3876 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) }}
4079
4180 outputs :
4281 tag : ${{ steps.next-release.outputs.tag }}
@@ -45,10 +84,20 @@ jobs:
4584 - name : Get Latest Next.js Release
4685 id : next-release
4786 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
52101 - name : checkout Next.js repo
53102 uses : actions/checkout@v4
54103 with :
@@ -69,6 +118,18 @@ jobs:
69118 - name : setup pnpm/yarn
70119 run : corepack enable
71120
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+
72133 - name : get npm cache
73134 id : npm-cache
74135 run : echo "PATH=$(npm config get cache)" >> ${GITHUB_OUTPUT}
77138 uses : actions/cache@v4
78139 with :
79140 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') }}
81142 restore-keys : |
82143 node-cache-
83144
96157 working-directory : ${{ env.next-path }}
97158
98159 - 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 }}
100161 working-directory : ${{ env.next-path }}
101162
102163 - name : Install Deno
@@ -116,33 +177,50 @@ jobs:
116177 - name : add netlify cli
117178 run : npm install -g netlify-cli
118179
119- - name : install playwright
120- run : npx playwright install
180+ - name : Install Playwright Browsers
181+ run : npx playwright install --with-deps
121182 working-directory : ${{ env.next-path }}
122183
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+
123196 - name : run tests
124197 env :
125198 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
129202 working-directory : ${{ env.next-path }}
130203
131204 - name : Upload Test Results
132205 if : success() || failure()
133- uses : actions/upload-artifact@v3
206+ uses : actions/upload-artifact@v4
134207 with :
135- name : Test Results ( ${{ matrix.group }})
208+ name : test-result- ${{matrix.version}}-${{ matrix.group }}
136209 path : ${{ env.next-path }}/test/test-junit-report/*.xml
137210 publish-test-results :
138- name : ' E2E Test Summary'
139- needs : e2e
211+ name : ' E2E Test Summary (${{matrix.version}})'
212+ needs :
213+ - e2e
214+ - setup
140215 runs-on : ubuntu-latest
141216 permissions :
142217 checks : write
143218 contents : read
144219 issues : read
145220 if : success() || failure()
221+ strategy :
222+ matrix :
223+ version : ${{ fromJson(needs.setup.outputs.version) }}
146224
147225 steps :
148226 - name : checkout runtime repo
@@ -152,17 +230,31 @@ jobs:
152230 uses : denoland/setup-deno@v1
153231
154232 - name : Download Artifacts
155- uses : actions/download-artifact@v3
233+ uses : actions/download-artifact@v4
156234 with :
235+ pattern : test-result-${{matrix.version}}-*
157236 path : artifacts
158237
159238 - name : Publish Test Report
239+ id : publish-test-results
160240 if : success() || failure()
161241 run : |
162242 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
163246
164- - name : Publish test site
247+ - name : Notify Slack
165248 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'
166258 run : |
167259 deno run -A tools/deno/junit2html.ts artifacts ${{needs.e2e.outputs.tag}} > report/index.html
168260 npx --yes netlify-cli@latest deploy --prod --cwd report
0 commit comments