Unverified Commit 13fcfabf authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

refactor(CI): Convert daily turbopack (areweturboyet) integration tests into…

refactor(CI): Convert daily turbopack (areweturboyet) integration tests into reusable workflows (#76251)

This builds on top of work that @timneutkens did in the
`wbinnssmith/try-ci-test` branch to rebuild the integration test CI on
top of `build_reusable.yml` and work around issues with the
`next-integration-stat`, but takes it a few steps further:

- As much of the integration test logic as possible is moved into a
single re-usable workflow so that we won't need to duplicate logic
between 6 workflows going forward (turbopack dev, turbopack build,
turbopack examples, rspack dev, rspack build, rspack examples). Right
now this just ports turbopack dev and build.

- Cleaned up a ton of legacy dead/broken code in
`next-integration-stat`. We might want to revive the comment-on-PR
functionality, so I didn't completely remove it, just the very obviously
broken parts (e.g. references to a >2-year-old stale branch of the
turborepo repository).

---

Manually triggered the workflows:

Dev tests: https://github.com/vercel/next.js/actions/runs/13466611352
Prod tests: https://github.com/vercel/next.js/actions/runs/13466609857

Tested by patching the `test/build-turbopack-*-tests-manifest.js`
scripts like so:

```diff
diff --git a/test/build-turbopack-dev-tests-manifest.js b/test/build-turbopack-dev-tests-manifest.js
index bc1928cf2d..e6546e0018 100644
--- a/test/build-turbopack-dev-tests-manifest.js
+++ b/test/build-turbopack-dev-tests-manifest.js
@@ -91,7 +91,11 @@ async function fetchLatestTestArtifact() {
   const res = JSON.parse(stdout)
 
   for (const artifact of res.artifacts) {
-    if (artifact.expired || artifact.workflow_run.head_branch !== 'canary') {
+    if (
+      artifact.expired ||
+      artifact.workflow_run.head_branch !==
+        'bgw/reusable-integration-test-workflow'
+    ) {
       continue
     }
```

And then diffing the generated json manifests:
https://gist.github.com/bgw/08778b5f63861811fbe88e3f466a8679

Note that some differences are expected: These jobs have been broken for
at least 2-3 weeks.
parent 319e3058
.github/actions/*/dist/** -text linguist-vendored
packages/next/bundles/** -text linguist-vendored
packages/next/compiled/** -text linguist-vendored
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,8 +2,6 @@ import { context, getOctokit } from '@actions/github'
import { info, getInput } from '@actions/core'
const { default: stripAnsi } = require('strip-ansi')
const fs = require('fs')
const path = require('path')
const semver = require('semver')
/// <reference path="./manifest" />
......@@ -18,67 +16,9 @@ const BOT_COMMENT_MARKER = `<!-- __marker__ next.js integration stats __marker__
// Header for the test report.
const commentTitlePre = `## Failing next.js integration test suites`
async function findNextJsVersionFromBuildLogs(
octokit: Octokit,
token: string,
job: Job
): Promise<string> {
console.log(
'findNextJsVersionFromBuildLogs: Checking logs for the job ',
job.name
)
// downloadJobLogsForWorkflowRun returns a redirect to the actual logs
const jobLogRedirectResponse =
await octokit.rest.actions.downloadJobLogsForWorkflowRun({
accept: 'application/vnd.github+json',
...context.repo,
job_id: job.id,
})
console.log(
'findNextJsVersionFromBuildLogs: Trying to get logs from redirect url ',
jobLogRedirectResponse.url
)
// fetch the actual logs
const jobLogsResponse = await fetch(jobLogRedirectResponse.url, {
headers: {
Accept: 'application/vnd.github.v3+json',
// [NOTE] we used to attach auth token, but seems this can cause 403
// redirect url is public anyway
//Authorization: `token ${token}`,
},
})
if (!jobLogsResponse.ok) {
throw new Error(
`Failed to get logsUrl, got status ${jobLogsResponse.status}`
)
}
// this should be the check_run's raw logs including each line
// prefixed with a timestamp in format 2020-03-02T18:42:30.8504261Z
const logText: string = await jobLogsResponse.text()
const dateTimeStripped = logText
.split('\n')
.map((line) => line.substr('2020-03-02T19:39:16.8832288Z '.length))
const nextjsVersion = dateTimeStripped
.find((x) => x.includes('RUNNING NEXTJS VERSION:') && !x.includes('$('))
?.split('RUNNING NEXTJS VERSION:')
.pop()
?.trim()!
console.log('Found Next.js version: ', nextjsVersion)
return nextjsVersion
}
// Download logs for a job in a workflow run by reading redirect url from workflow log response.
async function fetchJobLogsFromWorkflow(
octokit: Octokit,
token: string,
job: Job
): Promise<{ logs: string; job: Job }> {
console.log(
......@@ -86,6 +26,7 @@ async function fetchJobLogsFromWorkflow(
)
// downloadJobLogsForWorkflowRun returns a redirect to the actual logs
// The returned URL is valid (without any additional auth) for 1 minute
const jobLogRedirectResponse =
await octokit.rest.actions.downloadJobLogsForWorkflowRun({
accept: 'application/vnd.github.v3+json',
......@@ -101,7 +42,6 @@ async function fetchJobLogsFromWorkflow(
const jobLogsResponse = await fetch(jobLogRedirectResponse.url, {
headers: {
Accept: 'application/vnd.github.v3+json',
//Authorization: `token ${token}`,
},
})
......@@ -120,7 +60,7 @@ async function fetchJobLogsFromWorkflow(
const logText: string = await jobLogsResponse.text()
const dateTimeStripped = logText
.split('\n')
.map((line) => line.substr('2020-03-02T19:39:16.8832288Z '.length))
.map((line) => line.substring('2020-03-02T19:39:16.8832288Z '.length))
const logs = dateTimeStripped.join('\n')
......@@ -130,7 +70,6 @@ async function fetchJobLogsFromWorkflow(
// Collect necessary inputs to run actions,
async function getInputs(): Promise<{
token: string
shouldDiffWithMain: boolean
octokit: Octokit
prNumber: number | undefined
sha: string
......@@ -138,37 +77,28 @@ async function getInputs(): Promise<{
shouldExpandResultMessages: boolean
}> {
const token = getInput('token')
const octokit = getOctokit(token)
const shouldExpandResultMessages =
getInput('expand_result_messages') === 'true'
const diffBase = getInput('diff_base')
const shouldDiffWithMain = diffBase === 'main'
// For the daily cron workflow, we don't compare to previous but post daily summary
const noBaseComparison = diffBase === 'none'
if (diffBase !== 'main' && diffBase !== 'release' && diffBase !== 'none') {
console.error('Invalid diff_base, must be "main" or "release" or "none"')
process.exit(1)
}
if (!shouldExpandResultMessages) {
console.log('Test report comment will not include result messages.')
}
const octokit = getOctokit(token)
const prNumber = context?.payload?.pull_request?.number
const sha = context?.sha
let comments:
| Awaited<ReturnType<typeof octokit.rest.issues.listComments>>['data']
| null = null
// For the daily cron workflow, we don't compare to previous but post daily summary
const noBaseComparison = prNumber == null
if (prNumber) {
if (prNumber != null) {
console.log('Trying to collect integration stats for PR', {
prNumber,
sha: sha,
})
comments = await octokit.paginate(octokit.rest.issues.listComments, {
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
...context.repo,
issue_number: prNumber,
per_page: 200,
......@@ -198,23 +128,21 @@ async function getInputs(): Promise<{
info('No PR number found in context, will not try to post comment.')
}
console.log('getInputs: these inputs will be used to collect test results', {
token: !!token,
shouldDiffWithMain,
prNumber,
sha,
diff_base: getInput('diff_base'),
})
return {
const inputs = {
token,
shouldDiffWithMain,
octokit,
prNumber,
sha,
noBaseComparison,
shouldExpandResultMessages,
}
console.log('getInputs: these inputs will be used to collect test results', {
...inputs,
token: !!token, // redact this
})
return inputs
}
// Iterate all the jobs in the current workflow run, collect & parse logs for failed jobs for the postprocessing.
......@@ -233,45 +161,9 @@ async function getJobResults(
}
)
// Filter out next.js build setup jobs
const nextjsBuildSetupJob = jobs?.find((job) =>
/Build Next.js for the turbopack integration test$/.test(job.name)
)
// Next.js build setup jobs includes the version of next.js that is being tested, try to read it.
const nextjsVersion = await findNextJsVersionFromBuildLogs(
octokit,
token,
nextjsBuildSetupJob
)
// Find out next-swc build workflow
const nextSwcBuildJob = jobs?.find((job) =>
job.name.includes('Build Next.js for the turbopack integration test')
)
const nextSwcBuildLogs = (
await fetchJobLogsFromWorkflow(octokit, token, nextSwcBuildJob)
).logs.split('\n')
const buildTimeMatch = (
nextSwcBuildLogs.find((line) => line.includes('Time (abs ≡):')) ?? ''
).match(/ ([+-]?(?=\.\d|\d)(?:\d+)?(?:\.?\d*))(?:[Ee]([+-]?\d+))? s/)
const buildTime = buildTimeMatch?.length >= 2 ? buildTimeMatch[1] : undefined
const nextSwcBuildSize = (
nextSwcBuildLogs.find(
(line) =>
line.includes('NEXT_SWC_FILESIZE:') &&
/NEXT_SWC_FILESIZE: (\d+)/.test(line)
) ?? ''
).match(/NEXT_SWC_FILESIZE: (\d+)/)[1]
console.log(`Found next-swc build information from build logs`, {
buildTime,
nextSwcBuildSize,
})
// Filter out next.js integration test jobs
const integrationTestJobs = jobs?.filter((job) =>
/Next\.js integration test \([^)]*\) \([^)]*\)$/.test(job.name)
/Next\.js integration test \([^)]*\) \([^)]*\)/.test(job.name)
)
console.log(
......@@ -281,20 +173,11 @@ async function getJobResults(
// Iterate over all of next.js integration test jobs, read logs and collect failed test results if exists.
const fullJobLogsFromWorkflow = await Promise.all(
integrationTestJobs.map((job) =>
fetchJobLogsFromWorkflow(octokit, token, job)
)
integrationTestJobs.map((job) => fetchJobLogsFromWorkflow(octokit, job))
)
console.log('Logs downloaded for all jobs')
const testResultManifest: TestResultManifest = {
nextjsVersion,
buildTime,
buildSize: nextSwcBuildSize,
ref: sha,
} as any
const [jobResults, flakyMonitorJobResults] = fullJobLogsFromWorkflow.reduce(
(acc, { logs, job }) => {
const subset = job.name.includes('FLAKY_SUBSET')
......@@ -306,7 +189,7 @@ async function getJobResults(
// First item isn't test data, it's just the log header
splittedLogs.shift()
for (const logLine of splittedLogs) {
let testData
let testData: string | undefined
try {
testData = logLine.split('--test output end--')[0].trim()!
......@@ -333,8 +216,11 @@ async function getJobResults(
console.log(`Flakyness test subset results`, { flakyMonitorJobResults })
testResultManifest.flakyMonitorJobResults = flakyMonitorJobResults
testResultManifest.result = jobResults
const testResultManifest: TestResultManifest = {
ref: sha,
flakyMonitorJobResults: flakyMonitorJobResults,
result: jobResults,
}
// Collect all test results into single manifest to store into file. This'll allow to upload / compare test results
// across different runs.
......@@ -348,158 +234,16 @@ async function getJobResults(
// Get the latest base test results to diff against with current test results.
async function getTestResultDiffBase(
octokit: Octokit,
shouldDiffWithMain: boolean
_octokit: Octokit
): Promise<TestResultManifest | null> {
console.log('Trying to find latest test results to compare')
// First, get the tree of `test-results` from `nextjs-integration-test-data` branch
const branchTree = (
await octokit.rest.git.getTree({
...context.repo,
tree_sha: 'refs/heads/nextjs-integration-test-data',
})
).data.tree.find((tree) => tree.path === 'test-results')
if (!branchTree || !branchTree.sha) {
console.error("Couldn't find existing test results")
return null
}
// Get the trees under `/test-results`
const testResultsTree = (
await octokit.rest.git.getTree({
...context.repo,
tree_sha: branchTree.sha,
})
).data.tree
// If base is main, get the tree under `test-results/main`
// Otherwise iterate over all the trees under `test-results` then find latest next.js release
let testResultJsonTree:
| Awaited<
ReturnType<Awaited<Octokit['rest']['git']['getTree']>>
>['data']['tree']
| undefined
if (shouldDiffWithMain) {
console.log('Trying to find latest test results from main branch')
const baseTree = testResultsTree.find((tree) => tree.path === 'main')
if (!baseTree || !baseTree.sha) {
console.log('There is no base to compare test results against')
return null
}
console.log('Found base tree', baseTree)
// Now tree should point the list of .json for the actual test results
testResultJsonTree = (
await octokit.rest.git.getTree({
...context.repo,
tree_sha: baseTree.sha,
})
).data.tree
} else {
console.log('Trying to find latest test results from next.js release')
const getVersion = (v: { path?: string }) => {
if (v.path) {
console.log('Trying to get version from base path', v.path)
const base = path.basename(v.path, '.json')
const ret = base.split('-').slice(1, 3).join('-')
console.log('Found version', ret)
return ret
}
return null
}
const baseTree = testResultsTree
.filter((tree) => tree.path !== 'main')
.reduce((acc, value) => {
if (!acc) {
return value
}
const currentVersion = semver.valid(getVersion(value))
const accVersion = semver.valid(getVersion(acc))
if (!currentVersion || !accVersion) {
return acc
}
return semver.gt(currentVersion, accVersion) ? value : acc
}, null)
if (!baseTree || !baseTree.sha) {
console.log('There is no base to compare test results against')
return null
}
console.log('Found base tree', baseTree)
// If the results is for the release, no need to traverse down the tree
testResultJsonTree = [baseTree]
}
if (!testResultJsonTree) {
console.log('There is no test results stored in the base yet')
return null
}
// Find the latest test result tree, iterate results file names to find out the latest one.
// Filename follow ${yyyyMMddHHmm}-${sha}.json format.
const actualTestResultTree = testResultJsonTree.reduce(
(acc, value) => {
const dateStr = value.path?.split('-')[0].match(/(....)(..)(..)(..)(..)/)
if (!dateStr || dateStr.length < 5) {
return acc
}
const date = new Date(
dateStr![1] as any,
(dateStr![2] as any) - 1,
dateStr![3] as any,
dateStr![4] as any,
dateStr![5] as any
)
if (!acc) {
return {
date,
value,
}
}
return acc.date >= date ? acc : { date, value }
},
null as any as { date: Date; value: (typeof testResultJsonTree)[0] }
)
if (!actualTestResultTree || !actualTestResultTree?.value?.sha) {
console.log('There is no test results json stored in the base yet')
return null
}
console.log(
'Found test results to compare against: ',
actualTestResultTree.value
)
// actualTestResultTree should point to the file that contains the test results
// we can try to read now.
const { data } = await octokit.rest.git.getBlob({
...context.repo,
file_sha: actualTestResultTree.value.sha,
})
const { encoding, content } = data
if (encoding === 'base64') {
return JSON.parse(Buffer.from(content, 'base64').toString())
} else if (encoding === 'utf-8') {
return JSON.parse(content)
} else {
throw new Error('Unknown encoding: ' + encoding)
}
// TODO: This code was previously written for the `vercel/turborepo`
// repository which used to have a `nextjs-integration-test-data` branch with
// all the previous test run data.
//
// The last update to that branch is from Dec 2023. If we want to support
// comparisions with the canary branch, we need to read this data from
// somewhere else.
return null
}
function withoutRetries(results: Array<JobResult>): Array<JobResult> {
......@@ -519,7 +263,6 @@ function withoutRetries(results: Array<JobResult>): Array<JobResult> {
function getTestSummary(
sha: string,
shouldDiffWithMain: boolean,
baseResults: TestResultManifest | null,
jobResults: TestResultManifest
) {
......@@ -559,8 +302,6 @@ function getTestSummary(
}
)
const shortCurrentNextJsVersion = jobResults.nextjsVersion.split(' ')[1]
console.log(
'Current test summary',
JSON.stringify(
......@@ -656,15 +397,9 @@ function getTestSummary(
testCaseDiff = `:arrow_up_small: ${-caseCountDiff}`
}
const shortBaseNextJsVersion = baseResults.nextjsVersion.split(' ')[1]
// Append summary test report to the comment body
let ret = `### Test summary
| | ${
shouldDiffWithMain
? `main (${baseResults.ref} / ${shortBaseNextJsVersion})`
: `release (${baseResults.ref} / ${shortBaseNextJsVersion})`
} | Current (${sha} / ${shortCurrentNextJsVersion}) | Diff (Failed) |
| | ${`canary (${baseResults.ref}`} | Current (${sha}) | Diff (Failed) |
|---|---|---|---|
| Test suites | :red_circle: ${baseTestFailedSuiteCount} / :green_circle: ${baseTestPassedSuiteCount} (Total: ${baseTestTotalSuiteCount}) | :red_circle: ${currentTestFailedSuiteCount} / :green_circle: ${currentTestPassedSuiteCount} (Total: ${currentTestTotalSuiteCount}) | ${testSuiteDiff} |
| Test cases | :red_circle: ${baseTestFailedCaseCount} / :green_circle: ${baseTestPassedCaseCount} (Total: ${baseTestTotalCaseCount}) | :red_circle: ${currentTestFailedCaseCount} / :green_circle: ${currentTestPassedCaseCount} (Total: ${currentTestTotalCaseCount}) | ${testCaseDiff} |
......@@ -740,7 +475,6 @@ async function run() {
const {
token,
octokit,
shouldDiffWithMain,
prNumber,
sha,
noBaseComparison,
......@@ -753,7 +487,7 @@ async function run() {
// Get the base to compare against
const baseResults = noBaseComparison
? null
: await getTestResultDiffBase(octokit, shouldDiffWithMain)
: await getTestResultDiffBase(octokit)
const postCommentAsync = createCommentPostAsync(octokit, prNumber)
......@@ -763,7 +497,7 @@ async function run() {
const perJobFailedLists = {}
// Consturct a comment body to post test report with summary & full details.
const comments = jobResults.result.reduce((acc, value, idx) => {
const comments = jobResults.result.reduce((acc, value, _idx) => {
const { data: testData } = value
const commentValues = []
......@@ -860,12 +594,7 @@ async function run() {
{
header: [`Commit: ${sha}`],
contents: [
getTestSummary(
sha,
shouldDiffWithMain,
noBaseComparison ? null : baseResults,
jobResults
),
getTestSummary(sha, noBaseComparison ? null : baseResults, jobResults),
],
},
...comments,
......
......@@ -4,10 +4,7 @@ interface JobResult {
}
interface TestResultManifest {
nextjsVersion: string
ref: string
buildTime?: string
buildSize?: string
result: Array<JobResult>
flakyMonitorJobResults: Array<JobResult>
}
......
......@@ -226,7 +226,13 @@ jobs:
- run: turbo run get-test-timings -- --build ${{ github.sha }}
- run: /bin/bash -c "${{ inputs.afterBuild }}"
- run: ${{ inputs.afterBuild }}
# defaults.run.shell sets a stronger options (`-leo pipefail`)
# Set this back to github action's weaker defaults:
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
#
# We must use a login shell: fnm installation may modify the `.profile`
shell: bash -le {0}
timeout-minutes: ${{ inputs.timeout_minutes }}
- name: Upload artifact
......
name: Integration Tests Reusable
on:
workflow_call:
inputs:
name:
description: A unique identifer used for uploaded assets
type: string
test_type:
description: '"development" or "production"'
required: true
type: string
run_before_test:
description: >
Bash code to run before executing the test (e.g. setting environment
variables). Runs in the same step as the test.
type: string
default: ''
e2e_groups:
description: >
Size of the matrix used for running e2e tests (controls parallelism)
type: number
default: 6
integration_groups:
description: >
Size of the matrix used for running legacy integration tests (controls
parallelism)
type: number
default: 6
e2e_timeout_minutes:
type: number
default: 30
integration_timeout_minutes:
type: number
default: 30
jobs:
# First, build Next.js to execute across tests.
build-next:
name: build-next
uses: ./.github/workflows/build_reusable.yml
with:
skipNativeBuild: yes
stepName: build-next
secrets: inherit
build-native:
name: build-native
uses: ./.github/workflows/build_reusable.yml
with:
skipInstallBuild: yes
stepName: build-native
secrets: inherit
generate-matrices:
runs-on: [self-hosted, linux, x64, metal]
steps:
- id: out
run: |
printf 'e2e=[%s]\n' \
"$(seq -s, 1 ${{ inputs.e2e_groups }})" | \
tee -a "$GITHUB_OUTPUT"
printf 'integration=[%s]\n' \
"$(seq -s, 1 ${{ inputs.integration_groups }})" | \
tee -a "$GITHUB_OUTPUT"
outputs:
e2e: ${{ steps.out.outputs.e2e }}
integration: ${{ steps.out.outputs.integration }}
# Actual test scheduling. These jobs mimic the normal test jobs.
# Refer build_and_test.yml for more details.
#
# We run tests in two parts. Legacy integration tests are run separately:
# https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#test-types-in-nextjs
test-e2e:
# Name must match `integrationTestJobs` in
# `./.github/actions/next-integration-stat`
name: >-
Next.js integration test (E2E and ${{ inputs.test_type }})
(${{ matrix.group }}/${{ inputs.e2e_groups }})
needs: [build-next, build-native, generate-matrices]
strategy:
fail-fast: false
matrix:
group: ${{ fromJSON(needs.generate-matrices.outputs.e2e) }}
uses: ./.github/workflows/build_reusable.yml
with:
afterBuild: |
# e2e and ${{ inputs.test_type }} tests with `node run-tests.js`
export NEXT_TEST_CONTINUE_ON_ERROR=TRUE
export NEXT_E2E_TEST_TIMEOUT=240000
export NEXT_TEST_MODE=${{
inputs.test_type == 'development' && 'dev' || 'start'
}}
${{ inputs.run_before_test }}
node run-tests.js \
-g ${{ matrix.group }}/${{ inputs.e2e_groups }} \
-c $TEST_CONCURRENCY \
--type ${{ inputs.test_type }}
stepName: test-${{ inputs.name }}-${{ matrix.group }}
timeout_minutes: ${{ inputs.e2e_timeout_minutes }}
secrets: inherit
test-integration:
# Name must match `integrationTestJobs` in
# `./.github/actions/next-integration-stat`
name: >-
Next.js integration test (Integration)
(${{ matrix.group }}/${{ inputs.e2e_groups }})
needs: [build-next, build-native, generate-matrices]
strategy:
fail-fast: false
matrix:
group: ${{ fromJSON(needs.generate-matrices.outputs.integration) }}
uses: ./.github/workflows/build_reusable.yml
with:
nodeVersion: 18.18.2
afterBuild: |
# legacy integration tests with `node run-tests.js`
export NEXT_TEST_CONTINUE_ON_ERROR=TRUE
export NEXT_E2E_TEST_TIMEOUT=240000
# HACK: Despite the name, these environment variables are just used to
# gate tests, so they're applicable to both turbopack and rspack tests
export ${{
inputs.test_type == 'development' &&
'TURBOPACK_DEV=1' ||
'TURBOPACK_BUILD=1'
}}
${{ inputs.run_before_test }}
node run-tests.js \
-g ${{ matrix.group }}/${{ inputs.integration_groups }} \
-c $TEST_CONCURRENCY \
--type integration
stepName: test-${{ inputs.name }}-integration-${{ matrix.group }}
timeout_minutes: ${{ inputs.integration_timeout_minutes }}
secrets: inherit
# Collect integration test results from execute_tests,
# Store it as github artifact for next step to consume.
collect_nextjs_development_integration_stat:
needs: [test-e2e, test-integration]
name: Next.js integration test development status report
runs-on: [self-hosted, linux, x64, metal]
if: always()
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Collect integration test stat
uses: ./.github/actions/next-integration-stat
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: test-results-${{ inputs.name }}
path: |
nextjs-test-results.json
failed-test-path-list.json
passed-test-path-list.json
# Reusable workflow to execute certain version of Next.js integration tests
# with turbopack.
#
# Refer test.yml for how this workflow is being initialized
# - Workflow can specify `inputs.version` to specify which version of next.js to use, otherwise will use latest release version.
name: Turbopack Next.js production integration tests
on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
inputs:
# Allow to specify Next.js version to run integration test against.
# If not specified, will use latest release version including canary.
version:
description: Next.js version, sha, branch to test
type: string
default: 'canary'
# The base of the test results to compare against. If not specified, will try to compare with latest main branch's test results.
diff_base:
type: string
default: 'none'
# Workflow-common env variables
env:
# Enabling backtrace will makes snapshot tests fail
RUST_BACKTRACE: 0
NEXT_TELEMETRY_DISABLED: 1
TEST_CONCURRENCY: 6
NEXT_JUNIT_TEST_REPORT: 'true'
__INTERNAL_CUSTOM_TURBOPACK_BINDINGS: ${{ github.workspace }}/packages/next-swc/native/next-swc.linux-x64-gnu.node
NEXT_TEST_SKIP_RETRY_MANIFEST: ${{ github.workspace }}/integration-test-data/test-results/main/failed-test-path-list.json
NEXT_TEST_CONTINUE_ON_ERROR: TRUE
NEXT_E2E_TEST_TIMEOUT: 240000
NEXT_TEST_JOB: 1
workflow_dispatch: {}
jobs:
# First, build Next.js to execute across tests.
setup_nextjs:
name: Setup Next.js build
uses: ./.github/workflows/setup-nextjs-build.yml
test-dev:
name: Next.js integration tests
uses: ./.github/workflows/integration_tests_reusable.yml
with:
nodeVersion: 18.18.2
version: ${{ inputs.version || 'canary' }}
# Actual test scheduling. These jobs mimic the same jobs in Next.js repo,
# which we do allow some of duplications to make it easier to update if upstream changes.
# Refer build_and_test.yml in the Next.js repo for more details.
test-production:
# This job name is being used in github action to collect test results. Do not change it, or should update
# ./.github/actions/next-integration-stat to match the new name.
name: Next.js integration test (Production)
# Currently it is possible test grouping puts large number of failing tests suites in a single group,
# which ends up job timeouts. Temporarily relieve the timeout until we make progresses on the failing suites.
# ref: https://github.com/vercel/turbo/pull/5668
# timeout-minutes: 180
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
needs: [setup_nextjs]
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.18.2
check-latest: true
- uses: actions/cache/restore@v3
id: restore-build
with:
path: ./*
key: ${{ inputs.version || 'canary' }}-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt}}-${{ github.run_number }}
fail-on-cache-miss: true
- name: Enable corepack and install yarn
run: |
corepack enable
corepack prepare --activate yarn@1.22.19
- name: Setup playwright
run: |
pnpm playwright install
- name: Run test/production
run: |
NEXT_TEST_MODE=start TURBOPACK=1 TURBOPACK_BUILD=1 NEXT_E2E_TEST_TIMEOUT=240000 node run-tests.js -g ${{ matrix.group }}/12 -c ${TEST_CONCURRENCY} --type production
# It is currently expected to fail some of next.js integration test, do not fail CI check.
continue-on-error: true
- name: Upload test report artifacts
uses: actions/upload-artifact@v4
with:
name: test-reports-start-${{ matrix.group }}
if-no-files-found: 'error'
path: |
test/turbopack-test-junit-report
test-integration-production:
name: Next.js integration test (Integration)
needs: [setup_nextjs]
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.18.2
check-latest: true
- uses: actions/cache/restore@v3
id: restore-build
with:
path: ./*
key: ${{ inputs.version || 'canary' }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Enable corepack and install yarn
run: |
corepack enable
corepack prepare --activate yarn@1.22.19
- name: Setup playwright
run: |
pnpm playwright install
- name: Run test/integration
run: |
TURBOPACK=1 TURBOPACK_BUILD=1 NEXT_E2E_TEST_TIMEOUT=240000 node run-tests.js -g ${{ matrix.group }}/12 -c ${TEST_CONCURRENCY} --type integration
continue-on-error: true
- name: Upload test report artifacts
uses: actions/upload-artifact@v4
with:
name: test-reports-build-integration-${{ matrix.group }}
if-no-files-found: 'error'
path: |
test/turbopack-test-junit-report
# Collect integration test results from execute_tests,
# Store it as github artifact for next step to consume.
collect_nextjs_production_integration_stat:
needs: [test-production, test-integration-production]
name: Next.js integration test production status report
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
if: always()
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Collect integration test stat
uses: ./.github/actions/next-integration-stat
with:
diff_base: ${{ inputs.diff_base || 'none' }}
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: test-results-turbopack-production
path: |
nextjs-test-results.json
failed-test-path-list.json
passed-test-path-list.json
upload_test_report:
needs: [test-production, test-integration-production]
name: Upload test report to datadog
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
if: ${{ !cancelled() }}
steps:
- name: Download test report artifacts
id: download-test-reports
uses: actions/download-artifact@v4
with:
pattern: test-reports-*
path: test/reports
merge-multiple: true
- name: Upload to datadog
env:
DATADOG_API_KEY: ${{ secrets.DATA_DOG_API_KEY }}
DD_ENV: 'ci'
run: |
# We'll tag this to the "Turbopack" datadog service, not "nextjs"
npx @datadog/datadog-ci@2.23.1 junit upload --tags test.type:turbopack-build.daily --service Turbopack-build ./test/reports
name: turbopack-production
test_type: production
run_before_test: |
export TURBOPACK=1 TURBOPACK_BUILD=1
# Failing tests take longer (due to timeouts and retries). Since we have
# many failing tests, we need smaller groups and longer timeouts, in case
# a group gets stuck with a cluster of failing tests.
e2e_groups: 12
integration_groups: 12
e2e_timeout_minutes: 60
integration_timeout_minutes: 60
secrets: inherit
# Reusable workflow to execute certain version of Next.js integration tests
# with turbopack.
#
# Refer test.yml for how this workflow is being initialized
# - Workflow can specify `inputs.version` to specify which version of next.js to use, otherwise will use latest release version.
name: Turbopack Next.js development integration tests
on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
inputs:
# Allow to specify Next.js version to run integration test against.
# If not specified, will use latest release version including canary.
version:
description: Next.js version, sha, branch to test
type: string
default: 'canary'
# The base of the test results to compare against. If not specified, will try to compare with latest main branch's test results.
diff_base:
type: string
default: 'none'
# Workflow-common env variables
env:
# Enabling backtrace will makes snapshot tests fail
RUST_BACKTRACE: 0
NEXT_TELEMETRY_DISABLED: 1
TEST_CONCURRENCY: 6
NEXT_JUNIT_TEST_REPORT: 'true'
__INTERNAL_CUSTOM_TURBOPACK_BINDINGS: ${{ github.workspace }}/packages/next-swc/native/next-swc.linux-x64-gnu.node
NEXT_TEST_SKIP_RETRY_MANIFEST: ${{ github.workspace }}/integration-test-data/test-results/main/failed-test-path-list.json
NEXT_TEST_CONTINUE_ON_ERROR: TRUE
NEXT_E2E_TEST_TIMEOUT: 240000
NEXT_TEST_JOB: 1
workflow_dispatch: {}
jobs:
# First, build next-dev and Next.js both to execute across tests.
setup_nextjs:
name: Setup Next.js build
uses: ./.github/workflows/setup-nextjs-build.yml
with:
nodeVersion: 18.18.2
version: ${{ inputs.version || 'canary' }}
# Actual test scheduling. These jobs mimic the same jobs in Next.js repo,
# which we do allow some of duplications to make it easier to update if upstream changes.
# Refer build_and_test.yml in the Next.js repo for more details.
test-dev:
# This job name is being used in github action to collect test results. Do not change it, or should update
# ./.github/actions/next-integration-stat to match the new name.
name: Next.js integration test (Development)
# Currently it is possible test grouping puts large number of failing tests suites in a single group,
# which ends up job timeouts. Temporarily relieve the timeout until we make progresses on the failing suites.
# ref: https://github.com/vercel/turbo/pull/5668
# timeout-minutes: 180
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
needs: [setup_nextjs]
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.18.2
check-latest: true
- uses: actions/cache/restore@v3
id: restore-build
with:
path: ./*
key: ${{ inputs.version || 'canary' }}-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt}}-${{ github.run_number }}
fail-on-cache-miss: true
- name: Enable corepack and install yarn
run: |
corepack enable
corepack prepare --activate yarn@1.22.19
- name: Setup playwright
run: |
pnpm playwright install
- name: Run test/development
run: |
NEXT_TEST_MODE=dev TURBOPACK=1 TURBOPACK_DEV=1 NEXT_E2E_TEST_TIMEOUT=240000 node run-tests.js -g ${{ matrix.group }}/12 -c ${TEST_CONCURRENCY} --type development
# It is currently expected to fail some of next.js integration test, do not fail CI check.
continue-on-error: true
- name: Upload test report artifacts
uses: actions/upload-artifact@v4
with:
name: test-reports-dev-${{ matrix.group }}
if-no-files-found: 'error'
path: |
test/turbopack-test-junit-report
test-integration-development:
name: Next.js integration test (Integration)
needs: [setup_nextjs]
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.18.2
check-latest: true
- uses: actions/cache/restore@v3
id: restore-build
with:
path: ./*
key: ${{ inputs.version || 'canary' }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Enable corepack and install yarn
run: |
corepack enable
corepack prepare --activate yarn@1.22.19
- name: Setup playwright
run: |
pnpm playwright install
- name: Run test/integration
run: |
TURBOPACK=1 TURBOPACK_DEV=1 NEXT_E2E_TEST_TIMEOUT=240000 node run-tests.js -g ${{ matrix.group }}/12 -c ${TEST_CONCURRENCY} --type integration
continue-on-error: true
- name: Upload test report artifacts
uses: actions/upload-artifact@v4
with:
name: test-reports-dev-integration-${{ matrix.group }}
if-no-files-found: 'error'
path: |
test/turbopack-test-junit-report
# Collect integration test results from execute_tests,
# Store it as github artifact for next step to consume.
collect_nextjs_development_integration_stat:
needs: [test-dev, test-integration-development]
name: Next.js integration test development status report
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
if: always()
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Collect integration test stat
uses: ./.github/actions/next-integration-stat
with:
diff_base: ${{ inputs.diff_base || 'none' }}
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: test-results-turbopack-development
path: |
nextjs-test-results.json
failed-test-path-list.json
passed-test-path-list.json
upload_test_report:
needs: [test-dev, test-integration-development]
name: Upload test report to datadog
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
if: ${{ !cancelled() }}
steps:
- name: Download test report artifacts
id: download-test-reports
uses: actions/download-artifact@v4
with:
pattern: test-reports-*
path: test/reports
merge-multiple: true
- name: Upload to datadog
env:
DATADOG_API_KEY: ${{ secrets.DATA_DOG_API_KEY }}
DD_ENV: 'ci'
run: |
# We'll tag this to the "Turbopack" datadog service, not "nextjs"
npx @datadog/datadog-ci@2.23.1 junit upload --tags test.type:turbopack.daily --service Turbopack ./test/reports
name: Next.js integration tests
uses: ./.github/workflows/integration_tests_reusable.yml
with:
name: turbopack-development
test_type: development
run_before_test: |
export TURBOPACK=1
secrets: inherit
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment