From 18c1f78b479e4dfb04e2a1641336f5a44c691bdd Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 4 Feb 2026 19:32:25 +0100 Subject: [PATCH 1/6] Add disabling label for the konflux retests --- .github/workflows/README.md | 1 + .github/workflows/retest-konflux-builds.yml | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 25b45989..077e2072 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -78,6 +78,7 @@ When a Konflux build check fails on a pull request, this action will automatical - **Configurable Retry Limit**: Set maximum retry attempts to prevent infinite loops - **Auto-Cleanup**: Removes old `/retest` comments when new commits are pushed - **Filtered Checks**: Only retests checks matching a specific name suffix (e.g., `-on-push`) +- **Disable via Label**: Add the `disable-konflux-auto-retest` label to a PR to skip automatic retesting ### Usage diff --git a/.github/workflows/retest-konflux-builds.yml b/.github/workflows/retest-konflux-builds.yml index 8bbb70d3..0f58979e 100644 --- a/.github/workflows/retest-konflux-builds.yml +++ b/.github/workflows/retest-konflux-builds.yml @@ -20,7 +20,9 @@ on: jobs: cleanup-retest-comments: - if: github.event_name == 'pull_request' + if: | + github.event_name == 'pull_request' && + !contains(github.event.pull_request.labels.*.name, 'disable-konflux-auto-retest') runs-on: ubuntu-latest permissions: @@ -58,7 +60,8 @@ jobs: github.event_name == 'check_run' && github.event.check_run.pull_requests[0] != null && github.event.check_run.conclusion == 'failure' && - startsWith(github.event.check_run.name, 'Red Hat Konflux') + startsWith(github.event.check_run.name, 'Red Hat Konflux') && + !contains(github.event.check_run.pull_requests[0].labels.*.name, 'disable-konflux-auto-retest') runs-on: ubuntu-latest permissions: From 5e5158547788c6ff9bca7d72548492ea274eda22 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Tue, 10 Feb 2026 16:08:06 +0100 Subject: [PATCH 2/6] Change the implementation to reading actual labels before posting retest --- .github/workflows/retest-konflux-builds.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/retest-konflux-builds.yml b/.github/workflows/retest-konflux-builds.yml index 5da81f4d..099fbf07 100644 --- a/.github/workflows/retest-konflux-builds.yml +++ b/.github/workflows/retest-konflux-builds.yml @@ -25,9 +25,7 @@ on: jobs: cleanup-retest-comments: - if: | - github.event_name == 'pull_request' && - !contains(github.event.pull_request.labels.*.name, 'disable-konflux-auto-retest') + if: github.event_name == 'pull_request' runs-on: ubuntu-latest permissions: @@ -66,8 +64,7 @@ jobs: github.event_name == 'check_run' && github.event.check_run.pull_requests[0] != null && github.event.check_run.conclusion == 'failure' && - startsWith(github.event.check_run.name, 'Red Hat Konflux') && - !contains(github.event.check_run.pull_requests[0].labels.*.name, 'disable-konflux-auto-retest') + startsWith(github.event.check_run.name, 'Red Hat Konflux') runs-on: ubuntu-latest permissions: @@ -85,6 +82,14 @@ jobs: RETEST_COMMAND: ${{ inputs.retest_command }} run: | CHECK_NAME="${{ github.event.check_run.name }}" + PR_NUMBER="${{ github.event.check_run.pull_requests[0].number }}" + + # Fetch current PR labels to avoid race conditions with stale event data + CURRENT_LABELS=$(gh api "repos/${{ github.repository }}/pulls/$PR_NUMBER" --jq '.labels[].name') + if echo "$CURRENT_LABELS" | grep -q "^disable-konflux-auto-retest$"; then + echo "Skipping retest: disable-konflux-auto-retest label is present" + exit 0 + fi # Check if the check name ends with the configured suffix if [[ ! "$CHECK_NAME" == *"$CHECK_NAME_SUFFIX" ]]; then From c66a250eae913b7236fd7ea792a34841c9bbb9a3 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Tue, 10 Feb 2026 16:25:39 +0100 Subject: [PATCH 3/6] Change null check --- .github/workflows/retest-konflux-builds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/retest-konflux-builds.yml b/.github/workflows/retest-konflux-builds.yml index 099fbf07..54714aea 100644 --- a/.github/workflows/retest-konflux-builds.yml +++ b/.github/workflows/retest-konflux-builds.yml @@ -62,7 +62,7 @@ jobs: auto-retest-failed-konflux-build: if: | github.event_name == 'check_run' && - github.event.check_run.pull_requests[0] != null && + github.event.check_run.pull_requests.length > 0 && github.event.check_run.conclusion == 'failure' && startsWith(github.event.check_run.name, 'Red Hat Konflux') runs-on: ubuntu-latest From 1da536397881b3c64eac32e3fa9c797c62f66e23 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 11 Mar 2026 14:44:37 +0100 Subject: [PATCH 4/6] Update .github/workflows/retest-konflux-builds.yml Co-authored-by: Misha Sugakov <537715+msugakov@users.noreply.github.com> --- .github/workflows/retest-konflux-builds.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/retest-konflux-builds.yml b/.github/workflows/retest-konflux-builds.yml index 54714aea..7f54e534 100644 --- a/.github/workflows/retest-konflux-builds.yml +++ b/.github/workflows/retest-konflux-builds.yml @@ -81,6 +81,7 @@ jobs: CHECK_NAME_SUFFIX: ${{ inputs.check_name_suffix }} RETEST_COMMAND: ${{ inputs.retest_command }} run: | + set -euo pipefail CHECK_NAME="${{ github.event.check_run.name }}" PR_NUMBER="${{ github.event.check_run.pull_requests[0].number }}" From 388116892efd0f1f1b05249c065bb80afa617b86 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 11 Mar 2026 21:05:39 +0100 Subject: [PATCH 5/6] Add quoting around command --- .github/workflows/retest-konflux-builds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/retest-konflux-builds.yml b/.github/workflows/retest-konflux-builds.yml index 7f54e534..4f601f82 100644 --- a/.github/workflows/retest-konflux-builds.yml +++ b/.github/workflows/retest-konflux-builds.yml @@ -86,7 +86,7 @@ jobs: PR_NUMBER="${{ github.event.check_run.pull_requests[0].number }}" # Fetch current PR labels to avoid race conditions with stale event data - CURRENT_LABELS=$(gh api "repos/${{ github.repository }}/pulls/$PR_NUMBER" --jq '.labels[].name') + CURRENT_LABELS="$(gh api "repos/${{ github.repository }}/pulls/$PR_NUMBER" --jq '.labels[].name')" if echo "$CURRENT_LABELS" | grep -q "^disable-konflux-auto-retest$"; then echo "Skipping retest: disable-konflux-auto-retest label is present" exit 0 From 0b16f1bcba96fb38aa005c3be6b5634528d6c066 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Thu, 12 Mar 2026 15:39:41 +0100 Subject: [PATCH 6/6] Review comments --- .github/workflows/retest-konflux-builds.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/retest-konflux-builds.yml b/.github/workflows/retest-konflux-builds.yml index 4f601f82..ae5f687f 100644 --- a/.github/workflows/retest-konflux-builds.yml +++ b/.github/workflows/retest-konflux-builds.yml @@ -40,6 +40,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RETEST_COMMAND: ${{ inputs.retest_command }} run: | + set -euo pipefail PR_NUMBER="${{ github.event.pull_request.number }}" echo "New commit pushed to PR #$PR_NUMBER. Cleaning up existing $RETEST_COMMAND comments from GitHub Actions..." @@ -86,7 +87,7 @@ jobs: PR_NUMBER="${{ github.event.check_run.pull_requests[0].number }}" # Fetch current PR labels to avoid race conditions with stale event data - CURRENT_LABELS="$(gh api "repos/${{ github.repository }}/pulls/$PR_NUMBER" --jq '.labels[].name')" + CURRENT_LABELS="$(gh pr view "$PR_NUMBER" --repo ${{ github.repository }} --json labels --jq '.labels[].name')" if echo "$CURRENT_LABELS" | grep -q "^disable-konflux-auto-retest$"; then echo "Skipping retest: disable-konflux-auto-retest label is present" exit 0