feat: Add comment strategy support for Gitea provider#2503
feat: Add comment strategy support for Gitea provider#2503chmouel merged 3 commits intotektoncd:mainfrom
Conversation
Summary of ChangesHello @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 enhances the Gitea provider by introducing configurable comment strategies for pipeline results on pull requests. Users can now choose to disable all comments or have a single comment updated for each PipelineRun, providing more control over the communication flow. The changes also include necessary refactoring to pass execution context to status creation methods and a crucial fix for regex handling to ensure robust comment management. Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
🔍 PR Lint Feedback
|
config/300-repositories.yaml
Outdated
| - roles | ||
| - secret_ref | ||
| type: object | ||
| gitea: |
There was a problem hiding this comment.
I can't remember the reasoning we have gitea or gitlab or githu specific settings when we could have just settings.comment_strategy shared across, i hate it, but this ship has sailed i guess
There was a problem hiding this comment.
I am changing this to forgejo, since this is user changes and we don't want to introduce a backward compatibility
There was a problem hiding this comment.
Code Review
This pull request adds support for comment_strategy to the Gitea provider, aligning its functionality with other providers like GitHub and GitLab. The changes include updates to the CRD, Go types, Gitea provider implementation, and validation webhook. The implementation correctly handles the disable_all and update strategies. Additionally, a bug in the comment update logic has been fixed by properly escaping regex meta-characters. The test coverage for the new functionality is good.
There was a problem hiding this comment.
Pull request overview
This pull request adds comment_strategy configuration support to the Gitea/Forgejo provider, bringing it to feature parity with the existing GitHub and GitLab providers. The implementation allows users to control how pipeline result comments are posted on pull requests by supporting two strategies: disable_all (prevents all status comments) and update (updates a single comment per PipelineRun instead of creating new ones on every trigger).
Changes:
- Added
GiteaSettingstype withCommentStrategyfield to repository settings API - Implemented comment strategy logic in the Gitea provider to support
disable_allandupdatestrategies - Fixed the update marker regex by escaping meta characters using
regexp.QuoteMetafor proper comment matching
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/apis/pipelinesascode/v1alpha1/types.go | Added GiteaSettings struct with CommentStrategy field and updated Settings.Merge to handle Gitea settings |
| config/300-repositories.yaml | Added CRD schema definition for gitea.comment_strategy with validation enum |
| pkg/webhook/validation.go | Added validation logic to ensure only valid comment strategy values are accepted for Gitea |
| pkg/provider/provider.go | Extended IsCommentStrategyUpdate function to check Gitea settings alongside GitHub and GitLab |
| pkg/provider/gitea/gitea.go | Implemented comment strategy handling, added formatPipelineComment method, and fixed regex escaping |
| pkg/provider/gitea/gitea_test.go | Added tests for comment formatting and normalization in update comments |
| test/gitea_gitops_commands_test.go | Added integration test using update comment strategy |
| pkg/provider/gitea/testdata/TestCreateStatusUpdateCommentNormalizesBreaks.golden | Golden file for test verification |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8fc2cc0 to
1d1f047
Compare
There was a problem hiding this comment.
Code Review
This pull request adds support for comment_strategy to the Gitea provider, allowing users to control how pipeline status comments are posted on pull requests. The implementation is clean and includes new configurations in the CRD, provider logic to handle the strategies (disable_all, update), and comprehensive tests. The changes are consistent with existing features for other providers. The previously identified minor issue regarding an incomplete merge function remains valid and has been kept.
| if newSettings.Gitea != nil && s.Gitea == nil { | ||
| s.Gitea = newSettings.Gitea | ||
| } |
There was a problem hiding this comment.
This Merge function is missing logic for Github and Gitlab settings. While adding the merge logic for Gitea, we should also add it for the other providers for consistency and to ensure global settings are correctly applied as defaults.
if newSettings.Gitea != nil && s.Gitea == nil {
s.Gitea = newSettings.Gitea
}
if newSettings.Github != nil && s.Github == nil {
s.Github = newSettings.Github
}
if newSettings.Gitlab != nil && s.Gitlab == nil {
s.Gitlab = newSettings.Gitlab
}There was a problem hiding this comment.
we maybe need to double check this
1d1f047 to
1dbe476
Compare
1dbe476 to
975723b
Compare
Added `comment_strategy` configuration to the Foregejo/Gitea provider settings to control how pipeline result comments were handled on pull requests. Supported options included `disable_all` to prevent status comments and `update` to modify a single existing comment per PipelineRun instead of creating new ones on every trigger. Passed the execution context to the status creation methods to support the updated comment functionality and fixed the update marker regex by escaping meta characters. Jira: https://issues.redhat.com/browse/SRVKP-10900 Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
975723b to
cdf8e93
Compare
📝 Description of the Change
Added
comment_strategyconfiguration to the Gitea provider settings to control how pipeline result comments are handled on pull requests.Features:
disable_all: Prevents status comments from being created on pull requestsupdate: Modifies a single existing comment per PipelineRun instead of creating new ones on every triggerChanges:
comment_strategyfield to repository configurationGitea provider now supports configuration of how pipeline status comments are created on pull requests through the new
comment_strategyfield. This allows users to either disable comments entirely or update a single comment per PipelineRun instead of creating multiple comments.👨🏻 Linked Jira
Jira: https://issues.redhat.com/browse/SRVKP-10900
🔗 Linked GitHub Issue
🚀 Type of Change
feat:)🧪 Testing Strategy
🤖 AI Assistance
Which LLM was used?
Extent of AI Assistance:
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix any issues. For an efficient workflow, I have considered installing pre-commit and runningpre-commit installto automate these checks.