Exemple #1
0
func main() {
	flag.Parse()
	if len(*userWhitelist) == 0 {
		glog.Fatalf("--user-whitelist is required.")
	}
	if len(*jenkinsHost) == 0 {
		glog.Fatalf("--jenkins-host is required.")
	}
	client := github.MakeClient(*token)

	users, err := loadWhitelist(*userWhitelist)
	if err != nil {
		glog.Fatalf("error loading user whitelist: %v", err)
	}
	requiredContexts := strings.Split(*requiredContexts, ",")
	config := &github.FilterConfig{
		MinPRNumber:            *minPRNumber,
		UserWhitelist:          users,
		RequiredStatusContexts: requiredContexts,
		WhitelistOverride:      *whitelistOverride,
	}
	for !*oneOff {
		if err := github.ForEachCandidatePRDo(client, org, project, runE2ETests, *oneOff, config); err != nil {
			glog.Fatalf("Error getting candidate PRs: %v", err)
		}
	}
}
Exemple #2
0
func main() {
	flag.Parse()
	if len(*org) == 0 {
		glog.Fatalf("--organization is required.")
	}
	if len(*project) == 0 {
		glog.Fatalf("--project is required.")
	}
	tokenData := *token
	if len(tokenData) == 0 && len(*tokenFile) != 0 {
		data, err := ioutil.ReadFile(*tokenFile)
		if err != nil {
			glog.Fatalf("error reading token file: %v", err)
		}
		tokenData = string(data)
	}
	client := github.MakeClient(tokenData)

	if len(*issueMungers) > 0 {
		glog.Infof("Running issue mungers")
		if err := issues.MungeIssues(client, *issueMungers, *org, *project, *minIssueNumber, *dryrun); err != nil {
			glog.Errorf("Error munging issues: %v", err)
		}
	}
	if len(*prMungers) > 0 {
		glog.Infof("Running PR mungers")
		if err := pulls.MungePullRequests(client, *prMungers, *org, *project, *minPRNumber, *dryrun); err != nil {
			glog.Errorf("Error munging PRs: %v", err)
		}
	}
}
Exemple #3
0
func main() {
	flag.Parse()
	if len(*jenkinsHost) == 0 {
		glog.Fatalf("--jenkins-host is required.")
	}
	tokenData := *token
	if len(tokenData) == 0 && len(*tokenFile) != 0 {
		data, err := ioutil.ReadFile(*tokenFile)
		if err != nil {
			glog.Fatalf("error reading token file: %v", err)
		}
		tokenData = string(data)
	}

	client := github.MakeClient(tokenData)

	users, err := loadWhitelist(*userWhitelist)
	if err != nil {
		glog.Fatalf("error loading user whitelist: %v", err)
	}
	requiredContexts := strings.Split(*requiredContexts, ",")
	config := &github.FilterConfig{
		MinPRNumber:             *minPRNumber,
		AdditionalUserWhitelist: users,
		RequiredStatusContexts:  requiredContexts,
		WhitelistOverride:       *whitelistOverride,
		DryRun:                  *dryrun,
		DontRequireE2ELabel:     *dontRequireE2E,
		E2EStatusContext:        *e2eStatusContext,
	}
	e2e := &e2eTester{}
	if len(*address) > 0 {
		go http.ListenAndServe(*address, e2e)
	}
	for !*oneOff {
		if err := github.ForEachCandidatePRDo(client, org, project, e2e.runE2ETests, *oneOff, config); err != nil {
			glog.Errorf("Error getting candidate PRs: %v", err)
		}
		time.Sleep(*pollPeriod)
	}
}
Exemple #4
0
func main() {
	flag.Parse()
	if len(o.Org) == 0 {
		glog.Fatalf("--organization is required.")
	}
	if len(o.Project) == 0 {
		glog.Fatalf("--project is required.")
	}
	tokenData := *token
	if len(tokenData) == 0 && len(*tokenFile) != 0 {
		data, err := ioutil.ReadFile(*tokenFile)
		if err != nil {
			glog.Fatalf("error reading token file: %v", err)
		}
		tokenData = string(data)
	}
	client := github.MakeClient(tokenData)

	if len(*issueMungers) == 0 && len(*prMungers) == 0 {
		glog.Fatalf("must include at least one --issue-mungers or --pr-mungers")
	}
	for {
		if len(*issueMungers) > 0 {
			glog.Infof("Running issue mungers")
			if err := issues.MungeIssues(client, *issueMungers, o); err != nil {
				glog.Errorf("Error munging issues: %v", err)
			}
		}
		if len(*prMungers) > 0 {
			glog.Infof("Running PR mungers")
			if err := pulls.MungePullRequests(client, *prMungers, o); err != nil {
				glog.Errorf("Error munging PRs: %v", err)
			}
		}
		if *oneOff {
			break
		}
		time.Sleep(*period)
	}
}
Exemple #5
0
func main() {
	flag.Parse()
	if len(*org) == 0 {
		glog.Fatalf("--organization is required.")
	}
	if len(*project) == 0 {
		glog.Fatalf("--project is required.")
	}
	client := github.MakeClient(*token)

	if len(*issueMungers) > 0 {
		glog.Infof("Running issue mungers")
		if err := issues.MungeIssues(client, *issueMungers, *org, *project, *minIssueNumber, *dryrun); err != nil {
			glog.Errorf("Error munging issues: %v", err)
		}
	}
	if len(*prMungers) > 0 {
		glog.Infof("Running PR mungers")
		if err := pulls.MungePullRequests(client, *prMungers, *org, *project, *minPRNumber, *dryrun); err != nil {
			glog.Errorf("Error munging PRs: %v", err)
		}
	}
}
Exemple #6
0
func main() {
	flag.Parse()
	tokenData := *token
	if len(tokenData) == 0 && len(*tokenFile) != 0 {
		data, err := ioutil.ReadFile(*tokenFile)
		if err != nil {
			glog.Fatalf("error reading token file: %v", err)
		}
		tokenData = string(data)
	}

	client := github.MakeClient(tokenData)

	if *genCommitters {
		doGenCommitters(client)
	}

	if len(*jenkinsHost) == 0 {
		glog.Fatalf("--jenkins-host is required.")
	}

	users, err := loadWhitelist(*userWhitelist)
	if err != nil {
		glog.Fatalf("error loading user whitelist: %v", err)
	}
	committerList, err := loadWhitelist(*committers)
	if err != nil {
		glog.Fatalf("error loading committers whitelist: %v", err)
	}
	requiredContexts := strings.Split(*requiredContexts, ",")
	config := &github.FilterConfig{
		MinPRNumber:             *minPRNumber,
		AdditionalUserWhitelist: users,
		Committers:              committerList,
		RequiredStatusContexts:  requiredContexts,
		WhitelistOverride:       *whitelistOverride,
		DryRun:                  *dryrun,
		DontRequireE2ELabel:     *dontRequireE2E,
		E2EStatusContext:        *e2eStatusContext,
	}
	e2e := &e2eTester{
		BuildStatus: map[string]string{},
		Config:      config,
		state:       &ExternalState{},
	}
	if len(*address) > 0 {
		if len(*www) > 0 {
			http.Handle("/", http.FileServer(http.Dir(*www)))
		}
		http.Handle("/api", e2e)
		go http.ListenAndServe(*address, nil)
	}
	for !*oneOff {
		e2e.msg("Beginning PR scan...")
		wl := config.RefreshWhitelist(client, org, project)
		e2e.locked(func() { e2e.state.Whitelist = wl.List() })
		if err := github.ForEachCandidatePRDo(client, org, project, e2e.runE2ETests, *oneOff, config); err != nil {
			glog.Errorf("Error getting candidate PRs: %v", err)
		}
		time.Sleep(*pollPeriod)
	}
}