Unverified Commit e9383664 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

chore: cleanup unused workflows (#81391)

Cleans up unused workflows & scripts

- bankrupt workflow is superseded by the [stale
workflow](https://github.com/vercel/next.js/blob/canary/.github/workflows/issue_stale.yml)
- filtering issues by version hasn't been used in 9 months and can be
accomplished with a GH search
- the AI triaging tool has largely been more noise than signal. the
existing alerts that have been surfaced in the triage channel have been
sufficient
parent 7bcd46a9
...@@ -18,43 +18,3 @@ export function ninetyDaysAgo() { ...@@ -18,43 +18,3 @@ export function ninetyDaysAgo() {
date.setDate(date.getDate() - 90) date.setDate(date.getDate() - 90)
return date.toISOString().split('T')[0] return date.toISOString().split('T')[0]
} }
export async function getLatestCanaryVersion() {
let latestCanaryVersion
try {
const { stdout } = await getExecOutput('pnpm', [
'view',
'next',
'dist-tags',
'--json',
])
const distTags = JSON.parse(stdout)
latestCanaryVersion = distTags.canary || null
} catch (error) {
setFailed(`Error fetching latest Next.js canary version, skipping update.`)
}
return latestCanaryVersion
}
export async function getLatestVersion() {
let latestVersion
try {
const { stdout } = await getExecOutput('pnpm', [
'view',
'next',
'dist-tags',
'--json',
])
const distTags = JSON.parse(stdout)
latestVersion = distTags.latest || null
} catch (error) {
setFailed(`Error fetching latest Next.js version, skipping update.`)
}
return latestVersion
}
...@@ -2,12 +2,9 @@ ...@@ -2,12 +2,9 @@
"private": true, "private": true,
"description": "A variety of functions to help with triaging issues, PRs, and feature requests in the Next.js repo.", "description": "A variety of functions to help with triaging issues, PRs, and feature requests in the Next.js repo.",
"scripts": { "scripts": {
"build-issues-by-version": "ncc build src/issues-by-version.ts -m -o dist/issues-by-version --license licenses.txt",
"build-issues": "ncc build src/popular-issues.mjs -m -o dist/issues --license licenses.txt", "build-issues": "ncc build src/popular-issues.mjs -m -o dist/issues --license licenses.txt",
"build-prs": "ncc build src/popular-prs.ts -m -o dist/prs --license licenses.txt", "build-prs": "ncc build src/popular-prs.ts -m -o dist/prs --license licenses.txt",
"build-feature-requests": "ncc build src/popular-feature-requests.mjs -m -o dist/feature-requests --license licenses.txt", "build-feature-requests": "ncc build src/popular-feature-requests.mjs -m -o dist/feature-requests --license licenses.txt",
"build-bankrupt-issues": "ncc build src/bankrupt-issues.ts -m -o dist/bankrupt --license licenses.txt",
"build-triage-issues-with-ai": "ncc build src/triage-issues-with-ai.ts -m -o dist/triage-issues-with-ai --license licenses.txt",
"build-wrong-issue-template": "ncc build src/wrong-issue-template.ts -m -o dist/wrong-issue-template --license licenses.txt" "build-wrong-issue-template": "ncc build src/wrong-issue-template.ts -m -o dist/wrong-issue-template --license licenses.txt"
}, },
"dependencies": { "dependencies": {
......
import { info, setFailed } from '@actions/core'
import { context, getOctokit } from '@actions/github'
import { WebClient } from '@slack/web-api'
import { BlockCollection, Section } from 'slack-block-builder'
type Issue = { title: string; number: number; url: string }
async function main() {
if (!process.env.GITHUB_TOKEN) throw new TypeError('GITHUB_TOKEN not set')
if (!process.env.CREATED) throw new TypeError('CREATED not set')
if (!process.env.SLACK_TOKEN) throw new TypeError('SLACK_TOKEN not set')
const octokit = getOctokit(process.env.GITHUB_TOKEN)
const slackClient = new WebClient(process.env.SLACK_TOKEN)
const { runId } = context
const { owner, repo } = context.repo
const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}`
const createdQuery = process.env.CREATED
const dateRange = createdQuery.split('..').join(' to ')
const body = `
We are in the process of closing issues dating from **${dateRange}** to improve our focus on the most relevant and actionable problems.
**_Why are we doing this?_**
Stale issues often lack recent updates and clear reproductions, making them difficult to address effectively. Our objective is to prioritize the most upvoted and actionable issues that have up-to-date reproductions, enabling us to resolve bugs more efficiently.
**_Why these issues?_**
Issues dating from **${dateRange}** are likely to be outdated and less relevant to the current state of the codebase. By closing these older stale issues, we can better focus our efforts on more recent and relevant problems, ensuring a more effective and streamlined workflow.
If your issue is still relevant, please reopen it using our [bug report template](https://github.com/vercel/next.js/issues/new?assignees=&labels=bug&projects=&template=1.bug_report.yml). Be sure to include any important context from the original issue in your new report.
Thank you for your understanding and contributions.
Best regards,
The Next.js Team
`
const issues: Issue[] = []
try {
const { data } = await octokit.rest.search.issuesAndPullRequests({
q: `repo:${owner}/${repo} is:issue is:open created:${createdQuery}`,
})
data.items.forEach((issue) =>
issues.push({ title: issue.title, number: issue.number, url: issue.url })
)
info(`issues = ${JSON.stringify(issues)}`)
info(`${issues.length} issues found! Attempting to close these issues...`)
issues.forEach(async (issue) => {
// assign the issue to samcx
await octokit.rest.issues.addAssignees({
owner,
repo,
issue_number: issue.number,
assignees: ['samcx'],
})
// add a comment
await octokit.rest.issues.createComment({
owner,
repo,
issue_number: issue.number,
body,
})
// close the issue
await octokit.rest.issues.update({
owner,
repo,
issue_number: issue.number,
state: 'closed',
})
})
info(`Those ${issues.length} issues have been successfully closed.`)
const blocks = BlockCollection([
Section({
text: `We just bankrupted *${issues.length}* issues from ${dateRange}.\n_Note: This :github2: <https://github.com/vercel/next.js/actions/workflows/issue_bankrupt.yml|workflow> is ran manually with an inputed created query. To see which issues were closed, check the latest <${runUrl}|workflow run>._`,
}),
])
await slackClient.chat.postMessage({
blocks,
channel: '#coord-next-triage',
icon_emoji: ':github:',
username: 'GitHub Notifier',
})
} catch (error) {
setFailed(error)
}
}
main()
import { info, setFailed } from '@actions/core'
import { context, getOctokit } from '@actions/github'
import { WebClient } from '@slack/web-api'
import { BlockCollection, Divider, Section } from 'slack-block-builder'
async function main() {
if (!process.env.GITHUB_TOKEN) throw new TypeError('GITHUB_TOKEN not set')
if (!process.env.SLACK_TOKEN) throw new TypeError('SLACK_TOKEN not set')
if (!process.env.VERSION) throw new TypeError('VERSION not set')
const octokit = getOctokit(process.env.GITHUB_TOKEN)
const slackClient = new WebClient(process.env.SLACK_TOKEN)
const { owner, repo } = context.repo
const version = process.env.VERSION
try {
const { data: issues } = await octokit.rest.search.issuesAndPullRequests({
order: 'desc',
per_page: 25,
q: `repo:${owner}/${repo} is:issue is:open`,
})
const filteredIssues = issues.items.filter(
(issue) => issue.body && issue.body.includes(`${version}`)
)
if (filteredIssues.length > 0) {
const blocks = BlockCollection([
Section({
text: `*A list of the most recently created, open issues that are on v${version}.*\n_Note: This :github2: <https://github.com/vercel/next.js/blob/canary/.github/workflows/issue_version.yml|workflow> queries the 50 most recent issues, then filters them to only include issues that mention v${version}._`,
}),
Divider(),
Section({
text: filteredIssues
.map(
(issue, i) =>
`${i + 1}. <${issue.html_url}|#${issue.number}>: ${issue.title}`
)
.join('\n'),
}),
])
await slackClient.chat.postMessage({
blocks,
channel: '#next-info',
icon_emoji: ':github:',
username: 'GitHub Notifier',
})
info(`Posted to Slack!`)
} else {
info(`No issues found for ${version}.`)
}
} catch (error) {
setFailed(error)
}
}
main()
import { WebClient } from '@slack/web-api'
import { info, setFailed } from '@actions/core'
import { context } from '@actions/github'
import { generateObject } from 'ai'
import { openai } from '@ai-sdk/openai'
import { z } from 'zod'
import { BlockCollection, Divider, Section } from 'slack-block-builder'
import { getLatestCanaryVersion, getLatestVersion } from '../lib/util.mjs'
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
let latestVersion: string
let latestCanaryVersion: 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 {
object: { explanation, isSevere, number, title, html_url },
} = await generateObject({
model: openai(model),
schema: z.object({
explanation: z.string().describe('The explanation of the severity.'),
isSevere: z.boolean().describe('Whether the issue is severe.'),
number: z.number().describe('The issue number.'),
title: z.string().describe('The issue title.'),
html_url: z.string().describe('The issue html URL.'),
}),
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 to Slack the explanation 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 (isSevere) {
const blocks = BlockCollection([
Section({
text: `:github2: <${html_url}|#${number}>: ${title}\n_Note: This issue was evaluated and reported on Slack with *${model}*._`,
}),
Divider(),
Section({
text: `_${explanation}_`,
}),
])
await slackClient.chat.postMessage({
blocks,
channel,
icon_emoji: ':github:',
username: 'GitHub Notifier',
})
info('Reported to Slack!')
}
// the ai will also provide a reason why the issue was not severe enough to report on slack
info(
`Explanation: ${explanation}\nhtml_url: ${html_url}\nnumber: ${number}\ntitle: ${title}`
)
} catch (error) {
setFailed(error)
}
}
main()
name: 'Bankrupt issues'
on:
workflow_dispatch:
inputs:
created:
description: 'created date range'
required: true
type: string
jobs:
bankrupt:
if: github.repository_owner == 'vercel'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: 'Bankrupt issues & send notification to Slack'
run: node ./.github/actions/next-repo-actions/dist/bankrupt/index.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
CREATED: ${{ github.event.inputs.created }}
name: 'Fetch Issues by Version'
on:
workflow_dispatch:
inputs:
version:
description: 'Next.js Version'
required: true
type: string
jobs:
fetch_issues:
if: github.repository_owner == 'vercel'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: 'Fetch issues & send notification to Slack'
run: node ./.github/actions/next-repo-actions/dist/issues-by-version/index.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
VERSION: ${{ github.event.inputs.version }}
name: Triage Issues with AI
on:
issues:
types: [opened]
jobs:
triage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Setup corepack
run: |
npm i -g corepack@0.31
corepack enable
- name: 'Send report to Slack (AI-powered)'
run: node ./.github/actions/next-repo-actions/dist/triage-issues-with-ai/index.js
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
VERCEL_PROTECTION_BYPASS: ${{ secrets.VERCEL_PROTECTION_BYPASS }}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment