diff --git a/.github/scripts/pr-triage.sh b/.github/scripts/pr-triage.sh deleted file mode 100755 index aeab6d268d..0000000000 --- a/.github/scripts/pr-triage.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Initialize a comma-separated string to hold PR numbers that need a comment -PRS_NEEDING_COMMENT="" - -# Function to process a single PR -process_pr() { - if [[ -z "${GITHUB_REPOSITORY:-}" ]]; then - echo "â€ŧī¸ Missing \$GITHUB_REPOSITORY - this must be run from GitHub Actions" - return 1 - fi - - if [[ -z "${GITHUB_OUTPUT:-}" ]]; then - echo "â€ŧī¸ Missing \$GITHUB_OUTPUT - this must be run from GitHub Actions" - return 1 - fi - - local PR_NUMBER=$1 - echo "🔄 Processing PR #${PR_NUMBER}" - - # Get closing issue number with error handling - local ISSUE_NUMBER - if ! ISSUE_NUMBER=$(gh pr view "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}" --json closingIssuesReferences -q '.closingIssuesReferences.nodes[0].number' 2>/dev/null); then - echo " âš ī¸ Could not fetch closing issue for PR #${PR_NUMBER}" - fi - - if [[ -z "${ISSUE_NUMBER}" ]]; then - echo "â„šī¸ No linked issue found for PR #${PR_NUMBER} - this is acceptable for independent contributions" - # We no longer require PRs to have linked issues - # Independent valuable contributions are encouraged - else - echo "🔗 Found linked issue #${ISSUE_NUMBER}" - - # Remove status/need-issue label if present (legacy cleanup) - if ! gh pr edit "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}" --remove-label "status/need-issue" 2>/dev/null; then - echo " status/need-issue label not present or could not be removed" - fi - - # Get issue labels - echo "đŸ“Ĩ Fetching labels from issue #${ISSUE_NUMBER}" - local ISSUE_LABELS="" - if ! ISSUE_LABELS=$(gh issue view "${ISSUE_NUMBER}" --repo "${GITHUB_REPOSITORY}" --json labels -q '.labels[].name' 2>/dev/null | tr '\n' ',' | sed 's/,$//' || echo ""); then - echo " âš ī¸ Could not fetch issue #${ISSUE_NUMBER} (may not exist or be in different repo)" - ISSUE_LABELS="" - fi - - # Get PR labels - echo "đŸ“Ĩ Fetching labels from PR #${PR_NUMBER}" - local PR_LABELS="" - if ! PR_LABELS=$(gh pr view "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}" --json labels -q '.labels[].name' 2>/dev/null | tr '\n' ',' | sed 's/,$//' || echo ""); then - echo " âš ī¸ Could not fetch PR labels" - PR_LABELS="" - fi - - echo " Issue labels: ${ISSUE_LABELS}" - echo " PR labels: ${PR_LABELS}" - - # Convert comma-separated strings to arrays - local ISSUE_LABEL_ARRAY PR_LABEL_ARRAY - IFS=',' read -ra ISSUE_LABEL_ARRAY <<< "${ISSUE_LABELS}" - IFS=',' read -ra PR_LABEL_ARRAY <<< "${PR_LABELS}" - - # Find labels to add (on issue but not on PR) - local LABELS_TO_ADD="" - for label in "${ISSUE_LABEL_ARRAY[@]}"; do - if [[ -n "${label}" ]] && [[ " ${PR_LABEL_ARRAY[*]} " != *" ${label} "* ]]; then - if [[ -z "${LABELS_TO_ADD}" ]]; then - LABELS_TO_ADD="${label}" - else - LABELS_TO_ADD="${LABELS_TO_ADD},${label}" - fi - fi - done - - # Find labels to remove (on PR but not on issue) - local LABELS_TO_REMOVE="" - for label in "${PR_LABEL_ARRAY[@]}"; do - if [[ -n "${label}" ]] && [[ " ${ISSUE_LABEL_ARRAY[*]} " != *" ${label} "* ]]; then - # Don't remove status/need-issue since we already handled it (legacy cleanup) - if [[ "${label}" != "status/need-issue" ]]; then - if [[ -z "${LABELS_TO_REMOVE}" ]]; then - LABELS_TO_REMOVE="${label}" - else - LABELS_TO_REMOVE="${LABELS_TO_REMOVE},${label}" - fi - fi - fi - done - - # Apply label changes - if [[ -n "${LABELS_TO_ADD}" ]]; then - echo "➕ Adding labels: ${LABELS_TO_ADD}" - if ! gh pr edit "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}" --add-label "${LABELS_TO_ADD}" 2>/dev/null; then - echo " âš ī¸ Failed to add some labels" - fi - fi - - if [[ -z "${LABELS_TO_ADD}" ]]; then - echo "✅ Labels already synchronized" - fi - echo "needs_comment=false" >> "${GITHUB_OUTPUT}" - fi -} - -# If PR_NUMBER is set, process only that PR -if [[ -n "${PR_NUMBER:-}" ]]; then - if ! process_pr "${PR_NUMBER}"; then - echo "❌ Failed to process PR #${PR_NUMBER}" - exit 1 - fi -else - # Otherwise, get all open PRs and process them - # The script logic will determine which ones need issue linking or label sync - echo "đŸ“Ĩ Getting all open pull requests..." - if ! PR_NUMBERS=$(gh pr list --repo "${GITHUB_REPOSITORY}" --state open --limit 1000 --json number -q '.[].number' 2>/dev/null); then - echo "❌ Failed to fetch PR list" - exit 1 - fi - - if [[ -z "${PR_NUMBERS}" ]]; then - echo "✅ No open PRs found" - else - # Count the number of PRs - PR_COUNT=$(echo "${PR_NUMBERS}" | wc -w | tr -d ' ') - echo "📊 Found ${PR_COUNT} open PRs to process" - - for pr_number in ${PR_NUMBERS}; do - if ! process_pr "${pr_number}"; then - echo "âš ī¸ Failed to process PR #${pr_number}, continuing with next PR..." - continue - fi - done - fi -fi - -# Ensure output is always set, even if empty -if [[ -z "${PRS_NEEDING_COMMENT}" ]]; then - echo "prs_needing_comment=[]" >> "${GITHUB_OUTPUT}" -else - echo "prs_needing_comment=[${PRS_NEEDING_COMMENT}]" >> "${GITHUB_OUTPUT}" -fi - -echo "✅ PR triage completed" diff --git a/.github/workflows/gemini-scheduled-pr-triage.yml b/.github/workflows/gemini-scheduled-pr-triage.yml deleted file mode 100644 index 77119672cf..0000000000 --- a/.github/workflows/gemini-scheduled-pr-triage.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: 'Qwen Scheduled PR Triage 🚀' - -on: - schedule: - - cron: '*/15 * * * *' # Runs every 15 minutes - workflow_dispatch: - -jobs: - audit-prs: - timeout-minutes: 15 - if: |- - ${{ github.repository == 'QwenLM/qwen-code' }} - permissions: - contents: 'read' - id-token: 'write' - issues: 'write' - pull-requests: 'write' - runs-on: 'ubuntu-latest' - outputs: - prs_needing_comment: '${{ steps.run_triage.outputs.prs_needing_comment }}' - steps: - - name: 'Checkout' - uses: 'actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10' # v6.0.3 - - - name: 'Run PR Triage Script' - id: 'run_triage' - env: - GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' - GITHUB_REPOSITORY: '${{ github.repository }}' - run: './.github/scripts/pr-triage.sh' diff --git a/docs/developers/development/issue-and-pr-automation.md b/docs/developers/development/issue-and-pr-automation.md index dff4d377a4..cb075c72f1 100644 --- a/docs/developers/development/issue-and-pr-automation.md +++ b/docs/developers/development/issue-and-pr-automation.md @@ -44,21 +44,7 @@ This workflow ensures that all changes meet our quality standards before they ca - Ensure all CI checks pass. A green checkmark ✅ will appear next to your commit when everything is successful. - If a check fails (a red "X" ❌), click the "Details" link next to the failed check to view the logs, identify the problem, and push a fix. -### 3. Ongoing Triage for Pull Requests: `PR Auditing and Label Sync` - -This workflow runs periodically to ensure all open PRs are correctly linked to issues and have consistent labels. - -- **Workflow File**: `.github/workflows/gemini-scheduled-pr-triage.yml` -- **When it runs**: Every 15 minutes on all open pull requests. -- **What it does**: - - **Checks for a linked issue**: The bot scans your PR description for a keyword that links it to an issue (e.g., `Fixes #123`, `Closes #456`). - - **Adds `status/need-issue`**: If no linked issue is found, the bot will add the `status/need-issue` label to your PR. This is a clear signal that an issue needs to be created and linked. - - **Synchronizes labels**: If an issue _is_ linked, the bot ensures the PR's labels perfectly match the issue's labels. It will add any missing labels and remove any that don't belong, and it will remove the `status/need-issue` label if it was present. -- **What you should do**: - - **Always link your PR to an issue.** This is the most important step. Add a line like `Resolves #` to your PR description. - - This will ensure your PR is correctly categorized and moves through the review process smoothly. - -### 4. Release Automation +### 3. Release Automation This workflow handles the process of packaging and publishing new versions of Qwen Code. diff --git a/scripts/tests/issue-triage-ownership-workflow.test.js b/scripts/tests/issue-triage-ownership-workflow.test.js index 6fcfd0cd47..62681ad0dd 100644 --- a/scripts/tests/issue-triage-ownership-workflow.test.js +++ b/scripts/tests/issue-triage-ownership-workflow.test.js @@ -15,6 +15,7 @@ const issueWorkflow = readFileSync( ); const legacyWorkflows = [ 'check-issue-completeness.yml', + 'gemini-scheduled-pr-triage.yml', 'qwen-automated-issue-triage.yml', 'qwen-scheduled-issue-triage.yml', ]; @@ -52,7 +53,7 @@ describe('issue triage workflow ownership', () => { ); }); - it('removes disabled legacy issue triage workflows', () => { + it('removes disabled legacy triage workflows', () => { for (const file of legacyWorkflows) { expect(existsSync(`${workflowsDir}/${file}`)).toBe(false); }