mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
252 lines
10 KiB
YAML
252 lines
10 KiB
YAML
name: Issue Labeled
|
|
env:
|
|
BUN_VERSION: 1.1.44
|
|
|
|
on:
|
|
issues:
|
|
types: [labeled]
|
|
pull_request_target:
|
|
types: [labeled, opened, reopened, synchronize, unlabeled]
|
|
|
|
jobs:
|
|
# on-bug:
|
|
# runs-on: ubuntu-latest
|
|
# if: github.event.label.name == 'bug' || github.event.label.name == 'crash'
|
|
# permissions:
|
|
# issues: write
|
|
# steps:
|
|
# - name: Checkout
|
|
# uses: actions/checkout@v4
|
|
# with:
|
|
# sparse-checkout: |
|
|
# scripts
|
|
# .github
|
|
# CMakeLists.txt
|
|
# - name: Setup Bun
|
|
# uses: ./.github/actions/setup-bun
|
|
# with:
|
|
# bun-version: ${{ env.BUN_VERSION }}
|
|
# - name: "categorize bug"
|
|
# id: add-labels
|
|
# env:
|
|
# GITHUB_ISSUE_BODY: ${{ github.event.issue.body }}
|
|
# GITHUB_ISSUE_TITLE: ${{ github.event.issue.title }}
|
|
# ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
# shell: bash
|
|
# run: |
|
|
# echo '{"dependencies": { "@anthropic-ai/sdk": "latest" }}' > scripts/package.json && bun install --cwd=./scripts
|
|
# LABELS=$(bun scripts/label-issue.ts)
|
|
# echo "labels=$LABELS" >> $GITHUB_OUTPUT
|
|
# - name: Add labels
|
|
# uses: actions-cool/issues-helper@v3
|
|
# if: steps.add-labels.outputs.labels != ''
|
|
# with:
|
|
# actions: "add-labels"
|
|
# token: ${{ secrets.GITHUB_TOKEN }}
|
|
# issue-number: ${{ github.event.issue.number }}
|
|
# labels: ${{ steps.add-labels.outputs.labels }}
|
|
on-slop:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'slop')
|
|
permissions:
|
|
issues: write
|
|
pull-requests: write
|
|
contents: write
|
|
steps:
|
|
- name: Update PR title and body for slop and close
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const pr = await github.rest.pulls.get({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: context.issue.number
|
|
});
|
|
|
|
await github.rest.pulls.update({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: context.issue.number,
|
|
title: 'ai slop',
|
|
body: 'This PR has been marked as AI slop and the description has been updated to avoid confusion or misleading reviewers.\n\nMany AI PRs are fine, but sometimes they submit a PR too early, fail to test if the problem is real, fail to reproduce the problem, or fail to test that the problem is fixed. If you think this PR is not AI slop, please leave a comment.',
|
|
state: 'closed'
|
|
});
|
|
|
|
// Delete the branch if it's from a fork or if it's not a protected branch
|
|
try {
|
|
await github.rest.git.deleteRef({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
ref: `heads/${pr.data.head.ref}`
|
|
});
|
|
} catch (error) {
|
|
console.log('Could not delete branch:', error.message);
|
|
}
|
|
on-labeled:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'issues' && (github.event.label.name == 'crash' || github.event.label.name == 'needs repro')
|
|
permissions:
|
|
issues: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
sparse-checkout: |
|
|
scripts
|
|
.github
|
|
CMakeLists.txt
|
|
- name: Setup Bun
|
|
uses: ./.github/actions/setup-bun
|
|
with:
|
|
bun-version: ${{ env.BUN_VERSION }}
|
|
- name: "add platform and command label"
|
|
id: add-labels
|
|
if: github.event.label.name == 'crash'
|
|
env:
|
|
GITHUB_ISSUE_BODY: ${{ github.event.issue.body }}
|
|
GITHUB_ISSUE_TITLE: ${{ github.event.issue.title }}
|
|
GITHUB_ISSUE_NUMBER: ${{ github.event.issue.number }}
|
|
shell: bash
|
|
run: |
|
|
LABELS=$(bun scripts/read-issue.ts)
|
|
bun scripts/is-outdated.ts
|
|
|
|
# Check for patterns that should close the issue
|
|
CLOSE_ACTION=$(bun scripts/handle-crash-patterns.ts)
|
|
echo "close-action=$CLOSE_ACTION" >> $GITHUB_OUTPUT
|
|
|
|
if [[ -f "is-outdated.txt" ]]; then
|
|
echo "is-outdated=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
if [[ -f "outdated.txt" ]]; then
|
|
echo "outdated=$(cat outdated.txt)" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
if [[ -f "is-very-outdated.txt" ]]; then
|
|
echo "is-very-outdated=true" >> $GITHUB_OUTPUT
|
|
LABELS="$LABELS,old-version"
|
|
else
|
|
echo "is-very-outdated=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
echo "latest=$(cat LATEST)" >> $GITHUB_OUTPUT
|
|
echo "labels=$LABELS" >> $GITHUB_OUTPUT
|
|
rm -rf is-outdated.txt outdated.txt latest.txt is-very-outdated.txt
|
|
- name: Close issue if pattern detected
|
|
if: github.event.label.name == 'crash' && fromJson(steps.add-labels.outputs.close-action).close == true
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const closeAction = JSON.parse('${{ steps.add-labels.outputs.close-action }}');
|
|
|
|
// Comment with the reason
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
body: closeAction.comment
|
|
});
|
|
|
|
// Close the issue
|
|
await github.rest.issues.update({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
state: 'closed',
|
|
state_reason: closeAction.reason
|
|
});
|
|
- name: Generate comment text with Sentry Link
|
|
if: github.event.label.name == 'crash' && fromJson(steps.add-labels.outputs.close-action).close != true
|
|
# ignore if fail
|
|
continue-on-error: true
|
|
id: generate-comment-text
|
|
env:
|
|
GITHUB_ISSUE_BODY: ${{ github.event.issue.body }}
|
|
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_EVENTS_SECRET }}
|
|
shell: bash
|
|
run: |
|
|
bun scripts/associate-issue-with-sentry.ts
|
|
|
|
if [[ -f "sentry-link.txt" ]]; then
|
|
echo "sentry-link=$(cat sentry-link.txt)" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
if [[ -f "sentry-id.txt" ]]; then
|
|
echo "sentry-id=$(cat sentry-id.txt)" >> $GITHUB_OUTPUT
|
|
fi
|
|
- name: Remove old labels
|
|
uses: actions-cool/issues-helper@v3
|
|
if: github.event.label.name == 'crash' && steps.add-labels.outputs.is-very-outdated == 'false'
|
|
with:
|
|
actions: "remove-labels"
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
issue-number: ${{ github.event.issue.number }}
|
|
labels: old-version
|
|
- name: Add labels
|
|
uses: actions-cool/issues-helper@v3
|
|
if: github.event.label.name == 'crash'
|
|
with:
|
|
actions: "add-labels"
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
issue-number: ${{ github.event.issue.number }}
|
|
labels: ${{ steps.add-labels.outputs.labels }}
|
|
- name: Comment outdated
|
|
if: steps.add-labels.outputs.is-outdated == 'true' && github.event.label.name == 'crash' && steps.generate-comment-text.outputs.sentry-link == ''
|
|
uses: actions-cool/issues-helper@v3
|
|
with:
|
|
actions: "create-comment"
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
issue-number: ${{ github.event.issue.number }}
|
|
body: |
|
|
@${{ github.event.issue.user.login }}, the latest version of Bun is v${{ steps.add-labels.outputs.latest }}, but this crash was reported on Bun v${{ steps.add-labels.outputs.outdated }}.
|
|
|
|
Are you able to reproduce this crash on the latest version of Bun?
|
|
|
|
```sh
|
|
bun upgrade
|
|
```
|
|
- name: Comment with Sentry Link and outdated version
|
|
if: steps.generate-comment-text.outputs.sentry-link != '' && github.event.label.name == 'crash' && steps.add-labels.outputs.is-outdated == 'true'
|
|
uses: actions-cool/issues-helper@v3
|
|
with:
|
|
actions: "create-comment"
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
issue-number: ${{ github.event.issue.number }}
|
|
body: |
|
|
@${{ github.event.issue.user.login }}, thank you for reporting this crash. The latest version of Bun is v${{ steps.add-labels.outputs.latest }}, but this crash was reported on Bun v${{ steps.add-labels.outputs.outdated }}.
|
|
|
|
Are you able to reproduce this crash on the latest version of Bun?
|
|
|
|
```sh
|
|
bun upgrade
|
|
```
|
|
|
|
For Bun's internal tracking, this issue is [${{ steps.generate-comment-text.outputs.sentry-id }}](${{ steps.generate-comment-text.outputs.sentry-link }}).
|
|
|
|
<!-- sentry-id: ${{ steps.generate-comment-text.outputs.sentry-id }} -->
|
|
<!-- sentry-link: ${{ steps.generate-comment-text.outputs.sentry-link }} -->
|
|
- name: Comment with Sentry Link
|
|
if: steps.generate-comment-text.outputs.sentry-link != '' && github.event.label.name == 'crash' && steps.add-labels.outputs.is-outdated != 'true'
|
|
uses: actions-cool/issues-helper@v3
|
|
with:
|
|
actions: "create-comment"
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
issue-number: ${{ github.event.issue.number }}
|
|
body: |
|
|
Thank you for reporting this crash.
|
|
|
|
For Bun's internal tracking, this issue is [${{ steps.generate-comment-text.outputs.sentry-id }}](${{ steps.generate-comment-text.outputs.sentry-link }}).
|
|
|
|
<!-- sentry-id: ${{ steps.generate-comment-text.outputs.sentry-id }} -->
|
|
<!-- sentry-link: ${{ steps.generate-comment-text.outputs.sentry-link }} -->
|
|
- name: Comment needs repro
|
|
if: github.event.label.name == 'needs repro'
|
|
uses: actions-cool/issues-helper@v3
|
|
with:
|
|
actions: "create-comment"
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
issue-number: ${{ github.event.issue.number }}
|
|
body: |
|
|
Hello @${{ github.event.issue.user.login }}. Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository, [Replit](https://replit.com/@replit/Bun), [CodeSandbox](https://codesandbox.io/templates/bun), or provide a bulleted list of commands to run that reproduce this issue. Issues marked with `needs repro` will be closed if they have no activity within 3 days.
|