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: PR labels (#3002) #3118

Merged
merged 3 commits into from
Dec 20, 2024
Merged

feat: PR labels (#3002) #3118

merged 3 commits into from
Dec 20, 2024

Conversation

muenchdo
Copy link
Contributor

closes #3002

Copy link

netlify bot commented Dec 10, 2024

Deploy Preview for docs-kargo-io ready!

Name Link
🔨 Latest commit a5fa2c9
🔍 Latest deploy log https://app.netlify.com/sites/docs-kargo-io/deploys/6764ad0f4b799100080cd2cf
😎 Deploy Preview https://deploy-preview-3118.docs.kargo.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 40.62500% with 19 lines in your changes missing coverage. Please review.

Project coverage is 51.34%. Comparing base (d551ab8) to head (a5fa2c9).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/gitprovider/github/github.go 47.82% 11 Missing and 1 partial ⚠️
internal/gitprovider/azure/azure.go 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3118      +/-   ##
==========================================
+ Coverage   51.16%   51.34%   +0.17%     
==========================================
  Files         286      286              
  Lines       25912    25940      +28     
==========================================
+ Hits        13259    13319      +60     
+ Misses      11950    11908      -42     
- Partials      703      713      +10     

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

@muenchdo
Copy link
Contributor Author

@krancour I went down the rabbit hole of adding tests for the GitHub provider. Please let me know if this is generally going in a direction you like or whether the added complexity for these new tests is too much.

@krancour
Copy link
Member

I went down the rabbit hole of adding tests for the GitHub provider.

I like how you're approaching it, but the thing I worry about is that for something as complex as the GitHub APIs, it's plausible for the mock to accidentally do something that's inconsistent with the real API's behavior with the result being tests that pass but shouldn't.

We eventually need to figure out how to have dedicated repos for each provider perpetually available to test against or have a way to provision repos just-in-time and clean them up afterwards.

For now, I wouldn't let the above get in the way.

@muenchdo
Copy link
Contributor Author

For now, I wouldn't let the above get in the way.

By that do you mean you wouldn't add tests at all or just leave them as proposed in the PR and then add some real integration tests later?

Comment on lines 119 to 159
type githubClientWrapper struct {
client *github.Client
}

func (g githubClientWrapper) CreatePullRequest(ctx context.Context, owner string, repo string, pull *github.NewPullRequest) (*github.PullRequest, *github.Response, error) {
return g.client.PullRequests.Create(ctx, owner, repo, pull)
}

func (g githubClientWrapper) ListPullRequests(ctx context.Context, owner string, repo string, opts *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) {
return g.client.PullRequests.List(ctx, owner, repo, opts)
}

func (g githubClientWrapper) GetPullRequests(ctx context.Context, owner string, repo string, number int) (*github.PullRequest, *github.Response, error) {
return g.client.PullRequests.Get(ctx, owner, repo, number)
}

func (g githubClientWrapper) AddLabelsToIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*github.Label, *github.Response, error) {
return g.client.Issues.AddLabelsToIssue(ctx, owner, repo, number, labels)
}

Copy link
Member

Choose a reason for hiding this comment

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

Instead of creating a client wrapper, could the githubClient interface just be the relevant subset of the methods the client already actually has? This way we can just use the existing (unwrapped) client as the implementation of the githubClient, which is the interface we'll code to?

Copy link
Member

Choose a reason for hiding this comment

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

Oh... it's because of this p.client.PullRequests.Create 🤦‍♂️

That makes my suggestion rather difficult to pull off.

Nevermind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Believe me, I tried 😄

@krancour
Copy link
Member

By that do you mean you wouldn't add tests at all or just leave them as proposed in the PR and then add some real integration tests later?

Dealer's choice. I'm fine either way.

btw... #3128 just got merged, so you probably have to tweak that new provider a bit as well. Hopefully that's no too involved.

Signed-off-by: Dominik Münch <d.muench@celonis.com>
Signed-off-by: Dominik Münch <d.muench@celonis.com>
Signed-off-by: Dominik Münch <d.muench@celonis.com>
@muenchdo muenchdo marked this pull request as ready for review December 19, 2024 23:44
@muenchdo muenchdo requested review from a team as code owners December 19, 2024 23:44
@krancour krancour added this pull request to the merge queue Dec 20, 2024
@krancour
Copy link
Member

@diegocaspi thank you for some excellent work on this!

Merged via the queue into akuity:main with commit 7904760 Dec 20, 2024
16 of 17 checks passed
@muenchdo muenchdo deleted the pr-labels branch December 20, 2024 10:02
fykaa pushed a commit to fykaa/kargo that referenced this pull request Dec 20, 2024
Signed-off-by: Dominik Münch <d.muench@celonis.com>
fykaa pushed a commit to fykaa/kargo that referenced this pull request Jan 16, 2025
Signed-off-by: Dominik Münch <d.muench@celonis.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PR Labels
2 participants