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

bump release-sdk and go-github #3377

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/goark/go-cvss v1.6.6
github.com/golang/protobuf v1.5.3
github.com/google/go-containerregistry v0.16.1
github.com/google/go-github/v53 v53.2.0
github.com/google/go-github/v56 v56.0.0
github.com/google/safetext v0.0.0-20230106111101-7156a760e523
github.com/google/uuid v1.4.0
github.com/hashicorp/go-multierror v1.1.1
Expand Down Expand Up @@ -41,7 +41,7 @@ require (
sigs.k8s.io/bom v0.5.2-0.20230519223618-1ebaa9ce375f
sigs.k8s.io/mdtoc v1.1.0
sigs.k8s.io/promo-tools/v3 v3.6.0
sigs.k8s.io/release-sdk v0.10.3
sigs.k8s.io/release-sdk v0.10.4
sigs.k8s.io/release-utils v0.7.7
sigs.k8s.io/yaml v1.4.0
)
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,10 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-containerregistry v0.16.1 h1:rUEt426sR6nyrL3gt+18ibRcvYpKYdpsa5ZW7MA08dQ=
github.com/google/go-containerregistry v0.16.1/go.mod h1:u0qB2l7mvtWVR5kNcbFIhFY1hLbf8eeGapA+vbFDCtQ=
github.com/google/go-github/v53 v53.2.0 h1:wvz3FyF53v4BK+AsnvCmeNhf8AkTaeh2SoYu/XUvTtI=
github.com/google/go-github/v53 v53.2.0/go.mod h1:XhFRObz+m/l+UCm9b7KSIC3lT3NWSXGt7mOsAWEloao=
github.com/google/go-github/v55 v55.0.0 h1:4pp/1tNMB9X/LuAhs5i0KQAE40NmiR/y6prLNb9x9cg=
github.com/google/go-github/v55 v55.0.0/go.mod h1:JLahOTA1DnXzhxEymmFF5PP2tSS9JVNj68mSZNDwskA=
github.com/google/go-github/v56 v56.0.0 h1:TysL7dMa/r7wsQi44BjqlwaHvwlFlqkK8CtBWCX3gb4=
github.com/google/go-github/v56 v56.0.0/go.mod h1:D8cdcX98YWJvi7TLo7zM4/h8ZTx6u6fwGEkCdisopo0=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down Expand Up @@ -1575,8 +1575,8 @@ sigs.k8s.io/mdtoc v1.1.0 h1:q3YtqYzmC2e0hgLXRIOm7/QLuPux1CX3ZHCwlbABxZo=
sigs.k8s.io/mdtoc v1.1.0/go.mod h1:QZLVEdHH2iNIR4uHAZyvFRtjloHgVItk8lo/mzCtq3w=
sigs.k8s.io/promo-tools/v3 v3.6.0 h1:C2L08ezrWm1aZI8Emd3iZPZQserLPRgzuqQVxvI0PUI=
sigs.k8s.io/promo-tools/v3 v3.6.0/go.mod h1:XJ3jy0hJYs+hWKt8XsLHFzGQV8PUtvllvbxjN/E5RXI=
sigs.k8s.io/release-sdk v0.10.3 h1:OUDWndR0jXex7w1g/y2TI2TDmzJB0u1AFH4U8he/WAE=
sigs.k8s.io/release-sdk v0.10.3/go.mod h1:EBZWXznKbtE6XHsdsB5lx+eGCv4gW+TuHJmnev7i//8=
sigs.k8s.io/release-sdk v0.10.4 h1:Ji75SfmHXTaZUUKteCUWEIHKJkOk8H0uxTuRdEnbBQU=
sigs.k8s.io/release-sdk v0.10.4/go.mod h1:H9TsZQFDpdAmViPe69C4OkP8vlOPZ0YUmf1dqUNiqZ4=
sigs.k8s.io/release-utils v0.7.7 h1:JKDOvhCk6zW8ipEOkpTGDH/mW3TI+XqtPp16aaQ79FU=
sigs.k8s.io/release-utils v0.7.7/go.mod h1:iU7DGVNi3umZJ8q6aHyUFzsDUIaYwNnNKGHo3YE5E3s=
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 h1:UZbZAZfX0wV2zr7YZorDz6GXROfDFj6LvqCRm4VUVKk=
Expand Down
2 changes: 1 addition & 1 deletion pkg/fastforward/fastforward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
"testing"

gogithub "github.com/google/go-github/v53/github"
gogithub "github.com/google/go-github/v56/github"
"github.com/stretchr/testify/require"
"k8s.io/release/pkg/fastforward/fastforwardfakes"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/fastforward/fastforwardfakes/fake_impl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/fastforward/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"k8s.io/release/pkg/gcp/gcb"
"k8s.io/release/pkg/release"

gogithub "github.com/google/go-github/v53/github"
gogithub "github.com/google/go-github/v56/github"
"sigs.k8s.io/release-sdk/git"
"sigs.k8s.io/release-sdk/github"
"sigs.k8s.io/release-utils/env"
Expand Down
23 changes: 13 additions & 10 deletions pkg/notes/notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"time"
"unicode"

gogithub "github.com/google/go-github/v53/github"
gogithub "github.com/google/go-github/v56/github"
"github.com/nozzle/throttler"
"github.com/sirupsen/logrus"
"golang.org/x/text/cases"
Expand Down Expand Up @@ -911,12 +911,9 @@ func canWaitAndRetry(r *gogithub.Response, err error) bool {

// prsForCommitFromSHA retrieves the PR numbers for a commit given its sha
func (g *Gatherer) prsForCommitFromSHA(sha string) (prs []*gogithub.PullRequest, err error) {
plo := &gogithub.PullRequestListOptions{
State: "closed",
ListOptions: gogithub.ListOptions{
Page: 1,
PerPage: 100,
},
plo := &gogithub.ListOptions{
Page: 1,
PerPage: 100,
}

prs = []*gogithub.PullRequest{}
Expand All @@ -936,12 +933,18 @@ func (g *Gatherer) prsForCommitFromSHA(sha string) (prs []*gogithub.PullRequest,
break
}
}
prs = append(prs, pResult...)

for _, result := range pResult {
if result.GetState() == "closed" {
prs = append(prs, result)
}
}

if resp.NextPage == 0 {
break
}
plo.ListOptions.Page++
if plo.ListOptions.Page > resp.LastPage {
plo.Page++
if plo.Page > resp.LastPage {
break
}
}
Expand Down
40 changes: 21 additions & 19 deletions pkg/notes/notes_gatherer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"sync/atomic"
"testing"

"github.com/google/go-github/v53/github"
"github.com/google/go-github/v56/github"
"github.com/sirupsen/logrus"
"sigs.k8s.io/release-sdk/git"
"sigs.k8s.io/release-sdk/github/githubfakes"
Expand Down Expand Up @@ -235,7 +235,7 @@ func TestListCommits(t *testing.T) {

func TestGatherNotes(t *testing.T) {
type getPullRequestStub func(context.Context, string, string, int) (*github.PullRequest, *github.Response, error)
type listPullRequestsWithCommitStub func(context.Context, string, string, string, *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error)
type listPullRequestsWithCommitStub func(context.Context, string, string, string, *github.ListOptions) ([]*github.PullRequest, *github.Response, error)

tests := map[string]struct {
// listPullRequestsWithCommitStubber is a function that needs to return
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestGatherNotes(t *testing.T) {
repoCommit("some-random-sha", "some-random-commit-msg"),
},
listPullRequestsWithCommitStubber: func(t *testing.T) listPullRequestsWithCommitStub {
return func(_ context.Context, org, repo, sha string, _ *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) {
return func(_ context.Context, org, repo, sha string, _ *github.ListOptions) ([]*github.PullRequest, *github.Response, error) {
checkOrgRepo(t, org, repo)
if e, a := "some-random-sha", sha; e != a {
t.Errorf("Expected ListPullRequestsWithCommit(...) to be called for SHA '%s', have been called for '%s'", e, a)
Expand Down Expand Up @@ -312,7 +312,7 @@ func TestGatherNotes(t *testing.T) {
"when GetPullRequest(...) returns an error": {
commitList: []*github.RepositoryCommit{repoCommit("some-sha", "some #123 thing")},
listPullRequestsWithCommitStubber: func(t *testing.T) listPullRequestsWithCommitStub {
return func(_ context.Context, _, _, _ string, _ *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) {
return func(_ context.Context, _, _, _ string, _ *github.ListOptions) ([]*github.PullRequest, *github.Response, error) {
return nil, nil, fmt.Errorf("some-error-from-get-pull-request")
}
},
Expand All @@ -322,7 +322,7 @@ func TestGatherNotes(t *testing.T) {
"when ListPullRequestsWithCommit(...) returns an error": {
commitList: []*github.RepositoryCommit{repoCommit("some-sha", "some-msg")},
listPullRequestsWithCommitStubber: func(t *testing.T) listPullRequestsWithCommitStub {
return func(_ context.Context, _, _, _ string, _ *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) {
return func(_ context.Context, _, _, _ string, _ *github.ListOptions) ([]*github.PullRequest, *github.Response, error) {
return nil, nil, fmt.Errorf("some-error-from-list-pull-requests-with-commit")
}
},
Expand All @@ -334,27 +334,28 @@ func TestGatherNotes(t *testing.T) {
listPullRequestsWithCommitStubber: func(t *testing.T) listPullRequestsWithCommitStub {
prsPerCall := [][]*github.PullRequest{
// explicitly excluded
{pullRequest(1, "something ```release-note\nN/a\n``` something")},
{pullRequest(2, "something ```release-note\nNa\n``` something")},
{pullRequest(3, "something ```release-note\nNone \n``` something")},
{pullRequest(4, "something ```release-note\n'None' \n``` something")},
{pullRequest(5, "something /release-note-none something")},
{pullRequest(1, "something ```release-note\nN/a\n``` something", "closed")},
{pullRequest(2, "something ```release-note\nNa\n``` something", "closed")},
{pullRequest(3, "something ```release-note\nNone \n``` something", "closed")},
{pullRequest(4, "something ```release-note\n'None' \n``` something", "closed")},
{pullRequest(5, "something /release-note-none something", "closed")},
// multiple PRs
{ // first does no match, second one matches, rest is ignored
pullRequest(6, ""),
pullRequest(7, " something ```release-note\nTest\n``` something"),
pullRequest(8, "does-not-matter--is-not-considered"),
pullRequest(6, "", "closed"),
pullRequest(7, " something ```release-note\nTest\n``` something", "closed"),
pullRequest(8, "does-not-matter--is-not-considered", "closed"),
},
// some other strange things
{pullRequest(9, "release-note /release-note-none")}, // excluded, the exclusion filters take precedence
{pullRequest(10, "```release-note\nNAAAAAAAAAA\n```")}, // included, does not match the N/A filter, but the 'release-note' check
{pullRequest(11, "```release-note\nnone something\n```")}, // included, does not match the N/A filter, but the 'release-note' check
{pullRequest(9, "release-note /release-note-none", "closed")}, // excluded, the exclusion filters take precedence
{pullRequest(10, "```release-note\nNAAAAAAAAAA\n```", "closed")}, // included, does not match the N/A filter, but the 'release-note' check
{pullRequest(11, "```release-note\nnone something\n```", "closed")}, // included, does not match the N/A filter, but the 'release-note' check
// empty release note block shouldn't be matched
{pullRequest(12, "```release-note\n\n```")},
{pullRequest(12, "```release-note\n\n```", "closed")},
{pullRequest(13, "```release-note\n\n```", "open")},
}
var callCount int64 = -1

return func(_ context.Context, _, _, _ string, _ *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) {
return func(_ context.Context, _, _, _ string, _ *github.ListOptions) ([]*github.PullRequest, *github.Response, error) {
callCount := int(atomic.AddInt64(&callCount, 1))
if a, e := callCount+1, len(prsPerCall); a > e {
return nil, &github.Response{}, nil
Expand Down Expand Up @@ -407,10 +408,11 @@ func TestGatherNotes(t *testing.T) {
}
}

func pullRequest(id int, msg string) *github.PullRequest {
func pullRequest(id int, msg, state string) *github.PullRequest {
return &github.PullRequest{
Body: strPtr(msg),
Number: intPtr(id),
State: strPtr(state),
}
}

Expand Down