Repository: google/go-github
Pull request #3167 (2024-05-13 02:58:54)

feat!: Change enterprise runner to also use ListRunnersOptions
Fixes: #3166.

BREAKING-CHANGE: This changes `ListOptions` to  `ListRunnersOptions` in `EnterpriseService.ListRunners`.

I fixed a bug related ListRunners API. The `ListRunnersOptions` was not being applied to Enterprise Runner.
follow up: https://github.com/google/go-github/pull/3094


google-cla[bot]: Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this [failed invocation](https://github.com/google/go-github/pull/3167/checks?check_run_id=24879240660) of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/3167?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 92.91%. Comparing base [(`2b8c7fa`)](https://app.codecov.io/gh/google/go-github/commit/2b8c7fa86fcd1cb4a89a44c8e7b5a49fe4be8a45?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) to head [(`00ae280`)](https://app.codecov.io/gh/google/go-github/pull/3167?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> Report is 59 commits behind head on master.


<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #3167      +/-   ##
==========================================
- Coverage   97.72%   92.91%   -4.81%     
==========================================
  Files         153      171      +18     
  Lines       13390    11502    -1888     
==========================================
- Hits        13085    10687    -2398     
- Misses        215      724     +509     
- Partials       90       91       +1     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/google/go-github/pull/3167?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).

gmlewis: @fentas - perhaps you are available to review this?
gmlewis: Thank you, @fentas ! Merging.

Patch:
diff --git a/github/enterprise_actions_runners.go b/github/enterprise_actions_runners.go
index 4a6e6b52..a5364815 100644
--- a/github/enterprise_actions_runners.go
+++ b/github/enterprise_actions_runners.go
@@ -80,7 +80,7 @@ func (s *EnterpriseService) CreateRegistrationToken(ctx context.Context, enterpr
 // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-enterprise
 //
 //meta:operation GET /enterprises/{enterprise}/actions/runners
-func (s *EnterpriseService) ListRunners(ctx context.Context, enterprise string, opts *ListOptions) (*Runners, *Response, error) {
+func (s *EnterpriseService) ListRunners(ctx context.Context, enterprise string, opts *ListRunnersOptions) (*Runners, *Response, error) {
 	u := fmt.Sprintf("enterprises/%v/actions/runners", enterprise)
 	u, err := addOptions(u, opts)
 	if err != nil {


Test patch:
diff --git a/github/enterprise_actions_runners_test.go b/github/enterprise_actions_runners_test.go
index 36b2aaef..3bc3c737 100644
--- a/github/enterprise_actions_runners_test.go
+++ b/github/enterprise_actions_runners_test.go
@@ -106,11 +106,14 @@ func TestEnterpriseService_ListRunners(t *testing.T) {
 
 	mux.HandleFunc("/enterprises/e/actions/runners", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, "GET")
-		testFormValues(t, r, values{"per_page": "2", "page": "2"})
-		fmt.Fprint(w, `{"total_count":2,"runners":[{"id":23,"name":"MBP","os":"macos","status":"online"},{"id":24,"name":"iMac","os":"macos","status":"offline"}]}`)
+		testFormValues(t, r, values{"name": "MBP", "per_page": "2", "page": "2"})
+		fmt.Fprint(w, `{"total_count":1,"runners":[{"id":23,"name":"MBP","os":"macos","status":"online"}]}`)
 	})
 
-	opts := &ListOptions{Page: 2, PerPage: 2}
+	opts := &ListRunnersOptions{
+		Name:        String("MBP"),
+		ListOptions: ListOptions{Page: 2, PerPage: 2},
+	}
 	ctx := context.Background()
 	runners, _, err := client.Enterprise.ListRunners(ctx, "e", opts)
 	if err != nil {
@@ -118,10 +121,9 @@ func TestEnterpriseService_ListRunners(t *testing.T) {
 	}
 
 	want := &Runners{
-		TotalCount: 2,
+		TotalCount: 1,
 		Runners: []*Runner{
 			{ID: Int64(23), Name: String("MBP"), OS: String("macos"), Status: String("online")},
-			{ID: Int64(24), Name: String("iMac"), OS: String("macos"), Status: String("offline")},
 		},
 	}
 	if !cmp.Equal(runners, want) {
@@ -130,7 +132,7 @@ func TestEnterpriseService_ListRunners(t *testing.T) {
 
 	const methodName = "ListRunners"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Enterprise.ListRunners(ctx, "\n", &ListOptions{})
+		_, _, err = client.Enterprise.ListRunners(ctx, "\n", &ListRunnersOptions{})
 		return err
 	})