diff --git a/.github/workflows/amd-ci.yml b/.github/workflows/amd-ci.yml index 98a9619d..8dea36fb 100644 --- a/.github/workflows/amd-ci.yml +++ b/.github/workflows/amd-ci.yml @@ -13,11 +13,14 @@ on: paths: - "src/**" - "test/**" + merge_group: + branches: + - main workflow_dispatch: # Enables manual trigger concurrency: # This causes it to cancel previous in-progress actions on the same PR / branch, - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.merge_group.head_ref || github.ref }} cancel-in-progress: true jobs: diff --git a/.github/workflows/intel-ci.yml b/.github/workflows/intel-ci.yml index 168aa013..b8d8606d 100644 --- a/.github/workflows/intel-ci.yml +++ b/.github/workflows/intel-ci.yml @@ -13,11 +13,14 @@ on: paths: - "src/**" - "test/**" + merge_group: + branches: + - main workflow_dispatch: # Enables manual trigger concurrency: # This causes it to cancel previous in-progress actions on the same PR / branch, - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.merge_group.head_ref || github.ref }} cancel-in-progress: true jobs: diff --git a/.github/workflows/merge-queue-failure.yml b/.github/workflows/merge-queue-failure.yml new file mode 100644 index 00000000..6bf6d0f9 --- /dev/null +++ b/.github/workflows/merge-queue-failure.yml @@ -0,0 +1,78 @@ +name: Merge Queue Failure Handler + +on: + workflow_run: + workflows: ["NVIDIA GPU"] + types: [completed] + branches: [main] + +permissions: + pull-requests: write + issues: write + +jobs: + handle-failure: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.conclusion == 'failure' && + github.event.workflow_run.event == 'merge_group' + + steps: + - name: Extract PR number from merge group + id: extract-pr + uses: actions/github-script@v7 + with: + script: | + const headRef = '${{ github.event.workflow_run.head_branch }}'; + // Merge group branch format: gh-readonly-queue/main/pr-{number}-{sha} + const match = headRef.match(/pr-(\d+)-/); + if (match) { + return match[1]; + } + return null; + result-encoding: string + + - name: Comment on PR + if: steps.extract-pr.outputs.result != 'null' + uses: actions/github-script@v7 + with: + script: | + const prNumber = parseInt('${{ steps.extract-pr.outputs.result }}'); + const workflowName = '${{ github.event.workflow_run.name }}'; + const runUrl = '${{ github.event.workflow_run.html_url }}'; + + // Check if PR exists and is open + try { + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber + }); + + // Add comment about merge queue failure + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + body: `## ⚠️ Merge Queue Failed\n\nThe merge queue validation failed for this PR.\n\n**Failed Workflow:** ${workflowName}\n**Run Details:** ${runUrl}\n\nThe PR has been automatically removed from the merge queue. Please review the test failures and push fixes to re-attempt merging.` + }); + + // If PR was somehow closed, reopen it + if (pr.state === 'closed') { + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber, + state: 'open' + }); + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + body: '🔄 This PR has been automatically reopened after merge queue failure.' + }); + } + } catch (error) { + console.log(`Could not process PR #${prNumber}: ${error.message}`); + } diff --git a/.github/workflows/nvi-ci.yml b/.github/workflows/nvi-ci.yml index b828651e..233c0924 100644 --- a/.github/workflows/nvi-ci.yml +++ b/.github/workflows/nvi-ci.yml @@ -13,10 +13,13 @@ on: paths: - "src/**" - "test/**" + merge_group: + branches: + - main workflow_dispatch: # Enables manual trigger concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.merge_group.head_ref || github.ref }} cancel-in-progress: true jobs: