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
5003de7b
Commit
5003de7b
authored
Nov 30, 2022
by
Balázs Orbán
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fix issue verifier issues
parent
cd02e5cf
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
23 deletions
+69
-23
index.mjs
.github/actions/issue-validator/index.mjs
+1
-1
index.mjs
.github/actions/issue-validator/src/index.mjs
+68
-22
No files found.
.github/actions/issue-validator/index.mjs
View file @
5003de7b
This diff is collapsed.
Click to expand it.
.github/actions/issue-validator/src/index.mjs
View file @
5003de7b
// @ts-check
// @ts-check
// @ts-expect-error
import
*
as
github
from
'@actions/github'
import
*
as
github
from
'@actions/github'
// @ts-expect-error
import
*
as
core
from
'@actions/core'
import
*
as
core
from
'@actions/core'
import
{
readFileSync
}
from
'node:fs'
import
{
readFileSync
}
from
'node:fs'
import
{
join
}
from
'node:path'
import
{
join
}
from
'node:path'
const
verifyCanaryLabel
=
'please verify canary'
const
verifyCanaryLabel
=
'please verify canary'
const
addReproductionLabel
=
'please add a complete reproduction'
const
addReproductionLabel
=
'please add a complete reproduction'
const
bugLabel
=
'template: bug'
const
__dirname
=
const
__dirname
=
'/home/runner/work/next.js/next.js/.github/actions/issue-validator'
'/home/runner/work/next.js/next.js/.github/actions/issue-validator'
...
@@ -19,20 +22,42 @@ const __dirname =
...
@@ -19,20 +22,42 @@ const __dirname =
* color :string
* color :string
* default :boolean
* default :boolean
* }} Label
* }} Label
*
* @typedef {{
* labels: Label[]
* pull_request: any
* issue?: {body: string, number: number}
* label: Label
* }} Payload
*
* @typedef {{
* payload: Payload
* repo: any
* }} Context
*/
*/
async
function
run
()
{
async
function
run
()
{
try
{
try
{
/** @type {Context} */
const
{
payload
,
repo
}
=
github
.
context
const
{
payload
,
repo
}
=
github
.
context
const
{
issue
,
pull_request
}
=
payload
const
{
issue
,
pull_request
,
label
:
{
name
:
newLabel
},
}
=
payload
if
(
pull_request
||
!
issue
?.
body
||
!
process
.
env
.
GITHUB_TOKEN
)
return
if
(
pull_request
||
!
issue
?.
body
||
!
process
.
env
.
GITHUB_TOKEN
)
return
/** @type {Label} */
const
labels
=
payload
.
labels
.
map
((
l
)
=>
l
.
name
)
const
newLabel
=
payload
.
label
const
isBugReport
=
const
{
body
,
number
:
issueNumber
}
=
issue
labels
.
includes
(
bugLabel
)
||
newLabel
===
bugLabel
||
!
labels
.
length
const
client
=
github
.
getOctokit
(
process
.
env
.
GITHUB_TOKEN
).
rest
const
issueCommon
=
{
...
repo
,
issue_number
:
issueNumber
}
if
(
!
(
isBugReport
&&
issue
.
number
>
43554
)
&&
!
[
verifyCanaryLabel
,
addReproductionLabel
].
includes
(
newLabel
)
)
{
return
core
.
info
(
'Not a bug report or not manually labeled'
)
}
/** @param {string|null|undefined} link */
/** @param {string|null|undefined} link */
async
function
hasRepro
(
link
)
{
async
function
hasRepro
(
link
)
{
...
@@ -49,29 +74,50 @@ async function run() {
...
@@ -49,29 +74,50 @@ async function run() {
return
response
.
ok
return
response
.
ok
}
}
const
hasValidRepro
=
await
hasRepro
(
const
hasValidRepro
=
body
.
match
(
/will be addressed faster
\n\n(
.*
)\n\n
### To Reproduce/i
)?.[
1
]
isBugReport
&&
)
(
await
hasRepro
(
issue
.
body
.
match
(
/will be addressed faster
\n\n(
.*
)\n\n
### To Reproduce/i
)?.[
1
]
))
const
client
=
github
.
getOctokit
(
process
.
env
.
GITHUB_TOKEN
).
rest
const
issueCommon
=
{
...
repo
,
issue_number
:
issue
.
number
}
if
(
!
hasValidRepro
||
newLabel
.
name
===
addReproductionLabel
)
{
if
(
newLabel
===
addReproductionLabel
||
!
hasValidRepro
)
{
await
client
.
issues
.
createComment
({
await
Promise
.
all
([
client
.
issues
.
addLabels
({
...
issueCommon
,
labels
:
[
addReproductionLabel
],
}),
client
.
issues
.
createComment
({
...
issueCommon
,
...
issueCommon
,
body
:
readFileSync
(
join
(
__dirname
,
'repro.md'
),
'utf8'
),
body
:
readFileSync
(
join
(
__dirname
,
'repro.md'
),
'utf8'
),
})
}),
])
return
core
.
info
(
return
core
.
info
(
'Commented on issue, because it did not have a sufficient reproduction.'
'Commented on issue, because it did not have a sufficient reproduction.'
)
)
}
}
const
isVerifyCanaryChecked
=
body
.
match
(
const
isVerifyCanaryChecked
=
isBugReport
&&
issue
.
body
.
match
(
/-
\[
x
\]
I verified that the issue exists in the latest Next.js canary release/i
/-
\[
x
\]
I verified that the issue exists in the latest Next.js canary release/i
)
)
if
(
!
isVerifyCanaryChecked
||
newLabel
.
name
===
verifyCanaryLabel
)
{
if
(
newLabel
===
verifyCanaryLabel
||
!
isVerifyCanaryChecked
)
{
await
client
.
issues
.
createComment
({
await
Promise
.
all
([
client
.
issues
.
addLabels
({
...
issueCommon
,
labels
:
[
verifyCanaryLabel
],
}),
client
.
issues
.
createComment
({
...
issueCommon
,
...
issueCommon
,
body
:
readFileSync
(
join
(
__dirname
,
'canary.md'
),
'utf8'
),
body
:
readFileSync
(
join
(
__dirname
,
'canary.md'
),
'utf8'
),
})
}),
])
return
core
.
info
(
return
core
.
info
(
'Commented on issue, because it was not verified against canary.'
'Commented on issue, because it was not verified against canary.'
)
)
...
...
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