Skip to content

feat: Add support for GitHub Code Quality API#4260

Open
MasterOogway1466 wants to merge 4 commits into
google:masterfrom
MasterOogway1466:code-quality-support
Open

feat: Add support for GitHub Code Quality API#4260
MasterOogway1466 wants to merge 4 commits into
google:masterfrom
MasterOogway1466:code-quality-support

Conversation

@MasterOogway1466
Copy link
Copy Markdown
Contributor

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/setup
  • PATCH /repos/{owner}/{repo}/code-quality/setup

Closes #4258.

Validation

Ran the repository validation flow from CONTRIBUTING.md:

  • script/fmt.sh
  • script/test.sh ./...
  • script/lint.sh
  • script/generate.sh

@gmlewis gmlewis changed the title feat: add support for Github code quality feat: Add support for GitHub Code Quality API May 28, 2026
@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label May 28, 2026
Copy link
Copy Markdown
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

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

Comment thread github/code_quality.go Outdated
Comment thread github/code_quality_test.go Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.48%. Comparing base (e03b799) to head (24ec136).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
Comment thread github/code_quality.go Outdated
Comment on lines +46 to +52
// 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))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The doc says, that apiVersion=2022-11-28. But the implementation has WithVersion(api20260310).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The same for UpdateSetup

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, 2026-03-10 is the correct apiVersion sorry for not checking the comments thoroughly before submitting 🥲

Comment thread github/code_quality_test.go Outdated
"github.com/google/go-cmp/cmp"
)

func TestCodeQualitySetupConfiguration_Marshal(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test is no longer needed.
Reason comment

Comment thread github/code_quality_test.go Outdated
testJSONMarshal(t, c, want)
}

func TestUpdateCodeQualitySetupResponse_Marshal(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test is no longer needed.
comment

Comment thread github/code_quality.go Outdated
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))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
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-configuration

This link (L71) has apiVersion=2022-11-28. So I believe we can remove WithVersion(api20260310)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@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)

@MasterOogway1466
Copy link
Copy Markdown
Contributor Author

MasterOogway1466 commented May 28, 2026

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 /script/test.sh. However, when I run /script/generate.sh it changes the API version back to 2022-11-28 in the comments.

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?

Before running /script/generate.sh (git diff)-
image

After running /script/generate.sh (git diff)-
image

Comment thread github/code_quality.go
Comment thread github/code_quality.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Code Quality support

5 participants