trigger

package
v0.0.0-...-1738bad Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PluginName is the name of the trigger plugin
	PluginName = "trigger"
)

Variables

This section is empty.

Functions

func FilterPresubmits

func FilterPresubmits(honorOkToTest bool, gitHubClient GitHubClient, body string, pr *github.PullRequest, presubmits []config.Presubmit, logger *logrus.Entry) ([]config.Presubmit, error)

FilterPresubmits determines which presubmits should run. We only want to trigger jobs that should run, but the pool of jobs we filter to those that should run depends on the type of trigger we just got:

  • if we get a /test foo, we only want to consider those jobs that match; jobs will default to run unless we can determine they shouldn't
  • if we got a /retest, we only want to consider those jobs that have already run and posted failing contexts to the PR or those jobs that have not yet run but would otherwise match /test all; jobs will default to run unless we can determine they shouldn't
  • if we got a /test all or an /ok-to-test, we want to consider any job that doesn't explicitly require a human trigger comment; jobs will default to not run unless we can determine that they should

If a comment that we get matches more than one of the above patterns, we consider the set of matching presubmits the union of the results from the matching cases.

func HonorOkToTest

func HonorOkToTest(trigger plugins.Trigger) bool

func RunRequested

func RunRequested(c Client, pr *github.PullRequest, baseSHA string, requestedJobs []config.Presubmit, eventGUID string) error

RunRequested executes the config.Presubmits that are requested

func RunRequestedWithLabels

func RunRequestedWithLabels(c Client, pr *github.PullRequest, baseSHA string, requestedJobs []config.Presubmit, eventGUID string, labels map[string]string) error

RunRequestedWithLabels executes the config.Presubmits that are requested with the additional labels

func TrustedPullRequest

func TrustedPullRequest(tprc trustedPullRequestClient, trigger plugins.Trigger, author, org, repo string, num int, l []github.Label) ([]github.Label, bool, error)

TrustedPullRequest returns whether or not the given PR should be tested. It first checks if the author is in the org, then looks for "ok-to-test" label. If already known, GitHub labels should be provided to save tokens. Otherwise, it fetches them.

Types

type Client

type Client struct {
	GitHubClient  githubClient
	ProwJobClient prowJobClient
	Config        *config.Config
	Logger        *logrus.Entry
	GitClient     git.ClientFactory
}

Client holds the necessary structures to work with prow via logging, github, kubernetes and its configuration.

TODO(fejta): consider exporting an interface rather than a struct

type GitHubClient

type GitHubClient interface {
	GetCombinedStatus(org, repo, ref string) (*github.CombinedStatus, error)
	GetPullRequestChanges(org, repo string, number int) ([]github.PullRequestChange, error)
}

type TrustedUserResponse

type TrustedUserResponse struct {
	IsTrusted bool
	// Reason contains the reason that a user is not trusted if IsTrusted is false
	Reason string
}

TrustedUserResponse is a response from TrustedUser. It contains the boolean response for trust as well a reason for denial if the user is not trusted.

func TrustedUser

func TrustedUser(ghc trustedUserClient, onlyOrgMembers bool, trustedApps []string, trustedOrg, user, org, repo string) (TrustedUserResponse, error)

TrustedUser returns true if user is trusted in repo. Trusted users are either repo collaborators, org members or trusted org members.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL