diff --git a/Makefile b/Makefile index 4e37b1a575..2a87f19f67 100644 --- a/Makefile +++ b/Makefile @@ -747,9 +747,9 @@ site: site/themes/docsy/assets/vendor/bootstrap/package.js out/hugo/hugo ## Serv out/mkcmp: GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $@ cmd/performance/mkcmp/main.go -.PHONY: out/performance-monitor -out/performance-monitor: - GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $@ cmd/performance/monitor/monitor.go +.PHONY: out/performance-bot +out/performance-bot: + GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $@ cmd/performance/pr-bot/bot.go .PHONY: compare compare: out/mkcmp out/minikube diff --git a/cmd/performance/pr-bot/bot.go b/cmd/performance/pr-bot/bot.go index 2614ea6884..340c4ef8f4 100644 --- a/cmd/performance/pr-bot/bot.go +++ b/cmd/performance/pr-bot/bot.go @@ -20,10 +20,10 @@ import ( "context" "fmt" "log" - "os" "time" "github.com/pkg/errors" + "k8s.io/minikube/pkg/perf/monitor" ) func main() { @@ -41,20 +41,15 @@ func main() { // 2. running mkcmp against those PRs // 3. commenting results on those PRs func analyzePerformance(ctx context.Context) error { - logsFile := "/home/performance-monitor/logs.txt" - if _, err := os.Stat(logsFile); err != nil { - return err - } - client := monitor.NewClient(context.Background(), "kubernetes", "minikube") - prs, err := client.ListOpenPRsWithLabel("") + client := monitor.NewClient(ctx, monitor.GithubOwner, monitor.GithubRepo) + prs, err := client.ListOpenPRsWithLabel(monitor.OkToTestLabel) if err != nil { return errors.Wrap(err, "listing open prs") } log.Print("got prs:", prs) - // TODO: priyawadhwa@ for each PR we should comment the error if we get one? for _, pr := range prs { log.Printf("~~~ Analyzing PR %d ~~~", pr) - newCommitsExist, err := client.NewCommitsExist(pr, "minikube-pr-bot") + newCommitsExist, err := client.NewCommitsExist(pr, monitor.BotName) if err != nil { return err } @@ -62,13 +57,12 @@ func analyzePerformance(ctx context.Context) error { log.Println("New commits don't exist, skipping rerun...") continue } - // TODO: priyawadhwa@ we should download mkcmp for each run? var message string message, err = monitor.RunMkcmp(ctx, pr) if err != nil { message = fmt.Sprintf("Error: %v\n%s", err, message) } - log.Printf("got message for pr %d:\n%s\n", pr, message) + log.Printf("message for pr %d:\n%s\n", pr, message) if err := client.CommentOnPR(pr, message); err != nil { return err } diff --git a/pkg/perf/monitor/constants.go b/pkg/perf/monitor/constants.go index 0221374464..be4a0011ab 100644 --- a/pkg/perf/monitor/constants.go +++ b/pkg/perf/monitor/constants.go @@ -21,4 +21,5 @@ const ( OkToTestLabel = "ok-to-test" GithubOwner = "kubernetes" GithubRepo = "minikube" + BotName = "minikube-pr-bot" ) diff --git a/pkg/perf/monitor/github.go b/pkg/perf/monitor/github.go index 18afdbb580..c50f9f1563 100644 --- a/pkg/perf/monitor/github.go +++ b/pkg/perf/monitor/github.go @@ -78,7 +78,7 @@ func (g *Client) ListOpenPRsWithLabel(label string) ([]int, error) { return nil, errors.Wrap(err, "listing pull requests") } for _, pr := range prs { - if prContainsLabel(pr.Labels, "ok-to-test") { + if prContainsLabel(pr.Labels, label) { validPrs = append(validPrs, pr.GetNumber()) } }