Skip to content

feat(github): add update comment strategy for GitHub#2481

Merged
theakshaypant merged 3 commits intotektoncd:mainfrom
theakshaypant:SRVKP-10453-github-update-comment-strategy
Feb 23, 2026
Merged

feat(github): add update comment strategy for GitHub#2481
theakshaypant merged 3 commits intotektoncd:mainfrom
theakshaypant:SRVKP-10453-github-update-comment-strategy

Conversation

@theakshaypant
Copy link
Copy Markdown
Member

@theakshaypant theakshaypant commented Feb 16, 2026

📝 Description of the Change

This PR adds an update comment strategy for GitHub pull requests. When thsi comment strategy is used, PAC creates a single comment per PipelineRun and update it with the latest status and commit SHA on re-execution.

Changes:

  • Implementation of the update comment strategy.
  • Documentation for configuring and using this option.
  • E2E tests covering:
    • CEL error replacement
    • Multiple PipelineRuns
    • Regex character handling in comments

👨🏻‍ Linked Jira

https://issues.redhat.com/browse/SRVKP-10453

🔗 Linked GitHub Issue

N/A

🚀 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

@pipelines-as-code
Copy link
Copy Markdown

pipelines-as-code bot commented Feb 16, 2026

🔍 PR Lint Feedback

Note: This automated check helps ensure your PR follows our contribution guidelines.

⚠️ Items that need attention:

🤖 AI attribution

The following commits lack an explicit AI attribution footer:

  • 2aefc3d feat(github): add update comment strategy for GitHub
  • 7b1084b docs(repository): document update comment strategy

If no AI assistance was used for a commit, you can ignore this warning.
Otherwise add an Assisted-by: or Co-authored-by: footer referencing the AI used.


ℹ️ Next Steps

  • Review and address the items above
  • Push new commits to update this PR
  • This comment will be automatically updated when issues are resolved
🔧 Admin Tools (click to expand)

Automated Issue/Ticket Creation:

  • /issue-create - Generate a GitHub issue from this PR content using AI
  • /jira-create - Create a SRVKP Jira ticket from this PR content using AI

⚠️ Important: Always review and edit generated content before finalizing tickets/issues.
The AI-generated content should be used as a starting point and may need adjustments.

These commands are available to maintainers and will post the generated content as PR comments for review.

🤖 This feedback was generated automatically by the PR CI system

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @theakshaypant, 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 introduces a significant enhancement for GitHub integration by implementing an "update" comment strategy. This new feature consolidates PipelineRun status updates into a single, continuously updated comment on a pull request, rather than generating a new comment for each status change or re-execution. This change aims to improve the user experience by reducing notification volume and keeping the pull request conversation cleaner.

Highlights

  • New GitHub Comment Strategy: Introduced a new update comment strategy for GitHub, allowing a single PipelineRun comment to be updated instead of creating multiple new ones, thus reducing notification noise.
  • Comprehensive End-to-End Tests: Added extensive end-to-end tests to validate the update comment strategy, covering scenarios such as CEL error replacement, handling multiple PipelineRuns, and ensuring correct behavior with regex characters in PipelineRun names.
  • Documentation Update: Updated the official documentation to clearly describe the new update comment strategy and its usage for GitHub repositories.
Changelog
  • config/300-repositories.yaml
    • Added "update" as a valid comment_strategy option for GitHub repositories within the configuration schema.
  • docs/content/docs/guide/repositorycrd.md
    • Documented the new "update" comment strategy for GitHub, explaining its behavior and benefits in detail.
  • pkg/apis/pipelinesascode/v1alpha1/types.go
    • Extended the CommentStrategy enumeration in GithubSettings to include the new "update" option.
  • pkg/provider/github/status.go
    • Implemented the core logic for the "update" comment strategy, including a new formatPipelineComment function to structure the updated comments with appropriate emojis and status details.
  • pkg/provider/provider.go
    • Defined new constants for UpdateCommentStrategy and DisableAllCommentStrategy, along with a PlrStatusCommentPrefixTemplate and an IsCommentStrategyUpdate helper function for comment management.
  • test/github_comment_strategy_update_test.go
    • Added new end-to-end tests to verify the functionality of the "update" comment strategy, covering CEL error handling, multiple PipelineRuns, and special characters in PipelineRun names.
  • test/pkg/github/pr.go
    • Modified PushFilesToRef to support updating existing Git references and introduced a new helper function UpdateFilesInRef to facilitate testing scenarios requiring ref updates.
  • test/testdata/failures/pipelinerun-invalid-cel.yaml
    • Updated the test PipelineRun YAML to include a target-namespace annotation for improved test setup.
  • test/testdata/pipelinerun-regex-chars-brackets.yaml
    • Added a new test PipelineRun YAML specifically designed to test PipelineRun names containing bracket characters.
  • test/testdata/pipelinerun-regex-chars-dots.yaml
    • Added a new test PipelineRun YAML specifically designed to test PipelineRun names containing dot characters.
Activity
  • Implemented the initial feature for the GitHub update comment strategy.
  • Developed comprehensive end-to-end tests to ensure the robustness and correctness of the new comment strategy.
  • Documented the new update comment strategy to provide clear guidance for users.
  • Utilized AI assistance (Claude) for generating parts of the unit/E2E tests and commit messages.
  • This pull request depends on feat(gitlab): add update comment stategy #2446 for related changes.
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.

@pipelines-as-code pipelines-as-code bot added documentation Improvements or additions to documentation feature New feature or request github labels Feb 16, 2026
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 introduces a new 'update' comment strategy for GitHub, allowing a single comment per PipelineRun to be updated, which helps reduce notification noise. However, a potential Markdown/HTML injection vulnerability exists because the user-controlled PipelineRun name is used without sanitization in HTML comment markers and the visible comment body, which could allow an attacker to inject malicious content or break out of the comment structure. Additionally, the review identified duplicated logic in pkg/provider/github/status.go, opportunities to improve E2E test stability by replacing time.Sleep with polling, and minor inconsistencies in regular expressions.

defer g.TearDown(ctx, t)

g.Cnx.Clients.Log.Infof("Waiting for CEL error comment to be created")
time.Sleep(15 * time.Second)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using time.Sleep can lead to flaky tests, especially in E2E environments where timing can vary. It would be more robust to use a polling mechanism with a timeout to wait for the expected condition (e.g., a comment to be created). The project's twait package might have helpers for this, or you could implement a simple polling loop. This applies to other time.Sleep calls in this file as well.

Copy link
Copy Markdown
Member Author

@theakshaypant theakshaypant left a comment

Choose a reason for hiding this comment

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

Have not duplicated the code in 2446 so expect the CI to fail.

@theakshaypant theakshaypant force-pushed the SRVKP-10453-github-update-comment-strategy branch from 50e0920 to bb9236d Compare February 19, 2026 10:34
@theakshaypant theakshaypant force-pushed the SRVKP-10453-github-update-comment-strategy branch from bb9236d to 76c3181 Compare February 19, 2026 10:39
@theakshaypant
Copy link
Copy Markdown
Member Author

/retest go-testing

@theakshaypant theakshaypant marked this pull request as ready for review February 19, 2026 11:11
@chmouel
Copy link
Copy Markdown
Member

chmouel commented Feb 19, 2026

/lgtm

Copy link
Copy Markdown

@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 @theakshaypant 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 🧭

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Feb 19, 2026

can you update the PR description properly (ie as a sentence)? that would help the release note

@theakshaypant
Copy link
Copy Markdown
Member Author

can you update the PR description properly (ie as a sentence)? that would help the release note

Done. Will keep that in mind for the future.

@theakshaypant
Copy link
Copy Markdown
Member Author

For reference, e2e tests cover the scenarios described in #2446 (comment)

Implement "update" comment strategy for GitHub pull requests that
updates a single comment per PipelineRun instead of creating new
comments on every trigger.

Jira: https://issues.redhat.com/browse/SRVKP-10453

Signed-off-by: Akshay Pant <akshay.akshaypant@gmail.com>
@theakshaypant theakshaypant force-pushed the SRVKP-10453-github-update-comment-strategy branch from fc71e3a to 65b8af8 Compare February 23, 2026 05:45
@theakshaypant
Copy link
Copy Markdown
Member Author

/retest

1 similar comment
@zakisk
Copy link
Copy Markdown
Member

zakisk commented Feb 23, 2026

/retest

@zakisk
Copy link
Copy Markdown
Member

zakisk commented Feb 23, 2026

/lgtm

Copy link
Copy Markdown

@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 @theakshaypant your PR Has been approved 🎉

✅ Pull Request Approved

Approval Status:

  • Required Approvals: 1
  • Current Approvals: 2

👥 Reviewers Who Approved:

Reviewer Permission Level Approval Status
@zakisk admin
@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 🧭

// 1. A CEL error comment is posted for a PLR
// 2. After fixing the CEL error with a new commit, the same comment is updated with success status
// 3. Only one comment exists.
func TestGithubCommentStrategyUpdateCELErrorReplacement(t *testing.T) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@theakshaypant the test you've added is failing in E2E

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Needed a change after the rebase, fixed in 1e50ff9

Add E2E tests for update comment strategy: CEL error replacement,
multiple PLRs, and regex character handling. Add UpdateFilesInRef
helper for updating files in existing branches.

Signed-off-by: Akshay Pant <akshay.akshaypant@gmail.com>
Assisted-by: Claude Sonnet 4.5 (via Claude Code
Add documentation for update comment strategy option. This strategy
creates a single comment per PipelineRun that gets updated with new
status and commit SHA on re-execution.

Signed-off-by: Akshay Pant <akshay.akshaypant@gmail.com>
@theakshaypant theakshaypant force-pushed the SRVKP-10453-github-update-comment-strategy branch from 65b8af8 to 7b1084b Compare February 23, 2026 07:18
@theakshaypant theakshaypant merged commit 490183d into tektoncd:main Feb 23, 2026
13 checks passed
@theakshaypant theakshaypant deleted the SRVKP-10453-github-update-comment-strategy branch February 23, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feature New feature or request github

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants