Fix Makefile rule to build bot

pull/9308/head
Priya Wadhwa 2020-09-22 13:56:53 -04:00
parent 3f44d470eb
commit 3d547a937f
4 changed files with 10 additions and 15 deletions

View File

@ -747,9 +747,9 @@ site: site/themes/docsy/assets/vendor/bootstrap/package.js out/hugo/hugo ## Serv
out/mkcmp: out/mkcmp:
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $@ cmd/performance/mkcmp/main.go GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $@ cmd/performance/mkcmp/main.go
.PHONY: out/performance-monitor .PHONY: out/performance-bot
out/performance-monitor: out/performance-bot:
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $@ cmd/performance/monitor/monitor.go GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $@ cmd/performance/pr-bot/bot.go
.PHONY: compare .PHONY: compare
compare: out/mkcmp out/minikube compare: out/mkcmp out/minikube

View File

@ -20,10 +20,10 @@ import (
"context" "context"
"fmt" "fmt"
"log" "log"
"os"
"time" "time"
"github.com/pkg/errors" "github.com/pkg/errors"
"k8s.io/minikube/pkg/perf/monitor"
) )
func main() { func main() {
@ -41,20 +41,15 @@ func main() {
// 2. running mkcmp against those PRs // 2. running mkcmp against those PRs
// 3. commenting results on those PRs // 3. commenting results on those PRs
func analyzePerformance(ctx context.Context) error { func analyzePerformance(ctx context.Context) error {
logsFile := "/home/performance-monitor/logs.txt" client := monitor.NewClient(ctx, monitor.GithubOwner, monitor.GithubRepo)
if _, err := os.Stat(logsFile); err != nil { prs, err := client.ListOpenPRsWithLabel(monitor.OkToTestLabel)
return err
}
client := monitor.NewClient(context.Background(), "kubernetes", "minikube")
prs, err := client.ListOpenPRsWithLabel("")
if err != nil { if err != nil {
return errors.Wrap(err, "listing open prs") return errors.Wrap(err, "listing open prs")
} }
log.Print("got prs:", prs) log.Print("got prs:", prs)
// TODO: priyawadhwa@ for each PR we should comment the error if we get one?
for _, pr := range prs { for _, pr := range prs {
log.Printf("~~~ Analyzing PR %d ~~~", pr) log.Printf("~~~ Analyzing PR %d ~~~", pr)
newCommitsExist, err := client.NewCommitsExist(pr, "minikube-pr-bot") newCommitsExist, err := client.NewCommitsExist(pr, monitor.BotName)
if err != nil { if err != nil {
return err return err
} }
@ -62,13 +57,12 @@ func analyzePerformance(ctx context.Context) error {
log.Println("New commits don't exist, skipping rerun...") log.Println("New commits don't exist, skipping rerun...")
continue continue
} }
// TODO: priyawadhwa@ we should download mkcmp for each run?
var message string var message string
message, err = monitor.RunMkcmp(ctx, pr) message, err = monitor.RunMkcmp(ctx, pr)
if err != nil { if err != nil {
message = fmt.Sprintf("Error: %v\n%s", err, message) 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 { if err := client.CommentOnPR(pr, message); err != nil {
return err return err
} }

View File

@ -21,4 +21,5 @@ const (
OkToTestLabel = "ok-to-test" OkToTestLabel = "ok-to-test"
GithubOwner = "kubernetes" GithubOwner = "kubernetes"
GithubRepo = "minikube" GithubRepo = "minikube"
BotName = "minikube-pr-bot"
) )

View File

@ -78,7 +78,7 @@ func (g *Client) ListOpenPRsWithLabel(label string) ([]int, error) {
return nil, errors.Wrap(err, "listing pull requests") return nil, errors.Wrap(err, "listing pull requests")
} }
for _, pr := range prs { for _, pr := range prs {
if prContainsLabel(pr.Labels, "ok-to-test") { if prContainsLabel(pr.Labels, label) {
validPrs = append(validPrs, pr.GetNumber()) validPrs = append(validPrs, pr.GetNumber())
} }
} }