Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
1a808968
Unverified
Commit
1a808968
authored
Aug 28, 2026
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Aug 28, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[15.5.x][ci] Run flake detection and new deploy tests when merged and on backport branches (#98019)
parent
6d9b5d8e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
110 additions
and
124 deletions
+110
-124
build_and_deploy.yml
.github/workflows/build_and_deploy.yml
+5
-1
build_and_test.yml
.github/workflows/build_and_test.yml
+4
-10
build_reusable.yml
.github/workflows/build_reusable.yml
+3
-0
create-release-branch.js
scripts/create-release-branch.js
+0
-6
get-changed-tests.mjs
scripts/get-changed-tests.mjs
+4
-69
git-info.js
scripts/git-info.js
+82
-0
run-for-change.js
scripts/run-for-change.js
+12
-38
No files found.
.github/workflows/build_and_deploy.yml
View file @
1a808968
...
...
@@ -50,7 +50,11 @@ jobs:
steps
:
-
uses
:
actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
# v6.0.2
with
:
fetch-depth
:
1
# Changing the checked out ref has wide implications:
# Be aware that all git-diff operations in the repo rely on the
# default behavior of GitHub actions (ref on push, merge-commit on PR).
# 2 last commits so that we can create a diff with HEAD~1
fetch-depth
:
2
-
run
:
echo "${{ github.event.after }}"
-
name
:
Setup node
uses
:
actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
# v6.4.0
...
...
.github/workflows/build_and_test.yml
View file @
1a808968
...
...
@@ -614,9 +614,7 @@ jobs:
test-new-tests-dev
:
name
:
Test new tests for flakes (dev)
needs
:
[
'
optimize-ci'
,
'
changes'
,
'
build-native'
,
'
build-next'
]
# test-new-tests-if
if
:
false
# test-new-tests-end-if
if
:
${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' }}
strategy
:
fail-fast
:
false
...
...
@@ -642,9 +640,7 @@ jobs:
test-new-tests-start
:
name
:
Test new tests for flakes (prod)
needs
:
[
'
optimize-ci'
,
'
changes'
,
'
build-native'
,
'
build-next'
]
# test-new-tests-if
if
:
false
# test-new-tests-end-if
if
:
${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' }}
strategy
:
fail-fast
:
false
...
...
@@ -668,10 +664,8 @@ jobs:
test-new-tests-deploy
:
name
:
Test new tests when deployed
needs
:
[
'
optimize-ci'
,
'
test-prod'
,
'
test-new-tests-start'
]
# test-new-tests-if
if
:
false
# test-new-tests-end-if
needs
:
[
'
optimize-ci'
,
'
changes'
,
'
test-prod'
,
'
test-new-tests-start'
]
if
:
${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' && needs.changes.outputs.is-release == 'false' }}
strategy
:
fail-fast
:
false
...
...
.github/workflows/build_reusable.yml
View file @
1a808968
...
...
@@ -194,6 +194,9 @@ jobs:
-
uses
:
actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
# v6.0.2
with
:
# Changing the checked out ref has wide implications:
# Be aware that all git-diff operations in the repo rely on the
# default behavior of GitHub actions (ref on push, merge-commit on PR).
fetch-depth
:
25
# local action -> needs to run after checkout
...
...
scripts/create-release-branch.js
View file @
1a808968
...
...
@@ -77,12 +77,6 @@ async function main() {
.
replace
(
`['canary']`
,
`['
${
branchName
}
']`
)
.
replace
(
/
[\s]{1,}(
'test-new-tests-.+',
)
/g
,
''
)
buildAndTest
=
buildAndTest
.
replace
(
/
(
^
[
\t]
*
)
# test-new-tests-if
\n(
^
[
\t]
*
)
if:.*
\n(
^
[
\t]
*
)
# test-new-tests-end-if/gm
,
(
_
,
indent1
,
indent2
,
indent3
)
=>
`
${
indent1
}
# test-new-tests-if\n
${
indent2
}
if: false\n
${
indent3
}
# test-new-tests-end-if`
)
await
fs
.
promises
.
writeFile
(
buildAndTestPath
,
buildAndTest
)
await
execa
(
`git add .`
,
{
...
...
scripts/get-changed-tests.mjs
View file @
1a808968
...
...
@@ -2,83 +2,19 @@
import
fs
from
'fs/promises'
import
execa
from
'execa'
import
path
from
'path'
import
{
getDiffRevision
,
getGitInfo
}
from
'./git-info.js'
/**
* Detects changed
tests files by comparing the current branch with `origin/canary`
* Detects changed
(see {@link getDiffRevision}) tests files.
* Returns tests separated by test mode (dev/prod), as well as the corresponding commit hash
* that the current branch is pointing to
*/
export
default
async
function
getChangedTests
()
{
let
eventData
=
{}
/** @type import('execa').Options */
const
EXECA_OPTS
=
{
shell
:
true
}
/** @type import('execa').Options */
const
EXECA_OPTS_STDIO
=
{
...
EXECA_OPTS
,
stdio
:
'inherit'
}
try
{
eventData
=
JSON
.
parse
(
await
fs
.
readFile
(
process
.
env
.
GITHUB_EVENT_PATH
||
''
,
'utf8'
)
)[
'pull_request'
]
||
{}
}
catch
(
_
)
{}
const
branchName
=
eventData
?.
head
?.
ref
||
process
.
env
.
GITHUB_REF_NAME
||
(
await
execa
(
'git rev-parse --abbrev-ref HEAD'
,
EXECA_OPTS
)).
stdout
const
remoteUrl
=
eventData
?.
head
?.
repo
?.
full_name
||
process
.
env
.
GITHUB_REPOSITORY
||
(
await
execa
(
'git remote get-url origin'
,
EXECA_OPTS
)).
stdout
const
commitSha
=
eventData
?.
head
?.
sha
||
process
.
env
.
GITHUB_SHA
||
(
await
execa
(
'git rev-parse HEAD'
,
EXECA_OPTS
)).
stdout
const
isCanary
=
branchName
.
trim
()
===
'canary'
&&
remoteUrl
.
includes
(
'vercel/next.js'
)
if
(
isCanary
)
{
console
.
log
(
`Skipping flake detection for canary`
)
return
{
devTests
:
[],
prodTests
:
[]
}
}
let
diffRevision
if
(
process
.
env
.
GITHUB_ACTIONS
===
'true'
&&
process
.
env
.
GITHUB_EVENT_NAME
===
'pull_request'
)
{
// GH Actions for `pull_request` run on the merge commit so HEAD~1:
// 1. includes all changes in the PR
// e.g. in
// A-B-C-main - F
// \ /
// D-E-branch
// GH actions for `branch` runs on F, so a diff for HEAD~1 includes the diff of D and E combined
// 2. Includes all changes of the commit for pushes
diffRevision
=
'HEAD~1'
}
else
{
try
{
await
execa
(
'git remote set-branches --add origin canary'
,
EXECA_OPTS_STDIO
)
await
execa
(
'git fetch origin canary --depth=20'
,
EXECA_OPTS_STDIO
)
}
catch
(
err
)
{
console
.
error
(
await
execa
(
'git remote -v'
,
EXECA_OPTS_STDIO
))
console
.
error
(
`Failed to fetch origin/canary`
,
err
)
}
// TODO: We should diff against the merge base with origin/canary not directly against origin/canary.
// A --- B ---- origin/canary
// \
// \-- C ---- HEAD
// `git diff origin/canary` includes B and C
// But we should only include C.
diffRevision
=
'origin/canary'
}
const
{
branchName
,
remoteUrl
,
commitSha
}
=
await
getGitInfo
()
const
diffRevision
=
await
getDiffRevision
()
const
changesResult
=
await
execa
(
`git diff
${
diffRevision
}
--name-only`
,
...
...
@@ -91,7 +27,6 @@ export default async function getChangedTests() {
{
branchName
,
remoteUrl
,
isCanary
,
commitSha
,
},
`\ngit diff:\n
${
changesResult
.
stderr
}
\n
${
changesResult
.
stdout
}
`
...
...
scripts/git-info.js
0 → 100644
View file @
1a808968
// @ts-check
const
fs
=
require
(
'fs/promises'
)
const
{
promisify
}
=
require
(
'util'
)
const
{
exec
:
execOrig
}
=
require
(
'child_process'
)
const
exec
=
promisify
(
execOrig
)
/**
* Gets git repository information from the environment
* @returns {Promise<{branchName: string, remoteUrl: string, commitSha: string}>}
*/
async
function
getGitInfo
()
{
let
eventData
=
{}
try
{
eventData
=
JSON
.
parse
(
await
fs
.
readFile
(
process
.
env
.
GITHUB_EVENT_PATH
||
''
,
'utf8'
)
)[
'pull_request'
]
||
{}
}
catch
(
_
)
{}
const
branchName
=
eventData
?.
head
?.
ref
||
process
.
env
.
GITHUB_REF_NAME
||
(
await
exec
(
'git rev-parse --abbrev-ref HEAD'
)).
stdout
.
trim
()
const
remoteUrl
=
eventData
?.
head
?.
repo
?.
full_name
||
process
.
env
.
GITHUB_REPOSITORY
||
(
await
exec
(
'git remote get-url origin'
)).
stdout
.
trim
()
const
commitSha
=
eventData
?.
head
?.
sha
||
process
.
env
.
GITHUB_SHA
||
(
await
exec
(
'git rev-parse HEAD'
)).
stdout
.
trim
()
return
{
branchName
,
remoteUrl
,
commitSha
}
}
/**
* Determines the appropriate git diff revision based on the environment
* @returns {Promise<string>} The git revision to diff against
*/
async
function
getDiffRevision
()
{
if
(
process
.
env
.
GITHUB_ACTIONS
===
'true'
)
{
const
eventName
=
process
.
env
.
GITHUB_EVENT_NAME
switch
(
eventName
)
{
// GH Actions for `pull_request` run on the merge commit by default so HEAD~1:
// 1. includes all changes in the PR
// e.g. in
// A-B-C-main - F
// \ /
// D-E-branch
// GH actions for `branch` runs on F, so a diff for HEAD~1 includes the diff of D and E combined
// 2. Includes all changes of the commit for pushes (assuming the push event is from a squash merge)
case
'pull_request'
:
case
'push'
:
return
'HEAD~1'
default
:
throw
new
Error
(
`Unsupported GITHUB_EVENT_NAME:
${
eventName
}
`
)
}
}
else
{
try
{
await
exec
(
'git remote set-branches --add origin canary'
)
await
exec
(
'git fetch origin canary --depth=20'
)
}
catch
(
err
)
{
const
remoteInfo
=
await
exec
(
'git remote -v'
)
console
.
error
(
remoteInfo
.
stdout
)
console
.
error
(
remoteInfo
.
stderr
)
console
.
error
(
`Failed to fetch origin/canary`
,
err
)
}
// TODO: We should diff against the merge base with origin/canary not directly against origin/canary.
// A --- B ---- origin/canary
// \
// \-- C ---- HEAD
// `git diff origin/canary` includes B and C
// But we should only include C.
return
'origin/canary'
}
}
module
.
exports
=
{
getDiffRevision
,
getGitInfo
}
scripts/run-for-change.js
View file @
1a808968
const
{
promisify
}
=
require
(
'util'
)
const
{
exec
:
execOrig
,
spawn
}
=
require
(
'child_process'
)
const
{
getDiffRevision
,
getGitInfo
}
=
require
(
'./git-info.js'
)
const
exec
=
promisify
(
execOrig
)
...
...
@@ -55,44 +56,17 @@ const CHANGE_ITEM_GROUPS = {
}
async
function
main
()
{
let
eventData
=
{}
try
{
eventData
=
require
(
process
.
env
.
GITHUB_EVENT_PATH
)[
'pull_request'
]
||
{}
}
catch
(
_
)
{}
const
branchName
=
eventData
?.
head
?.
ref
||
process
.
env
.
GITHUB_REF_NAME
||
(
await
exec
(
'git rev-parse --abbrev-ref HEAD'
)).
stdout
const
remoteUrl
=
eventData
?.
head
?.
repo
?.
full_name
||
process
.
env
.
GITHUB_REPOSITORY
||
(
await
exec
(
'git remote get-url origin'
)).
stdout
const
isCanary
=
branchName
.
trim
()
===
'canary'
&&
remoteUrl
.
includes
(
'vercel/next.js'
)
try
{
await
exec
(
'git remote set-branches --add origin canary'
)
await
exec
(
'git fetch origin canary --depth=20'
)
}
catch
(
err
)
{
console
.
error
(
await
exec
(
'git remote -v'
))
console
.
error
(
`Failed to fetch origin/canary`
,
err
)
}
// if we are on the canary branch only diff current commit
const
toDiff
=
isCanary
?
`
${
process
.
env
.
GITHUB_SHA
||
'canary'
}
~`
:
'origin/canary...'
const
changesResult
=
await
exec
(
`git diff
${
toDiff
}
--name-only`
).
catch
(
(
err
)
=>
{
console
.
error
(
err
)
return
{
stdout
:
''
}
}
)
console
.
error
({
branchName
,
remoteUrl
,
isCanary
,
changesResult
})
const
{
branchName
,
remoteUrl
}
=
await
getGitInfo
()
const
diffRevision
=
await
getDiffRevision
()
const
changesResult
=
await
exec
(
`git diff
${
diffRevision
}
--name-only`
).
catch
((
err
)
=>
{
console
.
error
(
err
)
return
{
stdout
:
''
}
})
console
.
error
({
branchName
,
remoteUrl
,
changesResult
})
const
changedFilesOutput
=
changesResult
.
stdout
const
typeIndex
=
process
.
argv
.
indexOf
(
'--type'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment