Skip to content

Commit

Permalink
Merge branch 'master' into workflow-job-event
Browse files Browse the repository at this point in the history
  • Loading branch information
mumoshu committed Sep 23, 2021
2 parents 77e71f7 + 55021d5 commit 28b6547
Show file tree
Hide file tree
Showing 69 changed files with 3,169 additions and 146 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
- package-ecosystem: gomod
directory: scrape
schedule:
interval: weekly
- package-ecosystem: gomod
directory: update-urls
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
19 changes: 19 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on: [push, pull_request]
name: linter

jobs:
lint:
strategy:
matrix:
go-version: [1.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v2

- name: golangci-lint
uses: golangci/golangci-lint-action@5c56cd6c9dc07901af25baab6f2b0d9f3b7c3018 #v2.5.2
with:
version: v1.41
args: --verbose
30 changes: 19 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

steps:
- name: Cancel previous
uses: styfle/cancel-workflow-action@89f242ee29e10c53a841bfe71cc0ce7b2f065abc #0.9.0
uses: styfle/cancel-workflow-action@a40b8845c0683271d9f53dfcb887a7e181d3918b #0.9.1
with:
access_token: ${{ github.token }}

Expand All @@ -39,23 +39,24 @@ jobs:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v2

# Get values for cache paths to be used in later steps
- id: cache-paths
run: |
echo "::set-output name=go-cache::$(go env GOCACHE)"
echo "::set-output name=go-mod-cache::$(go env GOMODCACHE)"
- name: Cache go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
path: |
${{ steps.cache-paths.outputs.go-cache }}
${{ steps.cache-paths.outputs.go-mod-cache }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-

- name: Run go fmt
if: runner.os != 'Windows'
run: diff -u <(echo -n) <(gofmt -d -s .)

- name: Ensure go generate produces a zero diff
shell: bash
run: go generate -x ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)

- name: Run go vet
run: go vet ./...
run: go generate -x ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)

- name: Run go test
run: go test -v -race -coverprofile coverage.txt -covermode atomic ./...
Expand All @@ -71,4 +72,11 @@ jobs:
- name: Upload coverage to Codecov
if: ${{ matrix.update-coverage }}
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b #v2.1.0

- name: Ensure go generate produces a zero diff for update-urls
shell: bash
run: cd update-urls && go generate -x ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)

- name: Run go test for update-urls
run: cd update-urls && go test -v -race ./...
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ coverage.out
# intellij files
.idea/
vendor/
.DS_Store
.DS_Store
.vscode
32 changes: 32 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
linters:
# TODO: fix errors so that all of the linters below pass.
# The linters that are commented out, as well as those explicitly disabled,
# are currently failing. We should fix those failures or define exclusion
# rules, and then enable those linters.
enable:
- dogsled
- dupl
- gofmt
- goimports
# - gosec
- misspell
- nakedret
# - stylecheck
# - unconvert
# - unparam
# - whitespace
disable:
- errcheck
- gosimple
- staticcheck
- ineffassign
- unused
issues:
exclude-rules:
- linters:
- dogsled
text: "declaration has 3 blank identifiers"
path: _test\.go
- linters:
- dupl
path: _test\.go
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# go-github #

[![go-github release (latest SemVer)](https://img.shields.io/github/v/release/google/go-github?sort=semver)](https://github.com/google/go-github/releases)
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/google/go-github/v38/github)
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/google/go-github/v39/github)
[![Test Status](https://github.com/google/go-github/workflows/tests/badge.svg)](https://github.com/google/go-github/actions?query=workflow%3Atests)
[![Test Coverage](https://codecov.io/gh/google/go-github/branch/master/graph/badge.svg)](https://codecov.io/gh/google/go-github)
[![Discuss at go-github@googlegroups.com](https://img.shields.io/badge/discuss-go--github%40googlegroups.com-blue.svg)](https://groups.google.com/group/go-github)
Expand All @@ -24,29 +24,29 @@ If you're interested in using the [GraphQL API v4][], the recommended library is
go-github is compatible with modern Go releases in module mode, with Go installed:

```bash
go get github.com/google/go-github/v38
go get github.com/google/go-github/v39
```

will resolve and add the package to the current development module, along with its dependencies.

Alternatively the same can be achieved if you use import in a package:

```go
import "github.com/google/go-github/v38/github"
import "github.com/google/go-github/v39/github"
```

and run `go get` without parameters.

Finally, to use the top-of-trunk version of this repo, use the following command:

```bash
go get github.com/google/go-github/v38@master
go get github.com/google/go-github/v39@master
```

## Usage ##

```go
import "github.com/google/go-github/v38/github" // with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/google/go-github/v39/github" // with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/google/go-github/github" // with go modules disabled
```

Expand Down Expand Up @@ -246,7 +246,7 @@ For complete usage of go-github, see the full [package docs][].
[oauth2]: https://github.com/golang/oauth2
[oauth2 docs]: https://godoc.org/golang.org/x/oauth2
[personal API token]: https://github.com/blog/1509-personal-api-tokens
[package docs]: https://pkg.go.dev/github.com/google/go-github/v38/github
[package docs]: https://pkg.go.dev/github.com/google/go-github/v39/github
[GraphQL API v4]: https://developer.github.com/v4/
[shurcooL/githubv4]: https://github.com/shurcooL/githubv4

Expand Down
2 changes: 1 addition & 1 deletion example/appengine/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"net/http"
"os"

"github.com/google/go-github/v38/github"
"github.com/google/go-github/v39/github"
"golang.org/x/oauth2"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
Expand Down
2 changes: 1 addition & 1 deletion example/basicauth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
"syscall"

"github.com/google/go-github/v38/github"
"github.com/google/go-github/v39/github"
"golang.org/x/crypto/ssh/terminal"
)

Expand Down
2 changes: 1 addition & 1 deletion example/commitpr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"strings"
"time"

"github.com/google/go-github/v38/github"
"github.com/google/go-github/v39/github"
"golang.org/x/oauth2"
)

Expand Down
2 changes: 1 addition & 1 deletion example/migrations/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"context"
"fmt"

"github.com/google/go-github/v38/github"
"github.com/google/go-github/v39/github"
"golang.org/x/oauth2"
)

Expand Down
2 changes: 1 addition & 1 deletion example/newrepo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"log"
"os"

"github.com/google/go-github/v38/github"
"github.com/google/go-github/v39/github"
"golang.org/x/oauth2"
)

Expand Down
2 changes: 1 addition & 1 deletion example/newreposecretwithlibsodium/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.15

require (
github.com/GoKillers/libsodium-go v0.0.0-20171022220152-dd733721c3cb
github.com/google/go-github/v38 v38.0.0
github.com/google/go-github/v39 v39.0.0
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
gopkg.in/yaml.v2 v2.3.0 // indirect
)
4 changes: 2 additions & 2 deletions example/newreposecretwithlibsodium/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-github/v33 v33.0.0 h1:qAf9yP0qc54ufQxzwv+u9H0tiVOnPJxo0lI/JXqw3ZM=
github.com/google/go-github/v33 v33.0.0/go.mod h1:GMdDnVZY/2TsWgp/lkYnpSAh6TrzhANBBwm6k6TTEXg=
github.com/google/go-github/v38 v38.0.0 h1:rCspN8/6kB1BAJWZfuafvHhyfIo5fkAulaP/3bOQ/tM=
github.com/google/go-github/v38 v38.0.0/go.mod h1:LM7in3NmXDrX58GbEHy7FtNLbI2JijX93RnMKvWG3m4=
github.com/google/go-github/v39 v39.0.0 h1:rCspN8/6kB1BAJWZfuafvHhyfIo5fkAulaP/3bOQ/tM=
github.com/google/go-github/v39 v39.0.0/go.mod h1:LM7in3NmXDrX58GbEHy7FtNLbI2JijX93RnMKvWG3m4=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
Expand Down
2 changes: 1 addition & 1 deletion example/newreposecretwithlibsodium/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"os"

sodium "github.com/GoKillers/libsodium-go/cryptobox"
"github.com/google/go-github/v38/github"
"github.com/google/go-github/v39/github"
"golang.org/x/oauth2"
)

Expand Down
2 changes: 1 addition & 1 deletion example/newreposecretwithxcrypto/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module newreposecretwithxcrypto
go 1.15

require (
github.com/google/go-github/v38 v38.0.0
github.com/google/go-github/v39 v39.0.0
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d // indirect
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
Expand Down
4 changes: 2 additions & 2 deletions example/newreposecretwithxcrypto/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-github/v38 v38.0.0 h1:rCspN8/6kB1BAJWZfuafvHhyfIo5fkAulaP/3bOQ/tM=
github.com/google/go-github/v38 v38.0.0/go.mod h1:LM7in3NmXDrX58GbEHy7FtNLbI2JijX93RnMKvWG3m4=
github.com/google/go-github/v39 v39.0.0 h1:rCspN8/6kB1BAJWZfuafvHhyfIo5fkAulaP/3bOQ/tM=
github.com/google/go-github/v39 v39.0.0/go.mod h1:LM7in3NmXDrX58GbEHy7FtNLbI2JijX93RnMKvWG3m4=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
Expand Down
2 changes: 1 addition & 1 deletion example/newreposecretwithxcrypto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"log"
"os"

"github.com/google/go-github/v38/github"
"github.com/google/go-github/v39/github"
"golang.org/x/crypto/nacl/box"
"golang.org/x/oauth2"
)
Expand Down
2 changes: 1 addition & 1 deletion example/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"context"
"fmt"

"github.com/google/go-github/v38/github"
"github.com/google/go-github/v39/github"
)

// Fetch all the public organizations' membership of a user.
Expand Down
2 changes: 1 addition & 1 deletion example/tokenauth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"log"
"syscall"

"github.com/google/go-github/v38/github"
"github.com/google/go-github/v39/github"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/oauth2"
)
Expand Down
2 changes: 1 addition & 1 deletion example/topics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"context"
"fmt"

"github.com/google/go-github/v38/github"
"github.com/google/go-github/v39/github"
)

// Fetch and lists all the public topics associated with the specified GitHub topic
Expand Down
7 changes: 6 additions & 1 deletion github/actions_runner_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,13 @@ func (s *ActionsService) UpdateOrganizationRunnerGroup(ctx context.Context, org
// ListRepositoryAccessRunnerGroup lists the repositories with access to a self-hosted runner group configured in an organization.
//
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#list-repository-access-to-a-self-hosted-runner-group-in-an-organization
func (s *ActionsService) ListRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID int64) (*ListRepositories, *Response, error) {
func (s *ActionsService) ListRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID int64, opts *ListOptions) (*ListRepositories, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories", org, groupID)
u, err := addOptions(u, opts)
if err != nil {
return nil, nil, err
}

req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
Expand Down
8 changes: 5 additions & 3 deletions github/actions_runner_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,13 @@ func TestActionsService_ListRepositoryAccessRunnerGroup(t *testing.T) {

mux.HandleFunc("/orgs/o/actions/runner-groups/2/repositories", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"per_page": "1", "page": "1"})
fmt.Fprint(w, `{"total_count": 1, "repositories": [{"id": 43, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World"}]}`)
})

ctx := context.Background()
groups, _, err := client.Actions.ListRepositoryAccessRunnerGroup(ctx, "o", 2)
opts := &ListOptions{Page: 1, PerPage: 1}
groups, _, err := client.Actions.ListRepositoryAccessRunnerGroup(ctx, "o", 2, opts)
if err != nil {
t.Errorf("Actions.ListRepositoryAccessRunnerGroup returned error: %v", err)
}
Expand All @@ -255,12 +257,12 @@ func TestActionsService_ListRepositoryAccessRunnerGroup(t *testing.T) {

const methodName = "ListRepositoryAccessRunnerGroup"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.ListRepositoryAccessRunnerGroup(ctx, "\n", 2)
_, _, err = client.Actions.ListRepositoryAccessRunnerGroup(ctx, "\n", 2, opts)
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Actions.ListRepositoryAccessRunnerGroup(ctx, "o", 2)
got, resp, err := client.Actions.ListRepositoryAccessRunnerGroup(ctx, "o", 2, opts)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
Expand Down

0 comments on commit 28b6547

Please sign in to comment.