From 5a4d79ccc6932f1d156b4a51cf6596fa5e486cf8 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 4 Feb 2026 16:16:19 +0100 Subject: [PATCH 1/2] Add retest command override and disabling label --- .github/workflows/README.md | 8 ++++-- .github/workflows/retest-konflux-builds.yml | 30 ++++++++++++++------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 25b4598..5c18c29 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -71,13 +71,16 @@ When a Konflux build check fails on a pull request, this action will automatical |-------|-------------|----------|---------| | `max_retries` | Maximum number of retries for failed builds | No | `3` | | `check_name_suffix` | Suffix to filter Konflux build check names (e.g., `-on-push`) | No | `-on-push` | +| `retest_command` | Command to trigger Konflux retest (e.g., /retest). Useful to use non default when OpenShift CI uses the same /retest syntax - prevents OpenShift CI from spamming comments saying it does not understand Konflux-specific retest commands. | No | `/retest` | ## Detailed options -- **Automatic Retesting**: Posts `/retest` commands when Konflux builds fail +- **Automatic Retesting**: Posts retest commands when Konflux builds fail - **Configurable Retry Limit**: Set maximum retry attempts to prevent infinite loops -- **Auto-Cleanup**: Removes old `/retest` comments when new commits are pushed +- **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`) +- **Custom Retest Command**: Configure the command used to trigger retests (default: `/retest`) +- **Disable via Label**: Add the `disable-konflux-auto-retest` label to a PR to skip automatic retesting ### Usage @@ -102,4 +105,5 @@ jobs: with: max_retries: 3 check_name_suffix: '-on-push' + retest_command: '/retest' ``` diff --git a/.github/workflows/retest-konflux-builds.yml b/.github/workflows/retest-konflux-builds.yml index 8bbb70d..5da81f4 100644 --- a/.github/workflows/retest-konflux-builds.yml +++ b/.github/workflows/retest-konflux-builds.yml @@ -1,5 +1,5 @@ # There are two kind of comments in the GitHub pull request: conversation comments and pull request review comments. -# Konflux monitors `/retest` conversation comments for rerunning pipelines. +# Konflux monitors retest conversation comments (configurable, default: `/retest`) for rerunning pipelines. # The conversation comments belong to `/issues/` Github API. name: Retest Failed Konflux Builds @@ -17,10 +17,17 @@ on: required: false type: string default: '-on-push' + retest_command: + description: 'Command to trigger Konflux retest (e.g., /retest). Useful to use non default when OpenShift CI uses the same /retest syntax - prevents OpenShift CI from spamming comments saying it does not understand Konflux-specific retest commands.' + required: false + type: string + default: '/retest' 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: @@ -30,20 +37,21 @@ jobs: issues: write steps: - - name: Remove existing /retest comments as new commits were pushed + - name: Remove existing retests comments env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RETEST_COMMAND: ${{ inputs.retest_command }} run: | PR_NUMBER="${{ github.event.pull_request.number }}" - echo "New commit pushed to PR #$PR_NUMBER. Cleaning up existing /retest comments from GitHub Actions..." + echo "New commit pushed to PR #$PR_NUMBER. Cleaning up existing $RETEST_COMMAND comments from GitHub Actions..." - # Get all comments from github-actions bot containing /retest and ending with CHECK_NAME_SUFFIX + # Get all comments from github-actions bot containing retest command and ending with CHECK_NAME_SUFFIX COMMENT_IDS=$(gh api --paginate "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \ - --jq '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("/retest") and endswith("${{ inputs.check_name_suffix }}"))) | .id') + --jq '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("'"$RETEST_COMMAND"'") and endswith("${{ inputs.check_name_suffix }}"))) | .id') if [ -z "$COMMENT_IDS" ]; then - echo "No /retest comments found to clean up" + echo "No $RETEST_COMMAND comments found to clean up" else # Delete each comment for COMMENT_ID in $COMMENT_IDS; do @@ -58,7 +66,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: @@ -73,6 +82,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MAX_RETRIES: ${{ inputs.max_retries }} CHECK_NAME_SUFFIX: ${{ inputs.check_name_suffix }} + RETEST_COMMAND: ${{ inputs.retest_command }} run: | CHECK_NAME="${{ github.event.check_run.name }}" @@ -88,11 +98,11 @@ jobs: # Count comments containing the retest command (fetches all comments via pagination) RETRY_COUNT="$(gh api --paginate "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \ - --jq '[.[] | select(.body | contains("/retest '"$CHECK_NAME"'"))] | length')" + --jq '[.[] | select(.body | contains("'"$RETEST_COMMAND"' '"$CHECK_NAME"'"))] | length')" if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then echo "::warning::Maximum retry limit ($MAX_RETRIES) reached for $CHECK_NAME on PR #$PR_NUMBER" else echo "Retrying $CHECK_NAME (attempt $((RETRY_COUNT + 1))/$MAX_RETRIES)" - gh pr comment "$PR_NUMBER" --repo ${{ github.repository }} --body "/retest $CHECK_NAME" + gh pr comment "$PR_NUMBER" --repo ${{ github.repository }} --body "$RETEST_COMMAND $CHECK_NAME" fi From fca2e6ff6727c265988aff80c5673c79994851a9 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 4 Feb 2026 19:38:03 +0100 Subject: [PATCH 2/2] drop disabling label --- .github/workflows/README.md | 1 - .github/workflows/retest-konflux-builds.yml | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 5c18c29..0082d06 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -80,7 +80,6 @@ When a Konflux build check fails on a pull request, this action will automatical - **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`) - **Custom Retest Command**: Configure the command used to trigger retests (default: `/retest`) -- **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 5da81f4..a2a67e1 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: