Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow skipping report comments #1611

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ Trigger specifies a configuration for a single trigger.<br /><br />The configura
| `ignore_ok_to_test` | bool | No | IgnoreOkToTest makes trigger ignore /ok-to-test comments.<br />This is a security mitigation to only allow testing from trusted users. |
| `elide_skipped_contexts` | bool | No | ElideSkippedContexts makes trigger not post "Skipped" contexts for jobs<br />that could run but do not run. |
| `skip_draft_pr` | bool | No | SkipDraftPR when enabled, skips triggering pipelines for draft PRs<br />unless /ok-to-test is added. |
| `skip_report_comment` | bool | No | SkipReportComment when enabled, skips report comments in the SCM provider based on the state of<br />the LighthouseJobs. |

## Welcome

Expand Down
1 change: 1 addition & 0 deletions docs/plugins/Plugins config.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ Trigger specifies a configuration for a single trigger.<br /><br />The configura
| IgnoreOkToTest | `ignore_ok_to_test` | bool | No | IgnoreOkToTest makes trigger ignore /ok-to-test comments.<br />This is a security mitigation to only allow testing from trusted users. |
| ElideSkippedContexts | `elide_skipped_contexts` | bool | No | ElideSkippedContexts makes trigger not post "Skipped" contexts for jobs<br />that could run but do not run. |
| SkipDraftPR | `skip_draft_pr` | bool | No | SkipDraftPR when enabled, skips triggering pipelines for draft PRs<br />unless /ok-to-test is added. |
| SkipReportComment | `skip_report_comment` | bool | No | SkipReportComment when enabled, skips report comments in the SCM provider based on the state of<br />the LighthouseJobs. |

## Welcome

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/h2non/gock v1.0.9
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/golang-lru v0.5.4
github.com/jenkins-x/go-scm v1.14.36
github.com/jenkins-x/go-scm v1.14.37
github.com/mattn/go-zglob v0.0.1
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.20.1
Expand Down Expand Up @@ -127,7 +127,7 @@ replace (
github.com/Azure/azure-sdk-for-go => github.com/Azure/azure-sdk-for-go v38.2.0+incompatible

// lets override the go-scm version from tektoncd
github.com/jenkins-x/go-scm => github.com/jenkins-x/go-scm v1.14.36
github.com/jenkins-x/go-scm => github.com/jenkins-x/go-scm v1.14.37

// gomodules.xyz breaks in Athens proxying
gomodules.xyz/jsonpatch/v2 => github.com/gomodules/jsonpatch/v2 v2.2.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/jenkins-x/go-scm v1.14.36 h1:JbEt2BIq1v/Jnbd+DW3zEAO4ZjONB53guF8OfxaARDY=
github.com/jenkins-x/go-scm v1.14.36/go.mod h1:MRLj/i0mhpMtqwwZV+x78SkEB8mx9rv3ebdRg9WunS8=
github.com/jenkins-x/go-scm v1.14.37 h1:Tq59JXyg5p4iuvIKf6+EA+Yzgxgpn/yG/yfM1mL8DDg=
github.com/jenkins-x/go-scm v1.14.37/go.mod h1:MRLj/i0mhpMtqwwZV+x78SkEB8mx9rv3ebdRg9WunS8=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
Expand Down
11 changes: 7 additions & 4 deletions pkg/foghorn/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,14 @@ func (r *LighthouseJobReconciler) reportStatus(activity *lighthousev1alpha1.Acti
return
}

err = reporter.Report(scmClient, r.jobConfig.Config().Plank.ReportTemplate, j, []job.PipelineKind{job.PresubmitJob})
if err != nil {
// For now, we're just going to ignore failures here.
r.logger.WithFields(fields).WithError(err).Warnf("failed to update comments on the PR")
if !r.pluginConfig.Config().TriggerFor(owner, repo).SkipReportComment {
err = reporter.Report(scmClient, r.jobConfig.Config().Plank.ReportTemplate, j, []job.PipelineKind{job.PresubmitJob})
if err != nil {
// For now, we're just going to ignore failures here.
r.logger.WithFields(fields).WithError(err).Warnf("failed to update comments on the PR")
}
}

r.logger.WithFields(fields).Info("reported git status")
j.Status.Description = statusInfo.description
j.Status.LastReportState = statusInfo.scmStatus.String()
Expand Down
3 changes: 3 additions & 0 deletions pkg/plugins/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ type Trigger struct {
ElideSkippedContexts bool `json:"elide_skipped_contexts,omitempty"`
// SkipDraftPR when enabled, skips triggering pipelines for draft PRs, unless /ok-to-test is added.
SkipDraftPR bool `json:"skip_draft_pr,omitempty"`
// SkipReportComment when enabled, skips report comments in the SCM provider based on the state of
// the LighthouseJobs.
SkipReportComment bool `json:"skip_report_comment,omitempty"`
}

// Milestone contains the configuration options for the milestone and
Expand Down
Loading