Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ 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
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/retest-konflux-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -82,6 +82,14 @@ jobs:
RETEST_COMMAND: ${{ inputs.retest_command }}
run: |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remembered one more thing. I believe, default shell flags in GHA aren't exactly
set -euo pipefail. I suggest set them explicitly in each step here so the behavior meets what we usually expect from shell scripts.

Suggested change
run: |
run: |
set -euo pipefail

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
Comment on lines +88 to +89
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why gh api, can't something like this work?
$ gh pr view --json labels --jq '.labels[].name' https://github.com/stackrox/stackrox/pull/18943
  1. Please use quoting around command substitution:
    VAR=$(command) - wrong
    VAR="$(command)" - better

  2. There's probably no need to define a variable to use it once.
    Instead of

CURRENT_LABELS="$(gh ...)"
if echo "$CURRENT_LABELS" | grep ...; then

you can write

if gh ... | grep ...; then

echo "Skipping retest: disable-konflux-auto-retest label is present"
exit 0
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like a new implementation that you landed 20 hours ago (according to GitHub). When I look at last comments/updates in https://github.com/stackrox/test-gh-actions/pull/240, they are from 2 days ago (according to GitHub).

Would you like to test the change?


# Check if the check name ends with the configured suffix
if [[ ! "$CHECK_NAME" == *"$CHECK_NAME_SUFFIX" ]]; then
Expand Down