feat(gitlab): add update comment stategy#2446
Conversation
Summary of ChangesHello @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 significantly enhances the GitLab integration by introducing an "update" comment strategy. This new feature streamlines communication on merge requests by consolidating all PipelineRun status updates and CEL validation errors into a single, continuously updated comment. This approach reduces comment clutter and provides a clear, real-time overview of pipeline execution directly within the merge request interface. 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
|
There was a problem hiding this comment.
Code Review
The pull request introduces a new 'update' comment strategy for GitLab, allowing for a single comment per PipelineRun to be updated on every trigger. This feature is implemented by adding new enum values to the API and schema definitions, and modifying the logic for reporting CEL validation errors and pipeline statuses to use this new strategy. The changes include adding constants for comment strategies and a helper function to check the current strategy. Overall, the changes are well-structured and integrate the new functionality effectively, with a minor suggestion regarding markdown formatting.
eec6744 to
43bf4b1
Compare
|
/review |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
43bf4b1 to
ab9acbe
Compare
This is a good catch, addressed in ab9acbe |
ab9acbe to
57a7295
Compare
|
❌ PR-Agent failed to apply 'global' repo settings The configuration file needs to be a valid TOML, please fix it. Error message: Configuration content:[github_app]
pr_commands = [ "/review" ]
[pr_reviewer]
enable_review_labels_security = true
enable_chat_in_code_suggestions=false
enable_chat_in_code_suggestions = false
enable_summary=false
enable_help_text=false
[pr_description]
publish_description_as_comment = true
[pr_code_suggestions]
commitable_code_suggestions = true
[pr_test]
num_tests = 0 |
daed45e to
443b123
Compare
|
if it's ready for review, can you remove the draft? |
443b123 to
8cf4d57
Compare
Will update with changes from this week and move it to ready. |
8cf4d57 to
6640a25
Compare
theakshaypant
left a comment
There was a problem hiding this comment.
I also decided to skip caching the comment ID in the PLR annotation in this implementation.
Consider a scenario where 5 PLRs complete, their respective comments are added, and the PLRs are patched with the comment IDs. If a new push triggers the same 5 PLRs again, and the previous runs have been cleaned up (eg, due to the max-keep-runs annotation or the pruner), we would end up fetching the comment via the Gitlab API using the original PR name marker anyway.
In my local testing, most lookups were done via the Gitlab API because older PLRs had already been cleaned up, so the annotation-based caching was rarely used. Given that, I felt the added complexity of maintaining this caching mechanism wasn’t justified, especially if it’s unlikely to be used frequently.
That said, I’m not sure if the same would hold true in other use cases, open to hearing other thoughts.
| if provider.IsCommentStrategyUpdate(repo) { | ||
| // Using the same logic for getting OriginalPipelineRun as the one used for setting | ||
| // the annotation which is used in the provider's "update" comment strategy. | ||
| originPipelineRunName := prun.GetName() | ||
| if originPipelineRunName == "" && prun.GenerateName != "" { | ||
| originPipelineRunName = prun.GetGenerateName() | ||
| } | ||
|
|
||
| if reportErrors { | ||
| reportCELValidationErrors(ctx, repo, []*pacerrors.PacYamlValidations{{ | ||
| Name: originPipelineRunName, | ||
| Err: fmt.Errorf("CEL expression evaluation error: %s", sanitizeErrorAsMarkdown(err)), | ||
| }}, eventEmitter, vcx, event, fmt.Sprintf(provider.PlrStatusCommentPrefixTemplate, originPipelineRunName)) | ||
| } | ||
| } else { | ||
| celValidationErrors = append(celValidationErrors, &pacerrors.PacYamlValidations{ | ||
| Name: prName, | ||
| Err: fmt.Errorf("CEL expression evaluation error: %s", sanitizeErrorAsMarkdown(err)), | ||
| }) | ||
| } |
There was a problem hiding this comment.
Input needed here.
I’ve updated the behavior so that pipeline CEL validation error comments are replaced with the current PLR status once the issue is resolved. With this change, users will only see the latest state of a PLR (e.g., CEL error, validation error, running, success, failure).
This differs from the current behavior, where CEL error comments remain on the MR even after they’ve been fixed. I believe this provides a better UX by reflecting the most up-to-date status for each PLR.
WDYT @zakisk @chmouel?
|
I like this direction overall.
One thing I’d like us to fix before merge:
Test coverage I’d like to see but skip it if they are too hard to implement for the values they gives:
|
That's a good point, will make this change.
I was planning on adding the first 2 cases you mentioned but for github. Since comments are fallback on gitlab, I thought it would be easier to have this in e2e tests for github provider using webhook. |
6640a25 to
922bb39
Compare
Adds an "update" comment strategy which updates a single comment per PipelineRun on every trigger. This comment strategy reports CEL validation errors immediately with a PipelineRun-specific prefix when using the update comment strategy, allowing them to be consolidated into a single updatable comment per PipelineRun. Jira: https://issues.redhat.com/browse/SRVKP-10453 Signed-off-by: Akshay Pant <akshay.akshaypant@gmail.com>
922bb39 to
17e7020
Compare
📝 Description of the Change
Adds an "update" comment strategy which updates a single comment per PipelineRun on every trigger.
This comment strategy reports CEL validation errors immediately with a PipelineRun-specific prefix when using the update comment strategy, allowing them to be consolidated into a single updatable comment per PipelineRun.
👨🏻 Linked Jira
https://issues.redhat.com/browse/SRVKP-10453
🔗 Linked GitHub Issue
N/A
🚀 Type of Change
fix:)feat:)feat!:,fix!:)docs:)chore:)refactor:)enhance:)deps:)🧪 Testing Strategy
Unit tests
Integration tests
End-to-end tests
Manual testing
Not Applicable
Pull Request 1 with /retest

Pull Request 2 with CEL validation errors

Pull request 2 status after CEL errors were resolved with an validation error

🤖 AI Assistance
If you have used AI assistance, please provide the following details:
Which LLM was used?
Extent of AI Assistance:
Important
If the majority of the code in this PR was generated by an AI, please add a
Co-authored-bytrailer 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.shto automatically addthese co-author trailers to your commits.
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.