Exemple #1
0
// This is called on a potentially mergeable PR
func (e *e2eTester) runE2ETests(client *github_api.Client, pr *github_api.PullRequest, issue *github_api.Issue) error {
	e.locked(func() { e.state.CurrentPR = pr })
	defer e.locked(func() { e.state.CurrentPR = nil })
	e.msg("Considering PR %d", *pr.Number)

	e.waitForStableBuilds()

	// if there is a 'e2e-not-required' label, just merge it.
	if len(*dontRequireE2E) > 0 && github.HasLabel(issue.Labels, *dontRequireE2E) {
		e.msg("Merging %d since %s is set", *pr.Number, *dontRequireE2E)
		return e.merge(client, org, project, pr)
	}
	// Ask for a fresh build
	e.msg("Asking PR builder to build %d", *pr.Number)
	body := "@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]"
	if _, _, err := client.Issues.CreateComment(org, project, *pr.Number, &github_api.IssueComment{Body: &body}); err != nil {
		e.error(err)
		return err
	}

	// Wait for the build to start
	err := github.WaitForPending(client, org, project, *pr.Number)

	// Wait for the status to go back to 'success'
	ok, err := github.ValidateStatus(client, org, project, *pr.Number, []string{}, true)
	if err != nil {
		e.error(err)
		return err
	}
	if !ok {
		e.msg("Status after build is not 'success', skipping PR %d", *pr.Number)
		return nil
	}
	return e.merge(client, org, project, pr)
}
Exemple #2
0
// This is called on a potentially mergeable PR
func (e *e2eTester) runE2ETests(client *github_api.Client, pr *github_api.PullRequest, issue *github_api.Issue) error {
	func() {
		e.Lock()
		defer e.Unlock()
		e.CurrentPR = pr
	}()
	// Test if the build is stable in Jenkins
	jenkinsClient := &jenkins.JenkinsClient{Host: *jenkinsHost}
	builds := strings.Split(*jobs, ",")
	for _, build := range builds {
		stable, err := jenkinsClient.IsBuildStable(build)
		e.msg(fmt.Sprintf("Checking build stability for %s", build))
		if err != nil {
			e.error(err)
			return err
		}
		if !stable {
			glog.Errorf("Build %s isn't stable, skipping!", build)
			err := errors.New("Unstable build")
			e.error(err)
			return err
		}
	}
	e.msg("Build is stable.")
	// if there is a 'safe-to-merge' label, just merge it.
	if len(*dontRequireE2E) > 0 && github.HasLabel(issue.Labels, *dontRequireE2E) {
		e.msg(fmt.Sprintf("Merging %d since %s is set", *pr.Number, *dontRequireE2E))
		return e.merge(client, org, project, pr)
	}
	// Ask for a fresh build
	e.msg(fmt.Sprintf("Asking PR builder to build %d", *pr.Number))
	body := "@k8s-bot test this [testing build queue, sorry for the noise]"
	if _, _, err := client.Issues.CreateComment(org, project, *pr.Number, &github_api.IssueComment{Body: &body}); err != nil {
		e.error(err)
		return err
	}

	// Wait for the build to start
	err := github.WaitForPending(client, org, project, *pr.Number)

	// Wait for the status to go back to 'success'
	ok, err := github.ValidateStatus(client, org, project, *pr.Number, []string{}, true)
	if err != nil {
		e.error(err)
		return err
	}
	if !ok {
		e.msg(fmt.Sprintf("Status after build is not 'success', skipping PR %d", *pr.Number))
		return nil
	}
	return e.merge(client, org, project, pr)
}