Skip to content

Conversation

@waveywaves
Copy link
Contributor

@waveywaves waveywaves commented Apr 15, 2025

Changes

/retest and /ok-to-test should only restart failed pipelines; the
changes in the PR ensure that we do not match successful pipelineruns
during invocation of these gitops commands. The tests have also been
updated to use /test instead wherever /retest is being used to restart
successful pipelines

fixes #1959
Jira: https://issues.redhat.com/browse/SRVKP-7236

Submitter Checklist

  • 📝 Ensure your commit message is clear and informative. Refer to the How to write a git commit message guide. Include the commit message in the PR body rather than linking to an external site (e.g., Jira ticket).

  • ♽ Run make test lint before submitting a PR to avoid unnecessary CI processing. Consider installing pre-commit and running pre-commit install in the repository root for an efficient workflow.

  • ✨ We use linters to maintain clean and consistent code. Run make lint before submitting a PR. Some linters offer a --fix mode, executable with make fix-linters (ensure markdownlint and golangci-lint are installed).

  • 📖 Document any user-facing features or changes in behavior.

  • 🧪 While 100% coverage isn't required, we encourage unit tests for code changes where possible.

  • 🎁 If feasible, add an end-to-end test. See README for details.

  • 🔎 Address any CI test flakiness before merging, or provide a valid reason to bypass it (e.g., token rate limitations).

  • If adding a provider feature, fill in the following details:

    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

    (update the provider documentation accordingly)

@osp-pac osp-pac added the e2e label Apr 15, 2025
@waveywaves waveywaves force-pushed the execute-non-successful branch 9 times, most recently from fa2a595 to 72e4aca Compare April 16, 2025 14:17
@waveywaves
Copy link
Contributor Author

/cancel

@waveywaves waveywaves force-pushed the execute-non-successful branch 2 times, most recently from 579fd77 to 7508871 Compare April 16, 2025 23:58
@waveywaves waveywaves changed the title fix: filter out already successful pipelineruns fix: /ok-to-test /retest pipelineruns are not created if last sha successful Apr 16, 2025
@waveywaves waveywaves marked this pull request as ready for review April 17, 2025 00:02
Copilot AI review requested due to automatic review settings April 17, 2025 00:02

This comment was marked as outdated.

@waveywaves waveywaves changed the title fix: /ok-to-test /retest pipelineruns are not created if last sha successful fix: /ok-to-test /retest pipelineruns should not be created if last sha successful Apr 17, 2025
@waveywaves
Copy link
Contributor Author

/retest

@waveywaves waveywaves force-pushed the execute-non-successful branch 5 times, most recently from 8f5c0ab to b44e208 Compare April 18, 2025 11:11
@waveywaves
Copy link
Contributor Author

waveywaves commented Apr 18, 2025

cc @chmouel seems like the provider e2e tests are not running :/ wanted to test them, not sure what's up
(none of the e2e tests are, they are being skipped)

@waveywaves
Copy link
Contributor Author

cc @zakisk

@zakisk zakisk added e2e and removed e2e labels Apr 21, 2025
@zakisk
Copy link
Contributor

zakisk commented Apr 21, 2025

cc @chmouel seems like the provider e2e tests are not running :/ wanted to test them, not sure what's up (none of the e2e tests are, they are being skipped)

it may be happening due to changes @chmouel is making.

@zakisk zakisk force-pushed the execute-non-successful branch from 0e2e6b9 to fe278ab Compare August 28, 2025 07:03
@zakisk zakisk force-pushed the execute-non-successful branch from fe278ab to 276c789 Compare September 1, 2025 07:25
@zakisk zakisk added fix gitops and removed e2e labels Sep 3, 2025
@pipelines-as-code pipelines-as-code bot added documentation Improvements or additions to documentation testing labels Sep 3, 2025
@waveywaves waveywaves force-pushed the execute-non-successful branch 4 times, most recently from 559708d to 24ff45d Compare September 11, 2025 14:25
@pipelines-as-code pipelines-as-code bot added the bug Something isn't working label Sep 11, 2025
@waveywaves waveywaves force-pushed the execute-non-successful branch from 24ff45d to be704f9 Compare September 11, 2025 14:46
/retest and /ok-to-test should only restart failed pipelines; the
changes in the PR ensure that we do not match successful pipelineruns
during invocation of these gitops commands. The tests have also been
updated to use /test instead wherever /retest is being used to restart
successful pipelines

Signed-off-by: Vibhav Bobade <[email protected]>
Assisted-by: Claude-4-Sonnet (via Cursor)
@zakisk zakisk force-pushed the execute-non-successful branch from be704f9 to 0dcc517 Compare September 17, 2025 06:54
@chmouel
Copy link
Member

chmouel commented Sep 18, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly implements the logic to prevent /retest and /ok-to-test commands from creating new PipelineRuns if a successful one already exists for the same SHA. The changes to the core logic in pkg/matcher/annotation_matcher.go are sound, and the accompanying documentation updates are clear and comprehensive. The test suite has also been updated to reflect this new behavior, which is great. I have two suggestions: one is to improve the unit testing for the new filtering logic to make it more robust, and the other is to fix a minor typo in a newly introduced constant.

Replace simplified test helper with comprehensive unit tests for the actual
production function. This addresses PR feedback about inadequate test coverage
of the core filtering logic.

Changes:
- Remove checkForExistingSuccessfulPipelineRun helper function
- Remove TestCheckForExistingSuccessfulPipelineRun test
- Add comprehensive TestFilterSuccessfulTemplates covering:
  * Multiple templates with different success/failure states
  * Per-template filtering based on most recent successful runs
  * Event type restrictions (retest/ok-to-test only)
  * Edge cases: empty SHA, different SHA, missing template names
  * All templates filtered resulting in empty list

Coverage improvements:
- filterSuccessfulTemplates function: 84.0% → 92.0%
- Overall matcher package: 87.4% → 87.8%

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Chmouel Boudjnah <[email protected]>
@chmouel
Copy link
Member

chmouel commented Sep 18, 2025

I have tested it and it works nicely chmouel/scratchmyback#377

I have reviewed it and it look fine to me

I have improved the testing in this commit via claude/gemin review and pushed the commit to that pull request

@chmouel
Copy link
Member

chmouel commented Sep 18, 2025

/lgtm

Copy link

@pipelines-as-code pipelines-as-code bot left a comment

Choose a reason for hiding this comment

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

Congrats @waveywaves your PR Has been approved 🎉

✅ Pull Request Approved

Approval Status:

  • Required Approvals: 1
  • Current Approvals: 1

👥 Reviewers Who Approved:

Reviewer Permission Level Approval Status
@chmouel admin

📝 Next Steps

  • Ensure all required checks pass
  • Comply with branch protection rules
  • Request a maintainer to merge using the /merge command (or merge it
    directly if you have repository permission).

Automated by the PAC Boussole 🧭

@waveywaves
Copy link
Contributor Author

/retest

@chmouel
Copy link
Member

chmouel commented Sep 19, 2025

/merge

@pipelines-as-code pipelines-as-code bot merged commit a72246d into openshift-pipelines:main Sep 19, 2025
9 of 10 checks passed
@pipelines-as-code
Copy link

✅ PR Successfully Merged

  • Merge method: rebase
  • Merged by: @chmouel
  • Total approvals: 1/1

Approvals Summary:

Reviewer Permission Status
@chmouel admin

Thank you @waveywaves for your valuable contribution! 🎉

Automated by the PAC Boussole 🧭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation fix gitops testing

Development

Successfully merging this pull request may close these issues.

/ok-to-test re-runs all the pipelines

4 participants