Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add gitlab support #205

Merged
merged 7 commits into from
Mar 27, 2025
Merged

Conversation

robinlieb
Copy link
Contributor

Implements #141

Copy link
Contributor

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

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

Looking fantastic! Did a quick first round review.

func (pr *PullRequest) Update(ctx context.Context, title, description string, prObj *v1alpha1.PullRequest) error {
logger := log.FromContext(ctx)

mrIID, err := strconv.Atoi(prObj.Status.ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should standardize on "Merge Request" within the context of the gitlab-specific code for variable names, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean that it's currently e.g. repo vs. gitRepo?

Copy link
Contributor

Choose a reason for hiding this comment

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

nah, it just that most stuff in the new gitlab code refers to "pull requests" even though gitlab calls them "merge requests." Not a big deal, but maybe better to stick with the SCM's convention.

@zachaller
Copy link
Contributor

One thing to note and this is more information than anything that needs to be done in this PR, there is also webhook support that is somewhat required at lest for faster reconciliation triggering than the default I think 10 minutes. There is not much support for multiple providers but you can see that here

@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 9.43396% with 48 lines in your changes missing coverage. Please review.

Project coverage is 50.25%. Comparing base (c6a2c1b) to head (64e7641).

Files with missing lines Patch % Lines
...rnal/controller/changetransferpolicy_controller.go 31.25% 11 Missing ⚠️
internal/scms/github/pullrequest.go 0.00% 8 Missing ⚠️
...ternal/controller/argocdcommitstatus_controller.go 0.00% 7 Missing ⚠️
internal/controller/commitstatus_controller.go 0.00% 7 Missing ⚠️
internal/controller/pullrequest_controller.go 0.00% 7 Missing ⚠️
internal/utils/utils.go 0.00% 5 Missing ⚠️
internal/scms/github/git_operations.go 0.00% 2 Missing ⚠️
internal/scms/github/commit_status.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #205      +/-   ##
==========================================
- Coverage   50.94%   50.25%   -0.70%     
==========================================
  Files          15       15              
  Lines        1751     1793      +42     
==========================================
+ Hits          892      901       +9     
- Misses        739      773      +34     
+ Partials      120      119       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@robinlieb robinlieb force-pushed the feat/gitlab branch 2 times, most recently from afb8774 to 6be7e34 Compare March 19, 2025 19:21
@robinlieb robinlieb marked this pull request as ready for review March 19, 2025 19:37
@robinlieb
Copy link
Contributor Author

@zachaller good catch, created #222 to keep track of that.

Copy link
Contributor

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

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

func (pr *PullRequest) Update(ctx context.Context, title, description string, prObj *v1alpha1.PullRequest) error {
logger := log.FromContext(ctx)

mrIID, err := strconv.Atoi(prObj.Status.ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

nah, it just that most stuff in the new gitlab code refers to "pull requests" even though gitlab calls them "merge requests." Not a big deal, but maybe better to stick with the SCM's convention.

@crenshaw-dev
Copy link
Contributor

I'm not getting anything for rate limits:

2025-03-24T10:15:27.383156-04:00        INFO    GitLab rate limits      {"controller": "pullrequest", "controllerGroup": "promoter.argoproj.io", "controllerKind": "PullRequest", "PullRequest": {"name":"mac9416-gitops-promoter-tests-environment-dev-next-environment-dev-acfd9df0","namespace":"promoter-system"}, "namespace": "promoter-system", "name": "mac9416-gitops-promoter-tests-environment-dev-next-environment-dev-acfd9df0", "reconcileID": "d28b1c59-8dcf-4fcf-9a60-c935b5d1cdc7", "scmProvider": "gitlab", "limit": "", "remaining": "", "reset": "", "url": "https://gitlab.com/api/v4/merge_requests?source_branch=environment%2Fdev-next&state=opened&target_branch=environment%2Fdev"}

robinlieb and others added 5 commits March 27, 2025 07:29
Signed-off-by: Robin Lieb <[email protected]>
Signed-off-by: Robin Lieb <[email protected]>
Signed-off-by: Robin Lieb <[email protected]>
Co-authored-by: Michael Crenshaw <[email protected]>
Signed-off-by: Robin Lieb <[email protected]>
@robinlieb robinlieb force-pushed the feat/gitlab branch 3 times, most recently from 37d4090 to c3b19a6 Compare March 27, 2025 08:40
@robinlieb
Copy link
Contributor Author

I'm not getting anything for rate limits:

2025-03-24T10:15:27.383156-04:00        INFO    GitLab rate limits      {"controller": "pullrequest", "controllerGroup": "promoter.argoproj.io", "controllerKind": "PullRequest", "PullRequest": {"name":"mac9416-gitops-promoter-tests-environment-dev-next-environment-dev-acfd9df0","namespace":"promoter-system"}, "namespace": "promoter-system", "name": "mac9416-gitops-promoter-tests-environment-dev-next-environment-dev-acfd9df0", "reconcileID": "d28b1c59-8dcf-4fcf-9a60-c935b5d1cdc7", "scmProvider": "gitlab", "limit": "", "remaining": "", "reset": "", "url": "https://gitlab.com/api/v4/merge_requests?source_branch=environment%2Fdev-next&state=opened&target_branch=environment%2Fdev"}

As far as I understand they are only provided on GitLab Self-Managed and also only once the limit is reached. There is no information provided to get the current status of the rate limit. I changed the implementation to only log if they are provided in the response.

@crenshaw-dev crenshaw-dev merged commit 0a49233 into argoproj-labs:main Mar 27, 2025
6 of 7 checks passed
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.

4 participants