Skip to content

fix: Check status by SHA in wait check#2459

Merged
chmouel merged 3 commits intotektoncd:mainfrom
chmouel:fix-check-status-by-sha-in-wait-check
Feb 10, 2026
Merged

fix: Check status by SHA in wait check#2459
chmouel merged 3 commits intotektoncd:mainfrom
chmouel:fix-check-status-by-sha-in-wait-check

Conversation

@chmouel
Copy link
Copy Markdown
Member

@chmouel chmouel commented Feb 9, 2026

📝 Description of the Change

Fix SHA matching in test wait/check utilities to avoid incorrect assertions when multiple repository statuses exist.

test/pkg/wait/check.go:

  • When a SHA is provided in Succeeded(), find the matching status entry by iterating backwards instead of blindly using the last status. This prevents false failures when multiple statuses exist with different SHAs.
  • Add an assertion that repository status is non-empty before accessing it.
  • On SHA mismatch, report all available SHAs in the error message to aid debugging.

test/pkg/wait/wait.go:

  • In UntilRepositoryUpdated(), when TargetSHA is set, count only the status entries matching that specific SHA rather than just checking total status count. This ensures we wait for the correct SHA's status to appear.

👨🏻‍ Linked Jira

🔗 Linked GitHub Issue

Fixes #

🚀 Type of Change

  • 🐛 Bug fix (fix:)
  • ✨ New feature (feat:)
  • 💥 Breaking change (feat!:, fix!:)
  • 📚 Documentation update (docs:)
  • ⚙️ Chore (chore:)
  • 💅 Refactor (refactor:)
  • 🔧 Enhancement (enhance:)
  • 📦 Dependency update (deps:)

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

If you have used AI assistance, please provide the following details:

Which LLM was used?

  • GitHub Copilot
  • ChatGPT (OpenAI)
  • Claude (Anthropic)
  • Cursor
  • Gemini (Google)
  • Other: ____________

Extent of AI Assistance:

  • Documentation and research only
  • Unit tests or E2E tests only
  • Code generation (parts of the code)
  • Full code generation (most of the PR)
  • PR description and comments
  • Commit message(s)

Important

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com

**💡You can use the script ./hack/add-llm-coauthor.sh to automatically add
these co-author trailers to your commits.

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

Added logic to find the correct status by SHA when checking for a
succeeded condition. Previously, it always used the last status, which
could lead to incorrect assertions if multiple statuses existed with
different SHAs. This change ensures the check is performed against the
status corresponding to the provided SHA.
Copilot AI review requested due to automatic review settings February 9, 2026 20:53
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @chmouel, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a potential issue in status checking logic where the system might incorrectly assert against the latest status instead of the one corresponding to a specific commit SHA. By introducing logic to explicitly search for and utilize the status associated with a given SHA, the changes enhance the reliability and accuracy of status condition evaluations, particularly in scenarios involving multiple status updates for different commits.

Highlights

  • Accurate Status Checking: The Succeeded function now correctly identifies the relevant repository status by iterating through available statuses and matching against a provided SHA, preventing erroneous checks when multiple statuses exist.
  • Enhanced Wait Condition: The UntilRepositoryUpdated function has been improved to specifically wait for a status associated with a TargetSHA, ensuring that the waiting mechanism is more precise and robust.
Changelog
  • test/pkg/wait/check.go
    • Modified the Succeeded function to include a loop that searches for a repository status matching the provided sopt.SHA.
    • Ensured that if sopt.SHA is specified, the assertion is made against the status corresponding to that SHA, rather than just the last status in the list.
  • test/pkg/wait/wait.go
    • Added a conditional block within UntilRepositoryUpdated to check if a status for opts.TargetSHA exists.
    • If opts.TargetSHA is provided and no matching status is found, the wait condition will return false to continue polling until the specific SHA's status appears.
Activity
  • Pull request opened by chmouel.
  • No human activity (comments, reviews) detected yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@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 fixes a bug where the wrong status was being checked by always using the last one. The changes ensure that when a SHA is provided, the corresponding status is found and used. My review focuses on improving the robustness of the test code. The suggested improvement in test/pkg/wait/check.go to fail fast if the status for a given SHA is not found will make test failures clearer. The changes in test/pkg/wait/wait.go look correct and ensure the polling logic waits for the specific SHA to appear.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves the E2E wait/assert helpers to select the repository run status that matches a provided commit SHA, avoiding incorrect assertions when repo.Status contains entries for multiple SHAs.

Changes:

  • Update Succeeded() check to search repo.Status for the most recent entry matching sopt.SHA.
  • Update UntilRepositoryUpdated() to wait until a status entry for TargetSHA appears (in addition to the existing min-status wait).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
test/pkg/wait/wait.go Adds TargetSHA-aware gating in the repository-status wait loop.
test/pkg/wait/check.go Selects the status entry to assert on by matching SHA instead of always using the last status.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Improved the logic for checking repository status by SHA. Previously, it
only checked if any status entry contained the target SHA. Now, it
verifies that a specific number of status entries match the target SHA,
providing a more robust check. Additionally, it was enhanced to report
all available SHAs if a matching SHA is not found, aiding in debugging.
This change ensures that tests accurately reflect the expected status
updates for a given commit.

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
@chmouel chmouel force-pushed the fix-check-status-by-sha-in-wait-check branch from 09e6919 to ceb3911 Compare February 9, 2026 21:37
Added retry logic to the repository URL renaming process during
teardown. This addresses potential conflicts arising from optimistic
locking when the repository's resource version changes between listing
and updating, ensuring the teardown completes reliably.
@chmouel chmouel merged commit 9b81c6c into tektoncd:main Feb 10, 2026
28 of 30 checks passed
@chmouel chmouel deleted the fix-check-status-by-sha-in-wait-check branch February 10, 2026 09:32
@chmouel
Copy link
Copy Markdown
Member Author

chmouel commented Feb 10, 2026

let's give this a try

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants