feat: Add support for GitHub Code Quality API#4260
Conversation
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @MasterOogway1466!
Just a couple tweaks, please, then we should be ready for a second LGTM+Approval from any other contributor to this repo before merging.
cc: @stevehipwell - @alexandear - @zyfy29 - @Not-Dhananjay-Mishra - @munlicode
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4260 +/- ##
=======================================
Coverage 97.48% 97.48%
=======================================
Files 191 192 +1
Lines 19206 19227 +21
=======================================
+ Hits 18723 18744 +21
Misses 268 268
Partials 215 215 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
| // GitHub API docs: https://docs.github.com/rest/code-quality/code-quality?apiVersion=2022-11-28#get-a-code-quality-setup-configuration | ||
| // | ||
| //meta:operation GET /repos/{owner}/{repo}/code-quality/setup | ||
| func (s *CodeQualityService) GetSetup(ctx context.Context, owner, repo string) (*CodeQualitySetupConfiguration, *Response, error) { | ||
| u := fmt.Sprintf("repos/%v/%v/code-quality/setup", owner, repo) | ||
|
|
||
| req, err := s.client.NewRequest(ctx, "GET", u, nil, WithVersion(api20260310)) |
There was a problem hiding this comment.
The doc says, that apiVersion=2022-11-28. But the implementation has WithVersion(api20260310).
There was a problem hiding this comment.
The same for UpdateSetup
There was a problem hiding this comment.
Yeah, 2026-03-10 is the correct apiVersion sorry for not checking the comments thoroughly before submitting 🥲
| "github.com/google/go-cmp/cmp" | ||
| ) | ||
|
|
||
| func TestCodeQualitySetupConfiguration_Marshal(t *testing.T) { |
| testJSONMarshal(t, c, want) | ||
| } | ||
|
|
||
| func TestUpdateCodeQualitySetupResponse_Marshal(t *testing.T) { |
| func (s *CodeQualityService) UpdateSetup(ctx context.Context, owner, repo string, opts *UpdateCodeQualitySetupOptions) (*UpdateCodeQualitySetupResponse, *Response, error) { | ||
| u := fmt.Sprintf("repos/%v/%v/code-quality/setup", owner, repo) | ||
|
|
||
| req, err := s.client.NewRequest(ctx, "PATCH", u, opts, WithVersion(api20260310)) |
There was a problem hiding this comment.
| req, err := s.client.NewRequest(ctx, "PATCH", u, opts, WithVersion(api20260310)) | |
| req, err := s.client.NewRequest(ctx, "PATCH", u, opts) |
// GitHub API docs: https://docs.github.com/rest/code-quality/code-quality?apiVersion=2022-11-28#update-a-code-quality-setup-configurationThis link (L71) has apiVersion=2022-11-28. So I believe we can remove WithVersion(api20260310)
There was a problem hiding this comment.
@MasterOogway1466 Let's remove the WithVersion(api20260310). Basically, there is nothing specific for the API 2026-03-10 that is not present in 2022-11-28.
This will resolve your problem #4260 (comment)
|
Okay I have a question. Every time I implement the 2026-03-10 version of the API, it passes all the tests when I run As per the issue I opened the PR for, the API version is meant to be the 2026 version. Not quite sure how to proceed, can I get some help on what to do about this? |


Summary
Adds client support for GitHub's Code Review REST API.
This implements the documented GitHub Code Quality: Repository Enablement API endpoints:
GET /repos/{owner}/{repo}/code-quality/setupPATCH /repos/{owner}/{repo}/code-quality/setupCloses #4258.
Validation
Ran the repository validation flow from
CONTRIBUTING.md:script/fmt.shscript/test.sh ./...script/lint.shscript/generate.sh