Skip to content

Commit

Permalink
Merge branch 'canary' into feat-headless-api
Browse files Browse the repository at this point in the history
  • Loading branch information
devjiwonchoi authored Aug 21, 2024
2 parents 51f1102 + cbb6811 commit 60a1272
Show file tree
Hide file tree
Showing 426 changed files with 17,637 additions and 9,533 deletions.
2 changes: 1 addition & 1 deletion .github/.react-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.0.0-rc-187dd6a7-20240806
19.0.0-rc-1eaccd82-20240816
9 changes: 6 additions & 3 deletions .github/ISSUE_TEMPLATE/1.bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ body:
description: |
A link to a **public** [GitHub repository](https://github.com/vercel/next.js/tree/canary/examples/reproduction-template) or a [CodeSandbox](https://codesandbox.io/p/sandbox/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. To report a Pages Router related issue, you can use these templates: [`npx create-next-app -e reproduction-template-pages`](https://github.com/vercel/next.js/tree/canary/examples/reproduction-template-pages) or [CodeSandbox](https://codesandbox.io/p/sandbox/github/vercel/next.js/tree/canary/examples/reproduction-template-pages)
**Skipping this/providing an invalid link will result in the issue being closed**
**Skipping this/providing an invalid link will result in the issue being closed.**
placeholder: 'https://github.com/user/my-minimal-nextjs-issue-reproduction'
validations:
required: true
Expand All @@ -39,8 +39,11 @@ body:
- type: textarea
attributes:
label: Current vs. Expected behavior
description: A clear and concise description of what the bug is, and what you expected to happen.
placeholder: 'Following the steps from the previous section, I expected A to happen, but I observed B instead'
description: |
A clear and concise description of what the bug is (e.g., screenshots, logs, etc.), and what you expected to happen.
**Skipping this/failure to provide complete information of the bug will result in the issue being closed.**
placeholder: 'Following the steps from the previous section, I expected A to happen, but I observed B instead.'
validations:
required: true
- type: textarea
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/next-repo-actions/dist/issues/index.mjs

Large diffs are not rendered by default.

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions .github/actions/next-repo-actions/lib/triage_guidelines.txt

This file was deleted.

9 changes: 8 additions & 1 deletion .github/actions/next-repo-actions/src/popular-issues.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,18 @@ async function run() {

if (data.items.length > 0) {
data.items.forEach(async (item) => {
const labelType = item.labels.some(
(label) => label.name === 'Turbopack'
)
? 'turbopack'
: 'next'
const syncLabel = `linear: ${labelType}`

await octoClient.rest.issues.addLabels({
owner,
repo,
issue_number: item.number,
labels: ['linear: next'],
labels: [syncLabel],
})
})

Expand Down
62 changes: 42 additions & 20 deletions .github/actions/next-repo-actions/src/triage-issues-with-ai.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { WebClient } from '@slack/web-api'
import * as path from 'node:path'
import { readFileSync } from 'node:fs'
import { info, setFailed } from '@actions/core'
import { context } from '@actions/github'
import { generateText, tool } from 'ai'
Expand All @@ -13,47 +11,67 @@ import { issueSchema } from '../lib/types'
async function main() {
if (!process.env.OPENAI_API_KEY) throw new TypeError('OPENAI_API_KEY not set')
if (!process.env.SLACK_TOKEN) throw new TypeError('SLACK_TOKEN not set')
if (!process.env.VERCEL_PROTECTION_BYPASS)
throw new TypeError('VERCEL_PROTECTION_BYPASS not set')

const slackClient = new WebClient(process.env.SLACK_TOKEN)
const model = 'gpt-4o'
const channel = '#next-info'

const issue = context.payload.issue
const filePath = path.join(
process.cwd(),
'.github/actions/next-repo-actions/lib/triage_guidelines.txt'
)
const fileText = readFileSync(filePath, 'utf8')

let latestVersion
let latestCanaryVersion
let latestVersion: string
let latestCanaryVersion: string
let html_url: string
let number: number
let title: string

try {
latestVersion = await getLatestVersion()
latestCanaryVersion = await getLatestCanaryVersion()

const res = await fetch(
'https://next-triage.vercel.sh/api/triage-guidelines',
{
method: 'GET',
headers: {
'x-vercel-protection-bypass': `${process.env.VERCEL_PROTECTION_BYPASS}`,
},
}
)

const guidelines = await res.text()

const result = await generateText({
model: openai(model),
maxAutomaticRoundtrips: 1,
tools: {
report_to_slack: tool({
description: 'Report to Slack if a GitHub issue is severe enough.',
description: 'Report to Slack.',
parameters: issueSchema,
execute: async ({ issue }) => ({
html_url: issue.html_url,
number: issue.number,
title: issue.title,
}),
execute: async ({ issue }) => {
html_url = issue.html_url
number = issue.number
title = issue.title

return { html_url, number, title }
},
}),
},
prompt: `${JSON.stringify(issue)}\n${fileText}\nlatestVersion: ${latestVersion}\nlatestCanaryVersion: ${latestCanaryVersion}\nWith the above GitHub issue (JSON), the triage guidelines for determining whether an issue is severe, and the latest versions of Next.js, can you determine whether the given issue is severe enough to report to Slack? If severe enough, report to Slack with an approximately 300 character summary (don't repeat the triage guidelines while doing so) of why you think it is severe enough to report to Slack. If not severe enough, do not report to Slack.`,
system:
'Your job is to determine the severity of a GitHub issue using the triage guidelines and the latest versions of Next.js. Succinctly explain why you chose the severity, without paraphrasing the triage guidelines. Report this explanation to slack only if the severity is considered severe.',
prompt:
`Here are the triage guidelines: ${guidelines}` +
`Here is the latest version of Next.js: ${latestVersion}` +
`Here is the latest canary version of Next.js: ${latestCanaryVersion}` +
`Here is the GitHub issue: ${JSON.stringify(issue)}`,
})

// the ai determined that the issue was severe enough to report on slack
if (result.roundtrips.length > 1) {
const blocks = BlockCollection([
Section({
text: `:github2: <${result.roundtrips[0].toolResults[0].result.html_url}|#${result.roundtrips[0].toolResults[0].result.number}>: ${result.roundtrips[0].toolResults[0].result.title}\n_Note: This issue was summarized and reported on Slack with the *${model}* model._`,
text: `:github2: <${html_url}|#${number}>: ${title}\n_Note: This issue was evaluated and reported on Slack with *${model}*._`,
}),
Divider(),
Section({
Expand All @@ -67,10 +85,14 @@ async function main() {
icon_emoji: ':github:',
username: 'GitHub Notifier',
})
} else {
// the ai will also provide a reason why the issue was not severe enough to report on slack
info(`${result.text}`)

info('Posted to Slack!')
}

// the ai will also provide a reason why the issue was not severe enough to report on slack
info(
`result.text: ${result.text}\nhtml_url: ${html_url}\nnumber: ${number}\ntitle: ${title}`
)
} catch (error) {
setFailed(error)
}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/triage_with_ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ jobs:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
VERCEL_PROTECTION_BYPASS: ${{ secrets.VERCEL_PROTECTION_BYPASS }}
Loading

0 comments on commit 60a1272

Please sign in to comment.