Unverified Commit 53d017d3 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Parallelize dev/start flake detection (#63954)

Since we're re-running tests a few times and in both modes this can take
a while ([related
run](https://github.com/vercel/next.js/actions/runs/8514892757/job/23321431099?pr=56995)),
so this parallelizes by separating dev/prod into separate jobs.

Closes NEXT-2975
parent fbfd1b27
...@@ -256,15 +256,27 @@ jobs: ...@@ -256,15 +256,27 @@ jobs:
secrets: inherit secrets: inherit
test-new-tests: test-new-tests-dev:
name: Test new tests for flakes name: Test new tests for flakes (dev)
needs: ['changes', 'build-native', 'build-next'] needs: ['changes', 'build-native', 'build-next']
if: ${{ needs.changes.outputs.docs-only == 'false' }} if: ${{ needs.changes.outputs.docs-only == 'false' }}
uses: ./.github/workflows/build_reusable.yml uses: ./.github/workflows/build_reusable.yml
with: with:
afterBuild: node scripts/test-new-tests.mjs afterBuild: node scripts/test-new-tests.mjs --dev-mode
stepName: 'test-new-tests' stepName: 'test-new-tests-dev'
secrets: inherit
test-new-tests-start:
name: Test new tests for flakes (prod)
needs: ['changes', 'build-native', 'build-next']
if: ${{ needs.changes.outputs.docs-only == 'false' }}
uses: ./.github/workflows/build_reusable.yml
with:
afterBuild: node scripts/test-new-tests.mjs --prod-mode
stepName: 'test-new-tests-start'
secrets: inherit secrets: inherit
......
...@@ -4,6 +4,8 @@ import execa from 'execa' ...@@ -4,6 +4,8 @@ import execa from 'execa'
import path from 'path' import path from 'path'
async function main() { async function main() {
let testMode = process.argv.includes('--dev-mode') ? 'dev' : 'start'
let eventData = {} let eventData = {}
/** @type import('execa').Options */ /** @type import('execa').Options */
...@@ -57,6 +59,7 @@ async function main() { ...@@ -57,6 +59,7 @@ async function main() {
branchName, branchName,
remoteUrl, remoteUrl,
isCanary, isCanary,
testMode,
}, },
`\ngit diff:\n${changesResult.stderr}\n${changesResult.stdout}` `\ngit diff:\n${changesResult.stderr}\n${changesResult.stdout}`
) )
...@@ -99,42 +102,25 @@ async function main() { ...@@ -99,42 +102,25 @@ async function main() {
) )
) )
if (prodTests.length === 0 && devTests.length === 0) { const currentTests = testMode === 'dev' ? devTests : prodTests
if (currentTests.length === 0) {
console.log(`No added/changed tests detected`) console.log(`No added/changed tests detected`)
return return
} }
const RUN_TESTS_ARGS = ['run-tests.js', '-c', '1', '--retries', '0'] const RUN_TESTS_ARGS = ['run-tests.js', '-c', '1', '--retries', '0']
async function invokeRunTests({ mode, testFiles }) { for (let i = 0; i < 3; i++) {
await execa('node', [...RUN_TESTS_ARGS, ...testFiles], { console.log(`\n\nRun ${i + 1} for ${testMode} tests`)
await execa('node', [...RUN_TESTS_ARGS, ...currentTests], {
...EXECA_OPTS_STDIO, ...EXECA_OPTS_STDIO,
env: { env: {
...process.env, ...process.env,
NEXT_TEST_MODE: mode, NEXT_TEST_MODE: testMode,
}, },
}) })
} }
if (devTests.length > 0) {
for (let i = 0; i < 3; i++) {
console.log(`\n\nRun ${i + 1} for dev tests`)
await invokeRunTests({
mode: 'dev',
testFiles: devTests,
})
}
}
if (prodTests.length > 0) {
for (let i = 0; i < 3; i++) {
console.log(`\n\nRun ${i + 1} for production tests`)
await invokeRunTests({
mode: 'start',
testFiles: prodTests,
})
}
}
} }
main().catch((err) => { main().catch((err) => {
......
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