Documentation ¶
Overview ¶
Package jobutil contains helpers for working with LighthouseJobs.
Package jobutil contains helpers for working with ProwJobs.
Index ¶
- Variables
- func BatchSpec(p job.Presubmit, refs v1alpha1.Refs) v1alpha1.LighthouseJobSpec
- func FilterPresubmits(filter Filter, changes job.ChangedFilesProvider, branch string, ...) ([]job.Presubmit, []job.Presubmit, error)
- func LabelsAndAnnotationsForJob(lj v1alpha1.LighthouseJob, buildID string) (map[string]string, map[string]string)
- func LabelsAndAnnotationsForSpec(spec v1alpha1.LighthouseJobSpec, ...) (map[string]string, map[string]string)
- func LighthouseJobFields(lighthouseJob *v1alpha1.LighthouseJob) logrus.Fields
- func NewLighthouseJob(spec v1alpha1.LighthouseJobSpec, ...) v1alpha1.LighthouseJob
- func NewPresubmit(pr *scm.PullRequest, baseSHA string, job job.Presubmit, eventGUID string, ...) v1alpha1.LighthouseJob
- func PartitionActive(pjs []v1alpha1.LighthouseJob) (pending, triggered, aborted chan v1alpha1.LighthouseJob)
- func PeriodicSpec(p job.Periodic) v1alpha1.LighthouseJobSpec
- func PostsubmitSpec(p job.Postsubmit, refs v1alpha1.Refs) v1alpha1.LighthouseJobSpec
- func PresubmitSpec(p job.Presubmit, refs v1alpha1.Refs) v1alpha1.LighthouseJobSpec
- func ServePProf()
- type Filter
Constants ¶
This section is empty.
Variables ¶
var OkToTestRe = regexp.MustCompile(`(?m)^/(?:lh-)?ok-to-test\s*$`)
OkToTestRe provies the regex for `/ok-to-test`
var RetestRe = regexp.MustCompile(`(?m)^/(?:lh-)?retest\s*$`)
RetestRe provides the regex for `/retest`
var TestAllRe = regexp.MustCompile(`(?m)^/(?:lh-)?test all,?($|\s.*)`)
TestAllRe provides the regex for `/test all`
Functions ¶
func FilterPresubmits ¶
func FilterPresubmits(filter Filter, changes job.ChangedFilesProvider, branch string, presubmits []job.Presubmit, logger *logrus.Entry) ([]job.Presubmit, []job.Presubmit, error)
FilterPresubmits determines which presubmits should run and which should be skipped by evaluating the user-provided filter.
func LabelsAndAnnotationsForJob ¶
func LabelsAndAnnotationsForJob(lj v1alpha1.LighthouseJob, buildID string) (map[string]string, map[string]string)
LabelsAndAnnotationsForJob returns a standard set of labels to add to pod/build/etc resources.
func LabelsAndAnnotationsForSpec ¶
func LabelsAndAnnotationsForSpec(spec v1alpha1.LighthouseJobSpec, extraLabels, extraAnnotations map[string]string) (map[string]string, map[string]string)
LabelsAndAnnotationsForSpec returns a minimal set of labels to add to LighthouseJobs or its owned resources.
User-provided extraLabels and extraAnnotations values will take precedence over auto-provided values.
func LighthouseJobFields ¶
func LighthouseJobFields(lighthouseJob *v1alpha1.LighthouseJob) logrus.Fields
LighthouseJobFields extracts logrus fields from a LighthouseJob useful for logging.
func NewLighthouseJob ¶
func NewLighthouseJob(spec v1alpha1.LighthouseJobSpec, extraLabels, extraAnnotations map[string]string) v1alpha1.LighthouseJob
NewLighthouseJob initializes a LighthouseJob out of a LighthouseJobSpec.
func NewPresubmit ¶
func NewPresubmit(pr *scm.PullRequest, baseSHA string, job job.Presubmit, eventGUID string, prRefFmt string) v1alpha1.LighthouseJob
NewPresubmit converts a config.Presubmit into a builder.PipelineOptions. The builder.Refs are configured correctly per the pr, baseSHA. The eventGUID becomes a gitprovider.EventGUID label.
func PartitionActive ¶ added in v0.0.826
func PartitionActive(pjs []v1alpha1.LighthouseJob) (pending, triggered, aborted chan v1alpha1.LighthouseJob)
PartitionActive separates the provided prowjobs into pending and triggered and returns them inside channels so that they can be consumed in parallel by different goroutines. Complete prowjobs are filtered out. Controller loops need to handle pending jobs first so they can conform to maximum concurrency requirements that different jobs may have.
func PeriodicSpec ¶
func PeriodicSpec(p job.Periodic) v1alpha1.LighthouseJobSpec
PeriodicSpec initializes a PipelineOptionsSpec for a given periodic job.
func PostsubmitSpec ¶
func PostsubmitSpec(p job.Postsubmit, refs v1alpha1.Refs) v1alpha1.LighthouseJobSpec
PostsubmitSpec initializes a PipelineOptionsSpec for a given postsubmit job.
func PresubmitSpec ¶
PresubmitSpec initializes a PipelineOptionsSpec for a given presubmit job.
func ServePProf ¶
func ServePProf()
ServePProf sets up a handler for pprof debug endpoints and starts a server for them asynchronously. The contents of this function are identical to what the `net/http/pprof` package does on import for the simple case where the default mux is to be used, but with a custom mux to ensure we don't serve this data from an exposed port.
Types ¶
type Filter ¶
Filter digests a presubmit config to determine if:
- we the presubmit matched the filter
- we know that the presubmit is forced to run
- what the default behavior should be if the presubmit runs conditionally and does not match trigger conditions
func AggregateFilter ¶
AggregateFilter builds a filter that evaluates the child filters in order and returns the first match
func CommandFilter ¶
CommandFilter builds a filter for `/test foo`
func PresubmitFilter ¶
func PresubmitFilter(honorOkToTest bool, contextGetter contextGetter, body string, logger *logrus.Entry) (Filter, error)
PresubmitFilter creates a filter for presubmits
func RetestFilter ¶
RetestFilter builds a filter for `/retest`
func TestAllFilter ¶
func TestAllFilter() Filter
TestAllFilter builds a filter for the automatic behavior of `/test all`. Pipelines that explicitly match `/test all` in their trigger regex will be handled by a commandFilter for the comment in question.