From 16cbe509c75995d4f4ab6c8cf28e58a6c6af7656 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 4 Aug 2026 11:48:22 +0200 Subject: [PATCH] tools: add fallback cleanup job for CQ In case of cancellation (e.g. timeout) occuring while the CQ was dealing with a PR, we likely want the PR back into the queue. Signed-off-by: Antoine du Hamel --- .github/workflows/commit-queue.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/commit-queue.yml b/.github/workflows/commit-queue.yml index 7af712268711..b189e6fa9f49 100644 --- a/.github/workflows/commit-queue.yml +++ b/.github/workflows/commit-queue.yml @@ -97,3 +97,23 @@ jobs: run: ./tools/actions/commit-queue.sh "${GITHUB_REPOSITORY_OWNER}" "${REPOSITORY}" ${{ needs.get_mergeable_prs.outputs.numbers }} env: GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }} + cleanup: + needs: [get_mergeable_prs, commitQueue] + if: cancelled() && needs.get_mergeable_prs.outputs.numbers != '' + runs-on: ubuntu-slim + permissions: + pull-requests: write + steps: + - name: Re-add labels if needed + # If a PR was in the queue, is still open and has neither `commit-queue` + # nor `commit-queue-failed`, we assume it needs to get back into the queue. + run: | + for pr in $PRs; do + gh pr view --repo "$GITHUB_REPOSITORY" "$pr" \ + --json state,labels \ + --jq 'if .state == "OPEN" and all(.labels[]; .name != "commit-queue" and .name != "commit-queue-failed") then halt_error end' \ + || gh pr edit --repo "$GITHUB_REPOSITORY" "$pr" --add-label commit-queue + done + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PRs: ${{ needs.get_mergeable_prs.outputs.numbers }}