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

chore,prow: update prow and test-infra dependencies #3888

Merged
merged 5 commits into from
Jan 21, 2025
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ all: deps-update $(limiter) $(flake-report-writer) $(querier) $(kubevirtci) $(fl

clean: install-metrics-binaries
golangci-lint cache clean
go clean -cache -modcache

$(limiter) $(flake-report-writer) $(querier) $(kubevirtci) $(flake-issue-creator): deps-update
$(MAKE) --directory=$@
Expand Down
17 changes: 11 additions & 6 deletions external-plugins/botreview/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
"fmt"
"github.com/sirupsen/logrus"
"k8s.io/test-infra/pkg/flagutil"
"k8s.io/test-infra/prow/config/secret"
prowflagutil "k8s.io/test-infra/prow/flagutil"
"k8s.io/test-infra/prow/interrupts"
"k8s.io/test-infra/prow/pluginhelp/externalplugins"
"kubevirt.io/project-infra/external-plugins/botreview/server"
"net/http"
"os"
"sigs.k8s.io/prow/pkg/config/secret"
prowflagutil "sigs.k8s.io/prow/pkg/flagutil"
"sigs.k8s.io/prow/pkg/interrupts"
"sigs.k8s.io/prow/pkg/pluginhelp/externalplugins"
"strconv"
"time"
)
Expand Down Expand Up @@ -86,8 +86,13 @@ func main() {
logrus.WithError(err).Fatal("Error starting secrets agent.")
}

githubClient := o.github.GitHubClientWithAccessToken(string(secret.GetSecret(o.github.TokenPath)))
gitClient, err := o.github.GitClient(o.dryRun)
githubClient, err := o.github.GitHubClientWithAccessToken(string(secret.GetSecret(o.github.TokenPath)))
if err != nil {
logrus.WithError(err).Fatal("Error getting GitHub client.")
}
// TODO: check setup ok
cacheDir := ""
gitClient, err := o.github.GitClientFactory("", &cacheDir, o.dryRun, false)
if err != nil {
logrus.WithError(err).Fatal("Error getting Git client.")
}
Expand Down
8 changes: 4 additions & 4 deletions external-plugins/botreview/review/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
"fmt"
"github.com/sirupsen/logrus"
"github.com/sourcegraph/go-diff/diff"
"k8s.io/test-infra/prow/git"
"k8s.io/test-infra/prow/github"
"os/exec"
gitv2 "sigs.k8s.io/prow/pkg/git/v2"
"sigs.k8s.io/prow/pkg/github"
"strings"
)

Expand Down Expand Up @@ -222,9 +222,9 @@ type PRReviewOptions struct {
Repo string
}

func PreparePullRequestReview(gitClient *git.Client, prReviewOptions PRReviewOptions, githubClient github.Client) (*github.PullRequest, string, error) {
func PreparePullRequestReview(gitClient gitv2.ClientFactory, prReviewOptions PRReviewOptions, githubClient github.Client) (*github.PullRequest, string, error) {
// checkout repo to a temporary directory to have it reviewed
clone, err := gitClient.Clone(prReviewOptions.Org, prReviewOptions.Repo)
clone, err := gitClient.ClientFor(prReviewOptions.Org, prReviewOptions.Repo)
if err != nil {
logrus.WithError(err).Fatal("error cloning repo")
}
Expand Down
2 changes: 1 addition & 1 deletion external-plugins/botreview/review/review_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
testdiff "github.com/andreyvit/diff"
"github.com/sirupsen/logrus"
"github.com/sourcegraph/go-diff/diff"
"k8s.io/test-infra/prow/github"
"os"
"reflect"
"sigs.k8s.io/prow/pkg/github"
"testing"
)

Expand Down
10 changes: 5 additions & 5 deletions external-plugins/botreview/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ package server
import (
"encoding/json"
"github.com/sirupsen/logrus"
"k8s.io/test-infra/prow/config"
"k8s.io/test-infra/prow/git"
"k8s.io/test-infra/prow/github"
"k8s.io/test-infra/prow/pluginhelp"
"kubevirt.io/project-infra/external-plugins/botreview/review"
"net/http"
"os"
"sigs.k8s.io/prow/pkg/config"
gitv2 "sigs.k8s.io/prow/pkg/git/v2"
"sigs.k8s.io/prow/pkg/github"
"sigs.k8s.io/prow/pkg/pluginhelp"
)

const pluginName = "botreview"
Expand Down Expand Up @@ -66,7 +66,7 @@ type Server struct {
TokenGenerator func() []byte
BotName string

GitClient *git.Client
GitClient gitv2.ClientFactory
Ghc github.Client

Log *logrus.Entry
Expand Down
29 changes: 18 additions & 11 deletions external-plugins/phased/plugin/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
pi_github "kubevirt.io/project-infra/robots/pkg/github"
"net/http"
"os"
"os/exec"

"github.com/sirupsen/logrus"
"k8s.io/test-infra/prow/config"
gitv2 "k8s.io/test-infra/prow/git/v2"
"k8s.io/test-infra/prow/github"
"k8s.io/test-infra/prow/labels"
"k8s.io/test-infra/prow/pjutil"
"sigs.k8s.io/prow/pkg/config"
gitv2 "sigs.k8s.io/prow/pkg/git/v2"
"sigs.k8s.io/prow/pkg/github"
"sigs.k8s.io/prow/pkg/labels"
"sigs.k8s.io/prow/pkg/pjutil"
)

var log *logrus.Logger
Expand Down Expand Up @@ -101,7 +102,7 @@ func (h *GitHubEventsHandler) handlePullRequestEvent(log *logrus.Entry, event *g
return
}

org, repo, err := gitv2.OrgRepo(event.Repo.FullName)
org, repo, err := pi_github.OrgRepo(event.Repo.FullName)
if err != nil {
log.WithError(err).Errorf("Could not get org/repo from the event")
return
Expand Down Expand Up @@ -152,7 +153,7 @@ func (h *GitHubEventsHandler) loadPresubmits(pr github.PullRequest) ([]config.Pr
return nil, err
}

org, repo, err := gitv2.OrgRepo(pr.Base.Repo.FullName)
org, repo, err := pi_github.OrgRepo(pr.Base.Repo.FullName)
if err != nil {
log.WithError(err).Errorf("Could not parse repo name: %s", pr.Base.Repo.FullName)
return nil, err
Expand Down Expand Up @@ -245,22 +246,28 @@ func listRequiredManual(ghClient githubClientInterface, pr github.PullRequest, p

org, repo, number, branch := pr.Base.Repo.Owner.Login, pr.Base.Repo.Name, pr.Number, pr.Base.Ref
changes := config.NewGitHubDeferredChangedFilesProvider(ghClient, org, repo, number)
toTest, err := pjutil.FilterPresubmits(manualRequiredFilter, changes, branch, presubmits, log)
toTest, err := pjutil.FilterPresubmits(defaultManualRequiredFilter, changes, branch, presubmits, log)
if err != nil {
return nil, err
}

return toTest, nil
}

func manualRequiredFilter(p config.Presubmit) (bool, bool, bool) {
var defaultManualRequiredFilter = manualRequiredFilter{}

type manualRequiredFilter struct{}

func (f manualRequiredFilter) ShouldRun(p config.Presubmit) (shouldRun bool, forcedToRun bool, defaultBehavior bool) {
cond := !p.Optional && !p.AlwaysRun && p.RegexpChangeMatcher.RunIfChanged == "" &&
p.RegexpChangeMatcher.SkipIfOnlyChanged == ""
return cond, cond, false
}

func (f manualRequiredFilter) Name() string { return "manualRequiredFilter" }

func testRequested(ghClient githubClientInterface, pr github.PullRequest, requestedJobs []config.Presubmit) error {
org, repo, err := gitv2.OrgRepo(pr.Base.Repo.FullName)
org, repo, err := pi_github.OrgRepo(pr.Base.Repo.FullName)
if err != nil {
log.WithError(err).Errorf("Could not parse repo name: %s", pr.Base.Repo.FullName)
return err
Expand Down Expand Up @@ -336,7 +343,7 @@ func (h *GitHubEventsHandler) loadProwConfig(prFullName string) (*config.Config,
}
defer os.RemoveAll(tmpdir)

org, repo, err := gitv2.OrgRepo(prFullName)
org, repo, err := pi_github.OrgRepo(prFullName)
if err != nil {
log.WithError(err).Errorf("Could not parse repo name: %s", prFullName)
return nil, err
Expand Down
14 changes: 7 additions & 7 deletions external-plugins/phased/plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import (
"os"
"time"

"k8s.io/test-infra/prow/config"
"k8s.io/test-infra/prow/pluginhelp"
"sigs.k8s.io/prow/pkg/config"
"sigs.k8s.io/prow/pkg/pluginhelp"

"kubevirt.io/project-infra/external-plugins/phased/plugin/handler"

"github.com/sirupsen/logrus"
"k8s.io/test-infra/pkg/flagutil"
"k8s.io/test-infra/prow/config/secret"
prowflagutil "k8s.io/test-infra/prow/flagutil"
"k8s.io/test-infra/prow/git/v2"
"k8s.io/test-infra/prow/interrupts"
"k8s.io/test-infra/prow/pluginhelp/externalplugins"
"sigs.k8s.io/prow/pkg/config/secret"
prowflagutil "sigs.k8s.io/prow/pkg/flagutil"
"sigs.k8s.io/prow/pkg/git/v2"
"sigs.k8s.io/prow/pkg/interrupts"
"sigs.k8s.io/prow/pkg/pluginhelp/externalplugins"

"kubevirt.io/project-infra/external-plugins/phased/plugin/server"
)
Expand Down
12 changes: 6 additions & 6 deletions external-plugins/phased/plugin/phased_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
. "github.com/onsi/gomega"
"github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
"k8s.io/test-infra/prow/config"
"k8s.io/test-infra/prow/git/localgit"
git2 "k8s.io/test-infra/prow/git/v2"
"k8s.io/test-infra/prow/github"
"k8s.io/test-infra/prow/github/fakegithub"
"k8s.io/test-infra/prow/labels"
"sigs.k8s.io/prow/pkg/config"
"sigs.k8s.io/prow/pkg/git/localgit"
git2 "sigs.k8s.io/prow/pkg/git/v2"
"sigs.k8s.io/prow/pkg/github"
"sigs.k8s.io/prow/pkg/github/fakegithub"
"sigs.k8s.io/prow/pkg/labels"

"kubevirt.io/project-infra/external-plugins/phased/plugin/handler"
)
Expand Down
2 changes: 1 addition & 1 deletion external-plugins/phased/plugin/server/eventsserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package server
import (
"net/http"

"k8s.io/test-infra/prow/github"
"kubevirt.io/project-infra/external-plugins/phased/plugin/handler"
"sigs.k8s.io/prow/pkg/github"
)

type GitHubEventsServer struct {
Expand Down
13 changes: 8 additions & 5 deletions external-plugins/referee/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ import (
"github.com/sirupsen/logrus"
"golang.org/x/oauth2"
"k8s.io/test-infra/pkg/flagutil"
"k8s.io/test-infra/prow/config/secret"
prowflagutil "k8s.io/test-infra/prow/flagutil"
"k8s.io/test-infra/prow/interrupts"
"k8s.io/test-infra/prow/pluginhelp/externalplugins"
"kubevirt.io/project-infra/external-plugins/referee/ghgraphql"
"kubevirt.io/project-infra/external-plugins/referee/metrics"
"kubevirt.io/project-infra/external-plugins/referee/server"
"net/http"
"os"
"regexp"
"sigs.k8s.io/prow/pkg/config/secret"
prowflagutil "sigs.k8s.io/prow/pkg/flagutil"
"sigs.k8s.io/prow/pkg/interrupts"
"sigs.k8s.io/prow/pkg/pluginhelp/externalplugins"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -119,7 +119,10 @@ func main() {
logrus.WithError(err).Fatal("Error starting secrets agent.")
}

githubClient := o.github.GitHubClientWithAccessToken(string(secret.GetSecret(o.github.TokenPath)))
githubClient, err := o.github.GitHubClientWithAccessToken(string(secret.GetSecret(o.github.TokenPath)))
if err != nil {
logrus.WithError(err).Fatal("error getting github client")
}

botUserData, err := githubClient.BotUser()
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions external-plugins/referee/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import (
"fmt"
"github.com/sirupsen/logrus"
"html/template"
"k8s.io/test-infra/prow/config"
"k8s.io/test-infra/prow/github"
"k8s.io/test-infra/prow/pjutil"
"k8s.io/test-infra/prow/pluginhelp"
"kubevirt.io/project-infra/external-plugins/referee/ghgraphql"
"kubevirt.io/project-infra/external-plugins/referee/metrics"
"net/http"
"sigs.k8s.io/prow/pkg/config"
"sigs.k8s.io/prow/pkg/github"
"sigs.k8s.io/prow/pkg/pjutil"
"sigs.k8s.io/prow/pkg/pluginhelp"
)

const PluginName = "referee"
Expand Down
2 changes: 1 addition & 1 deletion external-plugins/referee/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
. "github.com/onsi/gomega"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/mock"
"k8s.io/test-infra/prow/github"
"kubevirt.io/project-infra/external-plugins/referee/ghgraphql"
"sigs.k8s.io/prow/pkg/github"
)

const (
Expand Down
28 changes: 15 additions & 13 deletions external-plugins/rehearse/plugin/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/r3labs/diff/v3"
"io/ioutil"
"k8s.io/test-infra/prow/repoowners"
"os"
"os/exec"
"path"
Expand All @@ -15,18 +13,22 @@ import (
"strconv"
"strings"

"github.com/r3labs/diff/v3"
pi_github "kubevirt.io/project-infra/robots/pkg/github"
"sigs.k8s.io/prow/pkg/repoowners"

"github.com/go-git/go-git/v5"
gitconfig "github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
prowapi "k8s.io/test-infra/prow/apis/prowjobs/v1"
v1 "k8s.io/test-infra/prow/client/clientset/versioned/typed/prowjobs/v1"
"k8s.io/test-infra/prow/config"
gitv2 "k8s.io/test-infra/prow/git/v2"
"k8s.io/test-infra/prow/github"
"k8s.io/test-infra/prow/pjutil"
prowapi "sigs.k8s.io/prow/pkg/apis/prowjobs/v1"
v1 "sigs.k8s.io/prow/pkg/client/clientset/versioned/typed/prowjobs/v1"
"sigs.k8s.io/prow/pkg/config"
gitv2 "sigs.k8s.io/prow/pkg/git/v2"
"sigs.k8s.io/prow/pkg/github"
"sigs.k8s.io/prow/pkg/pjutil"
)

const basicHelpCommentText = `You can trigger rehearsal for all jobs by commenting either ` + "`/rehearse`" + ` or ` + "`/rehearse all`" + `
Expand Down Expand Up @@ -138,7 +140,7 @@ func (h *GitHubEventsHandler) handleIssueComment(log *logrus.Entry, event *githu
return
}

org, repo, err := gitv2.OrgRepo(event.Repo.FullName)
org, repo, err := pi_github.OrgRepo(event.Repo.FullName)
if err != nil {
log.WithError(err).Errorf("Could not get org/repo from the event")
}
Expand Down Expand Up @@ -299,7 +301,7 @@ func (h *GitHubEventsHandler) handlePullRequestUpdateEvent(log *logrus.Entry, ev
return
}

org, repo, err := gitv2.OrgRepo(event.Repo.FullName)
org, repo, err := pi_github.OrgRepo(event.Repo.FullName)
if err != nil {
log.WithError(err).Errorf("Could not get org/repo from the event")
}
Expand Down Expand Up @@ -335,7 +337,7 @@ func (h *GitHubEventsHandler) handlePullRequestUpdateEvent(log *logrus.Entry, ev
}

func (h *GitHubEventsHandler) handleRehearsalForPR(log *logrus.Entry, pr *github.PullRequest, eventGUID string, commentBody string) {
org, repo, err := gitv2.OrgRepo(pr.Base.Repo.FullName)
org, repo, err := pi_github.OrgRepo(pr.Base.Repo.FullName)
if err != nil {
log.WithError(err).Errorf("Could not parse repo name: %s", pr.Base.Repo.FullName)
return
Expand Down Expand Up @@ -456,7 +458,7 @@ func (h *GitHubEventsHandler) getRebasedRepoClient(log *logrus.Entry, pr *github
if err != nil {
return nil, fmt.Errorf("could not change repo config: %w", err)
}
err = rebasedRepoClient.MergeAndCheckout(pr.Base.SHA, string(github.MergeSquash), pr.Head.SHA)
err = rebasedRepoClient.MergeAndCheckout(pr.Base.SHA, "squash", pr.Head.SHA)
if err != nil {
return nil, fmt.Errorf("could not rebase the PR on the target branch: %w", err)
}
Expand Down Expand Up @@ -562,7 +564,7 @@ func (h *GitHubEventsHandler) generatePresubmits(
}

repoOrg := repoFromJobKey(presubmitKey)
org, repo, err := gitv2.OrgRepo(repoOrg)
org, repo, err := pi_github.OrgRepo(repoOrg)
if err != nil {
log.Errorf(
"Could not extract repo and org from job key: %s. Job name: %s",
Expand Down
Loading