Skip to content

Commit

Permalink
Merge branch 'canary' into shu/2985
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding committed Dec 6, 2022
2 parents d0b120c + a19f04c commit 3fe39ec
Show file tree
Hide file tree
Showing 216 changed files with 5,885 additions and 13,388 deletions.
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE/1.bug_report.yml
Expand Up @@ -23,7 +23,7 @@ body:
required: true
- type: dropdown
attributes:
label: Which area of Next.js is affected? (leave empty if unsure)
label: Which area(s) of Next.js are affected? (leave empty if unsure)
multiple: true
options:
- 'App directory (appDir: true)'
Expand All @@ -32,23 +32,23 @@ body:
- 'Dynamic imports (next/dynamic)'
- 'ESLint (eslint-config-next)'
- 'Font optimization (@next/font)'
- 'Internationalzation (i18n)'
- 'Image optmization (next/image, next/legacy/image)'
- 'Head component/file (next/head / head.js)'
- 'Internationalization (i18n)'
- 'Image optimization (next/image, next/legacy/image)'
- 'Jest (next/jest)'
- 'Middleware / Edge (API routes, runtime)'
- 'Package manager (npm, pnpm, Yarn)'
- 'Routing (next/router, next/navigation, next/link)'
- 'Script optimizatzion (next/script)'
- 'Script optimization (next/script)'
- 'Standalone mode (output: "standalone")'
- 'Static HTML Export (next export)'
- 'SWC minifier (swcMinify: true)'
- 'SWC transpilation'
- 'Turbopack (--turbo)'
- 'TypeScript'
- 'Other'
- type: input
attributes:
label: Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
label: Link to the code that reproduces this issue
description: A link to a GitHub repository, a [StackBlitz](https://stackblitz.com/fork/github/vercel/next.js/tree/canary/examples/reproduction-template), or a [CodeSandbox](https://codesandbox.io/s/github/vercel/next.js/tree/canary/examples/reproduction-template) minimal reproduction. Minimal reproductions should be created from our [bug report template with `npx create-next-app -e reproduction-template`](https://github.com/vercel/next.js/tree/canary/examples/reproduction-template) and should include only changes that contribute to the issue.
validations:
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/issue-validator/index.mjs

Large diffs are not rendered by default.

127 changes: 92 additions & 35 deletions .github/actions/issue-validator/src/index.mjs
@@ -1,11 +1,14 @@
// @ts-check
// @ts-expect-error
import * as github from '@actions/github'
// @ts-expect-error
import * as core from '@actions/core'
import { readFileSync } from 'node:fs'
import { join } from 'node:path'

const verifyCanaryLabel = 'please verify canary'
const addReproductionLabel = 'please add a complete reproduction'
// const bugLabel = 'template: bug'
const __dirname =
'/home/runner/work/next.js/next.js/.github/actions/issue-validator'

Expand All @@ -19,59 +22,113 @@ const __dirname =
* color :string
* default :boolean
* }} Label
*
* @typedef {{
* pull_request: any
* issue?: {body: string, number: number, labels: Label[]}
* label: Label
* }} Payload
*
* @typedef {{
* payload: Payload
* repo: any
* }} Context
*/

async function run() {
try {
/** @type {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

/** @type {Label} */
const newLabel = payload.label
const { body, number: issueNumber } = issue
const client = github.getOctokit(process.env.GITHUB_TOKEN).rest
const issueCommon = { ...repo, issue_number: issueNumber }
const labels = issue.labels.map((l) => l.name)
// const isBugReport =
// labels.includes(bugLabel) || newLabel === bugLabel || !labels.length

/** @param {string|null|undefined} link */
async function hasRepro(link) {
if (!link) return false
try {
const url = new URL(link)
if (['example.com'].includes(url.hostname)) {
return false
}
} catch {
return false
}
const response = await fetch(link)
return response.ok
if (
// !(isBugReport && issue.number > 43554) &&
![verifyCanaryLabel, addReproductionLabel].includes(newLabel) &&
!(
labels.includes(verifyCanaryLabel) ||
labels.includes(addReproductionLabel)
)
) {
return core.info(
'Not a bug report or not manually labeled or already labeled.'
)
}

const hasValidRepro = await hasRepro(
body.match(/will be addressed faster\n\n(.*)\n\n### To Reproduce/i)?.[1]
)
// /** @param {string|null|undefined} link */
// async function hasRepro(link) {
// if (!link) return false
// try {
// const url = new URL(link)
// if (['example.com'].includes(url.hostname)) {
// return false
// }
// } catch {
// return false
// }
// const response = await fetch(link)
// return response.ok
// }

// const hasValidRepro =
// 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) {
await client.issues.createComment({
...issueCommon,
body: readFileSync(join(__dirname, 'repro.md'), 'utf8'),
})
if (
newLabel === addReproductionLabel
// || !hasValidRepro
) {
await Promise.all([
client.issues.addLabels({
...issueCommon,
labels: [addReproductionLabel],
}),
client.issues.createComment({
...issueCommon,
body: readFileSync(join(__dirname, 'repro.md'), 'utf8'),
}),
])
return core.info(
'Commented on issue, because it did not have a sufficient reproduction.'
)
}

const isVerifyCanaryChecked = body.match(
/- \[x\] I verified that the issue exists in the latest Next.js canary release/i
)
// const isVerifyCanaryChecked =
// isBugReport &&
// issue.body.match(
// /- \[x\] I verified that the issue exists in the latest Next.js canary release/i
// )

if (!isVerifyCanaryChecked || newLabel.name === verifyCanaryLabel) {
await client.issues.createComment({
...issueCommon,
body: readFileSync(join(__dirname, 'canary.md'), 'utf8'),
})
if (
newLabel === verifyCanaryLabel
// || !isVerifyCanaryChecked
) {
await Promise.all([
client.issues.addLabels({
...issueCommon,
labels: [verifyCanaryLabel],
}),
client.issues.createComment({
...issueCommon,
body: readFileSync(join(__dirname, 'canary.md'), 'utf8'),
}),
])
return core.info(
'Commented on issue, because it was not verified against canary.'
)
Expand Down
64 changes: 64 additions & 0 deletions .github/issue-labeler.yml
@@ -0,0 +1,64 @@
# https://github.com/github/issue-labeler#basic-examples

# Should match the list "Which area(s) of Next.js are affected?" in:
# https://github.com/vercel/next.js/blob/canary/.github/ISSUE_TEMPLATE/1.bug_report.yml
'area: app':
- 'App directory (appDir: true)'
'area: create-next-app':
- 'CLI (create-next-app)'
'area: data fetching':
- 'Data fetching (gS(S)P, getInitialProps)'
'area: next/dynamic':
- 'Dynamic imports (next/dynamic)'
'area: ESLint':
- 'ESLint (eslint-config-next)'
'area: Font Optimization':
- 'Font optimization (@next/font)'
'area: next/head / head.js':
- 'Head component/file (next/head / head.js)'
'area: I18n':
- 'Internationalzation (i18n)'
'area: next/image':
- 'Image optmization (next/image, next/legacy/image)'
'area: Jest':
- 'Jest (next/jest)'
'area: Edge':
- 'Middleware / Edge (API routes, runtime)'
'area: package manager':
- 'Package manager (npm, pnpm, Yarn)'
'area: Routing':
- 'Routing (next/router, next/navigation, next/link)'
'area: next/script':
- 'Script optimizatzion (next/script)'
'area: standalone mode':
- 'Standalone mode (output: "standalone")'
'area: export':
- 'Static HTML Export (next export)'
'area: SWC Minify':
- 'SWC minifier (swcMinify: true)'
'area: SWC transforms':
- 'SWC transpilation'
'area: Turbopack':
- 'Turbopack (--turbo)'
'area: TypeScript':
- 'TypeScript'
# Less used/old/redundant labels
# area: AMP
# area: API routes
# area: Application Code
# area: Codemods
# area: Compiler Performance
# area: Compiler
# area: Concurrent Features
# area: Debugger
# area: Developer Experience
# area: Ecosystem
# area: experimental
# area: Middleware
# area: Reliability
# area: Repository Maintenance
# area: Server Components
# area: Static Generation
# area: styled-jsx
# area: Tracing
# area: URL Imports

0 comments on commit 3fe39ec

Please sign in to comment.