// Munge is the workhorse the will actually make updates to the PR func (StalePendingCI) Munge(obj *github.MungeObject) { requiredContexts := []string{jenkinsUnitContext, jenkinsE2EContext} if !obj.IsPR() { return } if !obj.HasLabel(lgtmLabel) { return } if mergeable, err := obj.IsMergeable(); !mergeable || err != nil { return } status := obj.GetStatusState(requiredContexts) if status != "pending" { return } for _, context := range requiredContexts { statusTime := obj.GetStatusTime(context) if statusTime == nil { glog.Errorf("%d: unable to determine time %q context was set", *obj.Issue.Number, context) return } if time.Since(*statusTime) > stalePendingCIHours*time.Hour { obj.WriteComment(pendingMsgBody) return } } }
// Munge is the workhorse the will actually make updates to the PR func (PingCIMunger) Munge(obj *github.MungeObject) { if !obj.IsPR() { return } if !obj.HasLabel("lgtm") { return } mergeable, err := obj.IsMergeable() if err != nil { glog.V(2).Infof("Skipping %d - problem determining mergeability", *obj.Issue.Number) return } if !mergeable { glog.V(2).Infof("Skipping %d - not mergeable", *obj.Issue.Number) return } if state := obj.GetStatusState([]string{jenkinsCIContext, travisContext}); state != "incomplete" { glog.V(2).Info("Have %s status - skipping ping CI", jenkinsCIContext) return } state := obj.GetStatusState([]string{shippableContext, travisContext}) if state == "incomplete" { msg := "Continuous integration appears to have missed, closing and re-opening to trigger it" obj.WriteComment(msg) obj.ClosePR() time.Sleep(5 * time.Second) obj.OpenPR(10) } }
// Munge is unused by this munger. func (cla *ClaMunger) Munge(obj *githubhelper.MungeObject) { if !obj.IsPR() { return } if obj.HasLabel(claHumanLabel) { return } status := obj.GetStatusState([]string{cla.CLAStatusContext}) // Check for pending status and exit. if status == contextPending { // do nothing and wait for state to be updated. return } if status == contextSuccess { if obj.HasLabel(cncfClaYesLabel) { // status is success and we've already applied 'cncf-cla: yes'. return } if obj.HasLabel(cncfClaNoLabel) { obj.RemoveLabel(cncfClaNoLabel) } obj.AddLabel(cncfClaYesLabel) return } // If we are here, that means that the context is failure/error. comments, err := obj.ListComments() if err != nil { glog.Error(err) return } who := mungerutil.GetIssueUsers(obj.Issue).Author.Mention().Join() // Get a notification if it's time to ping. notif := cla.pinger.PingNotification( comments, who, nil, ) if notif != nil { obj.WriteComment(notif.String()) } if obj.HasLabel(cncfClaNoLabel) { // status reported error/failure and we've already applied 'cncf-cla: no' label. return } if obj.HasLabel(cncfClaYesLabel) { obj.RemoveLabel(cncfClaYesLabel) } obj.AddLabel(cncfClaNoLabel) }
// Munge is the workhorse the will actually make updates to the PR func (OkToTestMunger) Munge(obj *github.MungeObject) { if !obj.IsPR() { return } if !obj.HasLabel(lgtmLabel) { return } state := obj.GetStatusState(requiredContexts) if state == "incomplete" { glog.V(2).Infof("status is incomplete, adding ok to test") obj.WriteComment(okToTestBody) } }
func (sq *SubmitQueue) requiredStatusContexts(obj *github.MungeObject) []string { contexts := sq.RequiredStatusContexts // If the pr has a jenkins ci status, require it, otherwise require shippable if state := obj.GetStatusState([]string{jenkinsCIContext}); state != "incomplete" { contexts = append(contexts, jenkinsCIContext) } else { contexts = append(contexts, shippableContext) } if len(sq.E2EStatusContext) > 0 && (len(sq.DontRequireE2ELabel) == 0 || !obj.HasLabel(sq.DontRequireE2ELabel)) { contexts = append(contexts, sq.E2EStatusContext) } return contexts }
// Munge is the workhorse the will actually make updates to the PR func (OkToTestMunger) Munge(obj *github.MungeObject) { if !obj.IsPR() { return } if !obj.HasLabel("lgtm") { return } state := obj.GetStatusState([]string{"Jenkins GCE e2e"}) if state == "incomplete" { glog.V(2).Infof("status is incomplete, adding ok to test") msg := `@k8s-bot ok to test pr builder appears to be missing, activating due to 'lgtm' label.` obj.WriteComment(msg) } }
// Munge is unused by this munger. func (c *ClaMunger) Munge(obj *githubhelper.MungeObject) { if !obj.IsPR() { return } if obj.HasLabel(claHumanLabel) { return } status := obj.GetStatusState([]string{c.CLAStatusContext}) // Check for pending status and exit. if status == contextPending { // do nothing and wait for state to be updated. return } if status == contextSuccess { if obj.HasLabel(cncfClaYesLabel) { // status is success and we've already applied 'cncf-cla: yes'. return } if obj.HasLabel(cncfClaNoLabel) { obj.RemoveLabel(cncfClaNoLabel) } obj.AddLabel(cncfClaYesLabel) return } if obj.HasLabel(cncfClaNoLabel) { // status reported error/failure and we've already applied 'cncf-cla: no' label. return } // Write comment and then modify the labels. err := obj.WriteComment(fmt.Sprint(cncfclaNotFoundMessage, mungerutil.GetIssueUsers(obj.Issue).Author.Mention().Join())) if err != nil { return } if obj.HasLabel(cncfClaYesLabel) { obj.RemoveLabel(cncfClaYesLabel) } obj.AddLabel(cncfClaNoLabel) }
// Munge is the workhorse the will actually make updates to the PR func (PingCIMunger) Munge(obj *github.MungeObject) { if !obj.IsPR() { return } // This munger only runs on certain branches, since travis/CI only listens // on certain branches validBranch := false for _, b := range validBranches { if obj.IsForBranch(b) { validBranch = true break } } if !validBranch { return } if !obj.HasLabel(lgtmLabel) { return } mergeable, err := obj.IsMergeable() if err != nil { glog.V(2).Infof("ping CI skipping %d - problem determining mergeability", *obj.Issue.Number) return } if !mergeable { glog.V(2).Infof("ping CI skipping %d - not mergeable", *obj.Issue.Number) return } if state := obj.GetStatusState([]string{travisContext}); state == "incomplete" { msg := "Travis continuous integration appears to have missed, closing and re-opening to trigger it" obj.WriteComment(msg) obj.ClosePR() time.Sleep(5 * time.Second) obj.OpenPR(10) } }
// Munge is the workhorse the will actually make updates to the PR func (StalePendingCI) Munge(obj *github.MungeObject) { requiredContexts := []string{jenkinsUnitContext, jenkinsE2EContext} if !obj.IsPR() { return } if !obj.HasLabel("lgtm") { return } if mergeable, err := obj.IsMergeable(); !mergeable || err != nil { return } status := obj.GetStatusState(requiredContexts) if status != "pending" { return } for _, context := range requiredContexts { statusTime := obj.GetStatusTime(context) if statusTime == nil { glog.Errorf("%d: unable to determine time %q context was set", *obj.Issue.Number, context) return } if time.Since(*statusTime) > stalePendingCIHours*time.Hour { msgFormat := `@k8s-bot test this issue: #IGNORE Tests have been pending for %d hours` msg := fmt.Sprintf(msgFormat, stalePendingCIHours) obj.WriteComment(msg) return } } }