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
c1c33c92
Unverified
Commit
c1c33c92
authored
May 26, 2026
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
May 26, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ci] Reserve comments for stats and tests (#93240)
parent
aa004160
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
12 deletions
+135
-12
pr_ci_comment.yml
.github/workflows/pr_ci_comment.yml
+1
-1
pr-ci-comment.mjs
scripts/pr-ci-comment.mjs
+134
-11
No files found.
.github/workflows/pr_ci_comment.yml
View file @
c1c33c92
...
@@ -3,7 +3,7 @@ name: PR CI Comment
...
@@ -3,7 +3,7 @@ name: PR CI Comment
on
:
on
:
workflow_run
:
workflow_run
:
workflows
:
[
'
build-and-test'
,
'
Generate
Stats'
]
workflows
:
[
'
build-and-test'
,
'
Generate
Stats'
]
types
:
[
completed
]
types
:
[
requested
,
completed
]
permissions
:
permissions
:
actions
:
read
actions
:
read
...
...
scripts/pr-ci-comment.mjs
View file @
c1c33c92
...
@@ -130,11 +130,9 @@ class GitHubClient {
...
@@ -130,11 +130,9 @@ class GitHubClient {
)
)
}
}
async
upsertIssueComment
(
issueNumber
,
marker
,
body
,
fallbackHeadings
=
[])
{
async
findExistingBotComment
(
issueNumber
,
marker
,
fallbackHeadings
=
[])
{
body
=
fitComment
(
body
)
const
comments
=
await
this
.
listIssueComments
(
issueNumber
)
const
comments
=
await
this
.
listIssueComments
(
issueNumber
)
const
existing
=
[...
comments
].
reverse
().
find
((
comment
)
=>
{
return
[...
comments
].
reverse
().
find
((
comment
)
=>
{
if
(
comment
.
user
?.
login
!==
COMMENT_AUTHOR
)
{
if
(
comment
.
user
?.
login
!==
COMMENT_AUTHOR
)
{
return
false
return
false
}
}
...
@@ -144,6 +142,16 @@ class GitHubClient {
...
@@ -144,6 +142,16 @@ class GitHubClient {
fallbackHeadings
.
some
((
heading
)
=>
comment
.
body
?.
includes
(
heading
))
fallbackHeadings
.
some
((
heading
)
=>
comment
.
body
?.
includes
(
heading
))
)
)
})
})
}
async
upsertIssueComment
(
issueNumber
,
marker
,
body
,
fallbackHeadings
=
[])
{
body
=
fitComment
(
body
)
const
existing
=
await
this
.
findExistingBotComment
(
issueNumber
,
marker
,
fallbackHeadings
)
if
(
this
.
dryRun
)
{
if
(
this
.
dryRun
)
{
console
.
log
(
console
.
log
(
...
@@ -182,6 +190,45 @@ class GitHubClient {
...
@@ -182,6 +190,45 @@ class GitHubClient {
console
.
log
(
`Created comment
${
created
.
html_url
}
`
)
console
.
log
(
`Created comment
${
created
.
html_url
}
`
)
}
}
async
insertIssueCommentIfMissing
(
issueNumber
,
marker
,
body
,
fallbackHeadings
=
[]
)
{
body
=
fitComment
(
body
)
const
existing
=
await
this
.
findExistingBotComment
(
issueNumber
,
marker
,
fallbackHeadings
)
if
(
existing
)
{
console
.
log
(
`Existing comment
${
existing
.
html_url
}
found for #
${
issueNumber
}
; requested-phase is create-only, leaving it alone`
)
return
}
if
(
this
.
dryRun
)
{
console
.
log
(
`[dry-run] Would create placeholder comment for #
${
issueNumber
}
`
)
console
.
log
(
body
)
return
}
const
created
=
await
this
.
request
(
`/repos/
${
this
.
owner
}
/
${
this
.
repo
}
/issues/
${
issueNumber
}
/comments`
,
{
method
:
'POST'
,
body
:
JSON
.
stringify
({
body
}),
}
)
console
.
log
(
`Created placeholder comment
${
created
.
html_url
}
`
)
}
async
findPullRequestForCommit
(
sha
)
{
async
findPullRequestForCommit
(
sha
)
{
const
pulls
=
await
this
.
request
(
const
pulls
=
await
this
.
request
(
`/repos/
${
this
.
owner
}
/
${
this
.
repo
}
/commits/
${
sha
}
/pulls`
,
`/repos/
${
this
.
owner
}
/
${
this
.
repo
}
/commits/
${
sha
}
/pulls`
,
...
@@ -244,13 +291,26 @@ async function main() {
...
@@ -244,13 +291,26 @@ async function main() {
return
return
}
}
const
phase
=
event
.
action
if
(
phase
!==
'requested'
&&
phase
!==
'completed'
)
{
console
.
log
(
`Ignoring workflow_run action "
${
phase
}
"`
)
return
}
if
(
workflowRun
.
name
===
'Generate Stats'
)
{
if
(
workflowRun
.
name
===
'Generate Stats'
)
{
await
handleStatsWorkflow
({
github
,
workflowRun
,
pr
})
await
handleStatsWorkflow
({
github
,
workflowRun
,
pr
,
phase
})
return
return
}
}
if
(
workflowRun
.
name
===
'build-and-test'
)
{
if
(
workflowRun
.
name
===
'build-and-test'
)
{
await
handleBuildAndTestWorkflow
({
github
,
workflowRun
,
pr
,
owner
,
repo
})
await
handleBuildAndTestWorkflow
({
github
,
workflowRun
,
pr
,
owner
,
repo
,
phase
,
})
return
return
}
}
...
@@ -398,9 +458,41 @@ async function readPullRequestMetadataArtifact() {
...
@@ -398,9 +458,41 @@ async function readPullRequestMetadataArtifact() {
}
}
}
}
async
function
handleStatsWorkflow
({
github
,
workflowRun
,
pr
})
{
async
function
handleStatsWorkflow
({
github
,
workflowRun
,
pr
,
phase
})
{
if
(
phase
===
'requested'
)
{
const
sha
=
pr
.
headSha
||
workflowRun
.
head_sha
const
body
=
[
STATS_COMMENT_MARKER
,
'## Stats in progress'
,
''
,
`Commit:
${
sha
}
`
,
`[View workflow run](
${
workflowRun
.
html_url
}
)`
,
''
,
].
join
(
'
\
n'
)
await
github
.
insertIssueCommentIfMissing
(
pr
.
number
,
STATS_COMMENT_MARKER
,
body
,
[
'## Stats from current PR'
]
)
return
}
if
(
workflowRun
.
conclusion
===
'cancelled'
)
{
if
(
workflowRun
.
conclusion
===
'cancelled'
)
{
console
.
log
(
'Stats workflow was cancelled, skipping'
)
const
sha
=
pr
.
headSha
||
workflowRun
.
head_sha
const
body
=
[
STATS_COMMENT_MARKER
,
'## Stats cancelled'
,
''
,
`Commit:
${
sha
}
`
,
`[View workflow run](
${
workflowRun
.
html_url
}
)`
,
''
,
].
join
(
'
\
n'
)
await
github
.
upsertIssueComment
(
pr
.
number
,
STATS_COMMENT_MARKER
,
body
,
[
'## Stats from current PR'
,
])
return
return
}
}
...
@@ -439,7 +531,22 @@ async function handleStatsWorkflow({ github, workflowRun, pr }) {
...
@@ -439,7 +531,22 @@ async function handleStatsWorkflow({ github, workflowRun, pr }) {
return
return
}
}
console
.
log
(
'No stats block found in the completed stats workflow'
)
console
.
log
(
'No stats block found in the completed stats workflow. Assuming stats were skipped.'
)
const
sha
=
pr
.
headSha
||
workflowRun
.
head_sha
const
body
=
[
STATS_COMMENT_MARKER
,
'## Stats skipped'
,
''
,
`Commit:
${
sha
}
`
,
`[View workflow run](
${
workflowRun
.
html_url
}
)`
,
''
,
].
join
(
'
\
n'
)
await
github
.
upsertIssueComment
(
pr
.
number
,
STATS_COMMENT_MARKER
,
body
,
[
'## Stats from current PR'
,
])
}
}
async
function
handleBuildAndTestWorkflow
({
async
function
handleBuildAndTestWorkflow
({
...
@@ -448,9 +555,25 @@ async function handleBuildAndTestWorkflow({
...
@@ -448,9 +555,25 @@ async function handleBuildAndTestWorkflow({
pr
,
pr
,
owner
,
owner
,
repo
,
repo
,
phase
,
})
{
})
{
if
(
workflowRun
.
conclusion
===
'cancelled'
)
{
if
(
phase
===
'requested'
)
{
console
.
log
(
'build-and-test was cancelled, skipping'
)
const
sha
=
pr
.
headSha
||
workflowRun
.
head_sha
const
body
=
[
TEST_COMMENT_MARKER
,
'## Tests in progress'
,
''
,
`Commit:
${
sha
}
`
,
`[View workflow run](
${
workflowRun
.
html_url
}
)`
,
''
,
].
join
(
'
\
n'
)
await
github
.
insertIssueCommentIfMissing
(
pr
.
number
,
TEST_COMMENT_MARKER
,
body
,
[
'## Failing test suites'
,
'## Failing CI jobs'
]
)
return
return
}
}
...
...
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