Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: detect no canary verification #37788

Merged
merged 22 commits into from Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
97 changes: 97 additions & 0 deletions .github/actions/issue-validator/index.js
@@ -0,0 +1,97 @@
// @ts-check
import * as github from '@actions/github'
import * as core from '@actions/core'

const verifyCanaryLabel = 'please verify canary'
const bugReportLabel = 'template: bug'
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
const addReproductionLabel = 'please add a complete reproduction'

async function run() {
try {
const {
payload: { issue, pull_request },
repo,
} = github.context

if (pull_request || !issue?.body) return

const { body, labels, number: issueNumber } = issue

const isManuallyLabeled = labels.some(
(label) => label.name === verifyCanaryLabel
)

const isBugReport = labels.some((label) => label.name === bugReportLabel)

if (!process.env.GITHUB_TOKEN) {
return core.setFailed('GITHUB_TOKEN is not set')
}

// @ts-ignore
const client = github.getOctokit(process.env.GITHUB_TOKEN).rest

/**
* @param {string} label
* @param {string} comment
*/
function notifyOnIssue(label, comment) {
const issueCommon = { ...repo, issue_number: issueNumber }

return Promise.all([
client.issues.addLabels({ ...issueCommon, labels: [label] }),
client.issues.createComment({ ...issueCommon, body: comment }),
])
}

const isVerifyCanaryChecked = body.includes(
'- [X] I verified that the issue exists in Next.js canary release'
)

if (
!isVerifyCanaryChecked || // This can happen if the issue was from a comment in another issue or discussion.
isManuallyLabeled
) {
return await notifyOnIssue(
verifyCanaryLabel,
'Please verify your issue reproduces with `next@canary`. The canary version of Next.js ships daily and includes all features and fixes that have not been released to the stable version yet. Think of canary as a public beta. Some issues may already be fixed in the canary version, so please verify that your issue reproduces by running `npm install next@canary`. If the issue does not reproduce with the canary version, then it has already been fixed and this issue can be closed.'
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
)
}

if (!isBugReport) return

const reproductionUrl = body
.match(/### Link to reproduction\n\n(?<url>.*)\n/)
?.groups?.url.trim()

if (!reproductionUrl || !(await (await fetch(reproductionUrl)).ok)) {
return await notifyOnIssue(
addReproductionLabel,
'The link to the reproduction appears to be incorrect/unreachable. Please add a link to the reproduction of the issue. This is a required field.'
)
}

const reportedNextVersion = body.match(
/Relevant packages:\n next: (?<version>\d+\.\d+\.\d+)/
)?.groups?.version

if (!reportedNextVersion) {
// REVIEW: Should we add a label here?
return
}

const {
data: { tag_name: lastVersion },
} = await client.repos.getLatestRelease(repo)
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved

if (reportedNextVersion !== lastVersion) {
return await notifyOnIssue(
'please verify canary',
'The reported Next.js version did not match the latest `next@canary` version. The canary version of Next.js ships daily and includes all features and fixes that have not been released to the stable version yet. Think of canary as a public beta. Some issues may already be fixed in the canary version, so please verify that your issue reproduces by running `npm install next@canary`. If the issue does not reproduce with the canary version, then it has already been fixed and this issue can be closed.'
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
)
}
} catch (error) {
core.setFailed(error.message)
}
}

run()
12 changes: 12 additions & 0 deletions .github/actions/issue-validator/package.json
@@ -0,0 +1,12 @@
{
"private": true,
"main": "index.js",
"type": "module",
"devDependencies": {
"typescript": "4.6.3"
},
"dependencies": {
"@actions/core": "1.9.0",
"@actions/github": "5.0.3"
}
}
4 changes: 1 addition & 3 deletions .github/actions/next-stats-action/package.json
@@ -1,8 +1,6 @@
{
"name": "get-stats",
"version": "1.0.0",
"private": true,
"main": "src/index.js",
"license": "MIT",
"dependencies": {
"async-sema": "^3.1.0",
"fs-extra": "^8.1.0",
Expand Down
17 changes: 15 additions & 2 deletions .github/workflows/stale.yml
Expand Up @@ -11,12 +11,25 @@ jobs:
if: github.repository_owner == 'vercel'
steps:
- uses: actions/stale@v4
id: stale
id: stale-no-repro
name: 'Close stale issues with no reproduction'
with:
repo-token: ${{ secrets.STALE_TOKEN }}
only-labels: 'please add a complete reproduction'
close-issue-message: 'This issue has been automatically closed because it received no activity for a month and had no reproduction to investigate. If you think this was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.'
close-issue-message: 'This issue has been automatically closed because it received no activity for a month and had no reproduction to investigate. If you think it was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.'
days-before-issue-close: 1
days-before-issue-stale: 30
days-before-pr-close: -1
days-before-pr-stale: -1
exempt-issue-labels: 'blocked,must,should,keep'
operations-per-run: 300 # 1 operation per 100 issues, the rest is to label/comment/close
- uses: actions/stale@v4
id: stale-no-canary
name: 'Close issues not verified on canary'
with:
repo-token: ${{ secrets.STALE_TOKEN }}
only-labels: 'please verify canary'
close-issue-message: "This issue has been automatically closed because it wasn't verified against next@canary. If you think it was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you."
days-before-issue-close: 1
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
days-before-issue-stale: 30
days-before-pr-close: -1
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/validate_issue.yml
@@ -0,0 +1,12 @@
name: Validate issue
on:
issues:
types: [opened, labeled]

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: ./.github/issue-validator
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions contributing.md
Expand Up @@ -327,6 +327,8 @@ Issues are opened with one of these labels:

In case of a bug report, a maintainer looks at the provided reproduction. If the reproduction is missing or insufficient, a `please add a complete reproduction` label is added. If a reproduction is not provided for more than 30 days, the issue becomes stale and will be automatically closed. If a reproduction is provided within 30 days, the `please add a complete reproduction` label is removed and the issue will not become stale anymore.

Bug reports must be verified against the `next@canary` release. The canary version of Next.js ships daily and includes all features and fixes that have not been released to the stable version yet. Think of canary as a public beta. Some issues may already be fixed in the canary version, so please verify that your issue reproduces before opening a new issue. Issues not verified against `next@canary` will be closed after 30 days.

If the issue is specific to the project and not to Next.js itself, it might be converted to a [🎓️ Help discussion](https://github.com/vercel/next.js/discussions/categories/help)

If the bug is verified, it will receive the `kind: bug` label and will be tracked by the maintainers. An `area:` label can be added to indicate which part of Next.js is affected.
Expand Down