patch

package
v0.0.0-...-8775593 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 23 Imported by: 104

Documentation

Overview

Package patch models an intent to patch test code in a particular state. It is distinct from a version because a version has tasks, whereas a patch merely represents an intent.

Index

Constants

View Source
const (
	Collection   = "patches"
	GridFSPrefix = "patchfiles"
)
View Source
const (
	// IntentCollection is the database collection that stores patch intents.
	IntentCollection = "patch_intents"

	// GithubIntentType represents patch intents created for GitHub.
	GithubIntentType = "github"
)
View Source
const (
	AutomatedCaller = "auto"
	ManualCaller    = "manual"
	AllCallers      = ""
)

CalledBy can be either auto or manual.

View Source
const CliIntentType = "cli"
View Source
const (
	// GithubMergeIntentType is an intent to create a version for a GitHub merge group.
	GithubMergeIntentType = "github_merge"
)
View Source
const SizeLimit = 1024 * 1024 * 100

SizeLimit is a hard limit on patch size.

View Source
const TriggerIntentType = "trigger"

Variables

View Source
var (
	IdKey                   = bsonutil.MustHaveTag(Patch{}, "Id")
	DescriptionKey          = bsonutil.MustHaveTag(Patch{}, "Description")
	ProjectKey              = bsonutil.MustHaveTag(Patch{}, "Project")
	GithashKey              = bsonutil.MustHaveTag(Patch{}, "Githash")
	AuthorKey               = bsonutil.MustHaveTag(Patch{}, "Author")
	NumberKey               = bsonutil.MustHaveTag(Patch{}, "PatchNumber")
	VersionKey              = bsonutil.MustHaveTag(Patch{}, "Version")
	StatusKey               = bsonutil.MustHaveTag(Patch{}, "Status")
	CreateTimeKey           = bsonutil.MustHaveTag(Patch{}, "CreateTime")
	StartTimeKey            = bsonutil.MustHaveTag(Patch{}, "StartTime")
	FinishTimeKey           = bsonutil.MustHaveTag(Patch{}, "FinishTime")
	BuildVariantsKey        = bsonutil.MustHaveTag(Patch{}, "BuildVariants")
	TasksKey                = bsonutil.MustHaveTag(Patch{}, "Tasks")
	VariantsTasksKey        = bsonutil.MustHaveTag(Patch{}, "VariantsTasks")
	SyncAtEndOptionsKey     = bsonutil.MustHaveTag(Patch{}, "SyncAtEndOpts")
	PatchesKey              = bsonutil.MustHaveTag(Patch{}, "Patches")
	ParametersKey           = bsonutil.MustHaveTag(Patch{}, "Parameters")
	ActivatedKey            = bsonutil.MustHaveTag(Patch{}, "Activated")
	ProjectStorageMethodKey = bsonutil.MustHaveTag(Patch{}, "ProjectStorageMethod")
	PatchedProjectConfigKey = bsonutil.MustHaveTag(Patch{}, "PatchedProjectConfig")
	AliasKey                = bsonutil.MustHaveTag(Patch{}, "Alias")

	MergePatchKey = bsonutil.MustHaveTag(Patch{}, "MergePatch")
	TriggersKey   = bsonutil.MustHaveTag(Patch{}, "Triggers")
	HiddenKey     = bsonutil.MustHaveTag(Patch{}, "Hidden")

	// BSON fields for sync at end struct
	SyncAtEndOptionsBuildVariantsKey = bsonutil.MustHaveTag(SyncAtEndOptions{}, "BuildVariants")
	SyncAtEndOptionsTasksKey         = bsonutil.MustHaveTag(SyncAtEndOptions{}, "Tasks")
	SyncAtEndOptionsVariantsTasksKey = bsonutil.MustHaveTag(SyncAtEndOptions{}, "VariantsTasks")
	SyncAtEndOptionsStatusesKey      = bsonutil.MustHaveTag(SyncAtEndOptions{}, "Statuses")
	SyncAtEndOptionsTimeoutKey       = bsonutil.MustHaveTag(SyncAtEndOptions{}, "Timeout")

	// BSON fields for the module patch struct
	ModulePatchNameKey    = bsonutil.MustHaveTag(ModulePatch{}, "ModuleName")
	ModulePatchGithashKey = bsonutil.MustHaveTag(ModulePatch{}, "Githash")
	ModulePatchSetKey     = bsonutil.MustHaveTag(ModulePatch{}, "PatchSet")

	// BSON fields for the patch set struct
	PatchSetPatchKey   = bsonutil.MustHaveTag(PatchSet{}, "Patch")
	PatchSetSummaryKey = bsonutil.MustHaveTag(PatchSet{}, "Summary")

	// BSON fields for the patch trigger struct
	TriggerInfoAliasesKey              = bsonutil.MustHaveTag(TriggerInfo{}, "Aliases")
	TriggerInfoParentPatchKey          = bsonutil.MustHaveTag(TriggerInfo{}, "ParentPatch")
	TriggerInfoChildPatchesKey         = bsonutil.MustHaveTag(TriggerInfo{}, "ChildPatches")
	TriggerInfoDownstreamParametersKey = bsonutil.MustHaveTag(TriggerInfo{}, "DownstreamParameters")
)

BSON fields for the patches

ExcludePatchDiff is a projection that excludes diff data, helping load times.

Functions

func ByGithash

func ByGithash(githash string) db.Q

func ByGithubPRAndCreatedBefore

func ByGithubPRAndCreatedBefore(t time.Time, owner, repo string, prNumber int) db.Q

ByGithubPRAndCreatedBefore finds all patches that were created for a GitHub PR before the given timestamp.

func ById

func ById(id mgobson.ObjectId) db.Q

ById produces a query to return the patch with the given _id.

func ByProjectAndCommitQueue

func ByProjectAndCommitQueue(project string, filterCommitQueue bool) db.Q

ByProject produces a query that returns projects with the given identifier.

func ByStringId

func ByStringId(id string) db.Q

func ByStringIds

func ByStringIds(ids []string) db.Q

func ByUserAndCommitQueue

func ByUserAndCommitQueue(user string, filterCommitQueue bool) db.Q

ByUser produces a query that returns patches by the given user.

func ByUserPaginated

func ByUserPaginated(user string, ts time.Time, limit int) db.Q

ByUserPaginated produces a query that returns patches by the given user before/after the input time, sorted by creation time and limited

func ByVersion

func ByVersion(version string) db.Q

ByVersion produces a query that returns the patch for a given version.

func ByVersions

func ByVersions(versions []string) db.Q

ByVersion produces a query that returns the patch for a given version.

func ConsolidatePatchesForUser

func ConsolidatePatchesForUser(oldAuthor string, newUsr *user.DBUser) error

ConsolidatePatchesForUser updates all patches authored by oldAuthor to be authored by newAuthor, and if any patches have been authored by the new author already, update the patch numbers to come after the new author.

func FetchPatchContents

func FetchPatchContents(patchfileID string) (string, error)

func FindProjectForPatch

func FindProjectForPatch(patchID mgobson.ObjectId) (string, error)

func FindUnprocessedGithubIntents

func FindUnprocessedGithubIntents() ([]*githubIntent, error)

FindUnprocessedGithubIntents finds all patch intents that have not yet been processed.

func GetChildrenOrSiblingsReadiness

func GetChildrenOrSiblingsReadiness(childrenOrSiblings []string) (string, error)

func GetCollectiveStatusFromPatchStatuses

func GetCollectiveStatusFromPatchStatuses(statuses []string) string

GetCollectiveStatusFromPatchStatuses answers the question of what the patch status should be when the patch status and the status of its children are different, given a list of statuses.

func GetFinalizedChildPatchIdsForPatch

func GetFinalizedChildPatchIdsForPatch(patchID string) ([]string, error)

GetFinalizedChildPatchIdsForPatch returns patchIds for any finalized children of the given patch.

func GetGithubContextForChildPatch

func GetGithubContextForChildPatch(projectIdentifier string, parentPatch, childPatch *Patch) (string, error)

GetGithubContextForChildPatch returns the github context for the given child patch, to be used in github statuses.

func IsMailbox

func IsMailbox(patchFile string) (bool, error)

IsMailbox checks if the first line of a patch file has "From ". If so, it's assumed to be a mailbox-style patch, otherwise it's a diff

func IsMailboxDiff

func IsMailboxDiff(patchDiff string) bool

func IsPatchEmpty

func IsPatchEmpty(id string) (bool, error)

func IsValidId

func IsValidId(id string) bool

IsValidId returns whether the supplied Id is a valid patch doc id (BSON ObjectId).

func MostRecentPatchByUserAndProject

func MostRecentPatchByUserAndProject(user, project string) db.Q

MostRecentPatchByUserAndProject returns the latest patch made by the user for the project.

func NewId

func NewId(id string) mgobson.ObjectId

NewId constructs a valid patch Id from the given hex string.

func PatchesByProject

func PatchesByProject(projectId string, ts time.Time, limit int) db.Q

PatchesByProject builds a query for patches that match the given project's id.

func Remove

func Remove(query db.Q) error

Remove removes all patch documents that satisfy the query.

func ResolveVariantTasks

func ResolveVariantTasks(vts []VariantTasks) (bvs []string, tasks []string)

ResolveVariantTasks returns a set of all build variants and a set of all tasks that will run based on the given VariantTasks, filtering out any duplicates.

func TryMarkStarted

func TryMarkStarted(versionId string, startTime time.Time) error

TryMarkStarted attempts to mark a patch as started if it isn't already marked as such

func UpdateAll

func UpdateAll(query interface{}, update interface{}) (info *adb.ChangeInfo, err error)

UpdateAll runs an update on all patch documents.

func UpdateOne

func UpdateOne(query interface{}, update interface{}) error

UpdateOne runs an update on a single patch document.

Types

type BackportInfo

type BackportInfo struct {
	PatchID string `bson:"patch_id,omitempty" json:"patch_id,omitempty"`
	SHA     string `bson:"sha,omitempty" json:"sha,omitempty"`
}

type ByPatchNameStatusesCommitQueuePaginatedOptions

type ByPatchNameStatusesCommitQueuePaginatedOptions struct {
	Author             *string
	IncludeCommitQueue *bool
	IncludeHidden      *bool
	Limit              int
	OnlyCommitQueue    *bool
	Page               int
	PatchName          string
	Project            *string
	Requesters         []string
	Statuses           []string
}

type CLIIntentParams

type CLIIntentParams struct {
	User                string
	Path                string
	Project             string
	BaseGitHash         string
	Module              string
	PatchContent        string
	Description         string
	Finalize            bool
	BackportOf          BackportInfo
	GitInfo             *GitMetadata
	Parameters          []Parameter
	Variants            []string
	Tasks               []string
	RegexVariants       []string
	RegexTasks          []string
	Alias               string
	TriggerAliases      []string
	RepeatDefinition    bool
	RepeatFailed        bool
	RepeatPatchId       string
	SyncParams          SyncAtEndOptions
	LocalModuleIncludes []LocalModuleInclude
}

type DisplayTask

type DisplayTask struct {
	Name      string   `yaml:"name,omitempty" bson:"name,omitempty"`
	ExecTasks []string `yaml:"execution_tasks,omitempty" bson:"execution_tasks,omitempty"`
}

type GitMetadata

type GitMetadata struct {
	Username   string `bson:"username" json:"username"`
	Email      string `bson:"email" json:"email"`
	GitVersion string `bson:"git_version,omitempty" json:"git_version,omitempty"`
}

type Intent

type Intent interface {
	// ID returns a unique identifier for the patch. Should
	// correspond to the _id for the patch in database.
	ID() string

	// Insert inserts a patch intent in the database.
	Insert() error

	// SetProcessed should be called by an amboy queue after creating a patch from an intent.
	SetProcessed() error

	// IsProcessed returns whether a patch exists for this intent.
	IsProcessed() bool

	// GetType returns the patch intent, e.g., GithubIntentType.
	GetType() string

	// NewPatch creates a patch from the intent
	NewPatch() *Patch

	// Finalize indicates whether or not the patch created from this
	// intent should be finalized
	ShouldFinalizePatch() bool

	// RepeatPreviousPatchDefinition returns true if we should use the same tasks/variants as a previous patch.
	// Returns patch ID if specified, otherwise we use the latest patch.
	RepeatPreviousPatchDefinition() (string, bool)

	// RepeatFailedTasksAndVariants returns true if we should use the failed tasks/variants from a previous patch.
	// Returns patch ID if specified, otherwise we use the latest patch.
	RepeatFailedTasksAndVariants() (string, bool)

	// GetAlias defines the variants and tasks this intent should run on.
	GetAlias() string

	// RequesterIdentity supplies a valid requester type, that is recorded
	// in patches, versions, builds, and tasks to denote the origin of the
	// patch
	RequesterIdentity() string

	// GetCalledBy indicates whether the intent was created automatically
	// by Evergreen or manually by the user.
	GetCalledBy() string
}

Intent represents an intent to create a patch build and is processed by an amboy queue.

func FindIntent

func FindIntent(id, intentType string) (Intent, error)

FindIntent returns an intent of the specified type from the database

func GetIntent

func GetIntent(intentType string) (Intent, bool)

GetIntent returns a concrete Intent object of the type specified by intentType.

func NewCliIntent

func NewCliIntent(params CLIIntentParams) (Intent, error)

func NewGithubIntent

func NewGithubIntent(msgDeliveryID, patchOwner, calledBy, alias, mergeBase string, pr *github.PullRequest) (Intent, error)

NewGithubIntent creates an Intent from a google/go-github PullRequestEvent, or returns an error if the some part of the struct is invalid

func NewGithubMergeIntent

func NewGithubMergeIntent(msgDeliveryID string, caller string, mg *github.MergeGroupEvent) (Intent, error)

NewGithubIntent creates an Intent from a google/go-github MergeGroup.

func NewTriggerIntent

func NewTriggerIntent(opts TriggerIntentOptions) Intent

type LocalModuleInclude

type LocalModuleInclude struct {
	FileName string `yaml:"filename,omitempty" bson:"filename,omitempty" json:"filename,omitempty"`
	Module   string `yaml:"module,omitempty" bson:"module,omitempty" json:"module,omitempty"`

	// FileContent is only used for local module includes for CLI patches
	FileContent []byte `yaml:"file_content,omitempty" bson:"file_content,omitempty" json:"file_content,omitempty"`
}

type ModulePatch

type ModulePatch struct {
	ModuleName string   `bson:"name"`
	Githash    string   `bson:"githash"`
	PatchSet   PatchSet `bson:"patch_set"`
	IsMbox     bool     `bson:"is_mbox"`
}

ModulePatch stores request details for a patch

func MakeMergePatchPatches

func MakeMergePatchPatches(existingPatch *Patch, commitMessage string) ([]ModulePatch, error)

type Parameter

type Parameter struct {
	Key   string `yaml:"key" bson:"key"`
	Value string `yaml:"value" bson:"value"`
}

Parameter defines a key/value pair to be used as an expansion.

type Patch

type Patch struct {
	Id                 mgobson.ObjectId `bson:"_id,omitempty"`
	Description        string           `bson:"desc"`
	Path               string           `bson:"path,omitempty"`
	Project            string           `bson:"branch"`
	Githash            string           `bson:"githash"`
	Hidden             bool             `bson:"hidden"`
	PatchNumber        int              `bson:"patch_number"`
	Author             string           `bson:"author"`
	Version            string           `bson:"version"`
	Status             string           `bson:"status"`
	CreateTime         time.Time        `bson:"create_time"`
	StartTime          time.Time        `bson:"start_time"`
	FinishTime         time.Time        `bson:"finish_time"`
	BuildVariants      []string         `bson:"build_variants"`
	RegexBuildVariants []string         `bson:"regex_build_variants"`
	Tasks              []string         `bson:"tasks"`
	RegexTasks         []string         `bson:"regex_tasks"`
	VariantsTasks      []VariantTasks   `bson:"variants_tasks"`
	SyncAtEndOpts      SyncAtEndOptions `bson:"sync_at_end_opts,omitempty"`
	Patches            []ModulePatch    `bson:"patches"`
	Parameters         []Parameter      `bson:"parameters,omitempty"`
	// Activated indicates whether or not the patch is finalized (i.e.
	// tasks/variants are now scheduled to run). If true, the patch has been
	// finalized.
	Activated bool `bson:"activated"`
	// ProjectStorageMethod describes how the parser project is stored for this
	// patch before it's finalized. This field is only set while the patch is
	// unfinalized and is cleared once the patch has been finalized.
	ProjectStorageMethod evergreen.ParserProjectStorageMethod `bson:"project_storage_method,omitempty"`
	PatchedProjectConfig string                               `bson:"patched_project_config"`
	Alias                string                               `bson:"alias"`
	Triggers             TriggerInfo                          `bson:"triggers"`
	BackportOf           BackportInfo                         `bson:"backport_of,omitempty"`
	MergePatch           string                               `bson:"merge_patch"`
	GithubPatchData      thirdparty.GithubPatch               `bson:"github_patch_data,omitempty"`
	GithubMergeData      thirdparty.GithubMergeGroup          `bson:"github_merge_data,omitempty"`
	GitInfo              *GitMetadata                         `bson:"git_info,omitempty"`
	// DisplayNewUI is only used when roundtripping the patch via the CLI
	DisplayNewUI bool `bson:"display_new_ui,omitempty"`
	// MergeStatus is only used in gitServePatch to send the status of this
	// patch on the commit queue to the agent
	MergeStatus string `json:"merge_status"`
	// MergedFrom is populated with the patch id of the existing patch
	// the merged patch is based off of, if applicable.
	MergedFrom string `bson:"merged_from,omitempty"`
	// LocalModuleIncludes is only used for CLI patches to store local module changes.
	LocalModuleIncludes []LocalModuleInclude `bson:"local_module_includes,omitempty"`
	// ReferenceManifestID stores the ID of the manifest that this patch is based on.
	// It is used to determine the module revisions for this patch during creation.
	// This could potentially reference an invalid manifest, and should not error
	// when the manifest is not found.
	// Not stored in the database since it is only needed during patch creation.
	ReferenceManifestID string `bson:"-"`
}

Patch stores all details related to a patch request

func ByPatchNameStatusesCommitQueuePaginated

func ByPatchNameStatusesCommitQueuePaginated(ctx context.Context, opts ByPatchNameStatusesCommitQueuePaginatedOptions) ([]Patch, int, error)

func Find

func Find(query db.Q) ([]Patch, error)

Find runs a patch query, returning all patches that satisfy the query.

func FindFailedCommitQueuePatchesInTimeRange

func FindFailedCommitQueuePatchesInTimeRange(projectID string, startTime, endTime time.Time) ([]Patch, error)

FindFailedCommitQueuePatchesInTimeRange returns failed patches if they started or failed within range.

func FindLatestGithubPRPatch

func FindLatestGithubPRPatch(owner, repo string, prNumber int) (*Patch, error)

FindLatestGithubPRPatch returns the latest PR patch for the given PR, if there is one.

func FindOne

func FindOne(query db.Q) (*Patch, error)

FindOne runs a patch query, returning one patch.

func FindOneId

func FindOneId(id string) (*Patch, error)

func MakeNewMergePatch

func MakeNewMergePatch(pr *github.PullRequest, projectID, alias, commitTitle, commitMessage string) (*Patch, error)

func (*Patch) AddBuildVariants

func (p *Patch) AddBuildVariants(bvs []string) error

AddBuildVariants adds more buildvarints to a patch document. This is meant to be used after initial patch creation.

func (*Patch) AddSyncVariantsTasks

func (p *Patch) AddSyncVariantsTasks(vts []VariantTasks) error

AddSyncVariantsTasks adds new tasks for variants filtered from the given sequence of VariantsTasks to the existing synced VariantTasks.

func (*Patch) AddTasks

func (p *Patch) AddTasks(tasks []string) error

AddTasks adds more tasks to a patch document. This is meant to be used after initial patch creation, to reconfigure the patch.

func (*Patch) ClearPatchData

func (p *Patch) ClearPatchData()

ClearPatchData removes any inline patch data stored in this patch object for patches that have an associated id in gridfs, so that it can be stored properly.

func (*Patch) CollectiveStatus

func (p *Patch) CollectiveStatus() (string, error)

CollectiveStatus returns the aggregate status of all tasks and child patches. If this is meant for display on the UI, we should also consider the display status aborted. NOTE that the result of this should not be compared against version statuses, as those can be different.

func (*Patch) ConfigChanged

func (p *Patch) ConfigChanged(remotePath string) bool

ConfigChanged looks through the parts of the patch and returns true if the passed in remotePath is in the the name of the changed files that are part of the patch

func (*Patch) FetchPatchFiles

func (p *Patch) FetchPatchFiles(useRaw bool) error

FetchPatchFiles dereferences externally-stored patch diffs by fetching them from gridfs and placing their contents into the patch object.

func (*Patch) FilesChanged

func (p *Patch) FilesChanged() []string

func (*Patch) FindModule

func (p *Patch) FindModule(moduleName string) *ModulePatch

func (*Patch) GetCommitQueueURL

func (p *Patch) GetCommitQueueURL(uiHost string) string

func (*Patch) GetFamilyInformation

func (p *Patch) GetFamilyInformation() (bool, *Patch, error)

func (*Patch) GetPatchFamily

func (p *Patch) GetPatchFamily() ([]string, *Patch, error)

func (*Patch) GetPatchIndex

func (p *Patch) GetPatchIndex(parentPatch *Patch) (int, error)

func (*Patch) GetRequester

func (p *Patch) GetRequester() string

func (*Patch) GetURL

func (p *Patch) GetURL(uiHost string) string

func (*Patch) HasValidGitInfo

func (p *Patch) HasValidGitInfo() bool

func (*Patch) Insert

func (p *Patch) Insert() error

Insert inserts the patch into the db, returning any errors that occur

func (*Patch) IsBackport

func (p *Patch) IsBackport() bool

func (*Patch) IsChild

func (p *Patch) IsChild() bool

func (*Patch) IsCommitQueuePatch

func (p *Patch) IsCommitQueuePatch() bool

IsCommitQueuePatch returns true if the the patch is part of any commit queue: either Evergreen's commit queue or GitHub's merge queue.

func (*Patch) IsFinished

func (p *Patch) IsFinished() bool

IsFinished returns whether or not the patch has finished based on its status.

func (*Patch) IsGithubMergePatch

func (p *Patch) IsGithubMergePatch() bool

IsGithubMergePatch returns true if the patch is from the GitHub merge queue.

func (*Patch) IsGithubPRPatch

func (p *Patch) IsGithubPRPatch() bool

func (*Patch) IsPRMergePatch

func (p *Patch) IsPRMergePatch() bool

func (*Patch) IsParent

func (p *Patch) IsParent() bool

func (*Patch) MakeBackportDescription

func (p *Patch) MakeBackportDescription() (string, error)

func (*Patch) MarkFinished

func (p *Patch) MarkFinished(status string, finishTime time.Time) error

func (*Patch) MarshalBSON

func (p *Patch) MarshalBSON() ([]byte, error)

func (*Patch) RemoveModulePatch

func (p *Patch) RemoveModulePatch(moduleName string) error

RemoveModulePatch removes a module that's part of a patch request

func (*Patch) ResolveSyncVariantTasks

func (p *Patch) ResolveSyncVariantTasks(vts []VariantTasks) []VariantTasks

ResolveSyncVariantTasks filters the given tasks by variant to find only those that match the build variant and task filters.

func (*Patch) SetActivation

func (p *Patch) SetActivation(activated bool) error

SetActivation sets the patch to the desired activation state without modifying the activation status of the possibly corresponding version.

func (*Patch) SetChildPatches

func (p *Patch) SetChildPatches() error

SetChildPatches appends the IDs of downstream patches to the db

func (*Patch) SetDescription

func (p *Patch) SetDescription(desc string) error

SetDescription sets a patch's description in the database

func (*Patch) SetDownstreamParameters

func (p *Patch) SetDownstreamParameters(parameters []Parameter) error

func (*Patch) SetFinalized

func (p *Patch) SetFinalized(ctx context.Context, versionId string) error

SetFinalized marks the patch as finalized.

func (*Patch) SetMergePatch

func (p *Patch) SetMergePatch(newPatchID string) error

func (*Patch) SetParameters

func (p *Patch) SetParameters(parameters []Parameter) error

func (*Patch) SetParametersFromParent

func (p *Patch) SetParametersFromParent() (*Patch, error)

func (*Patch) SetPatchVisibility

func (p *Patch) SetPatchVisibility(hidden bool) error

SetPatchVisibility set the patch visibility to the desired state. This is used to hide patches that the user does not need to see.

func (*Patch) SetTriggerAliases

func (p *Patch) SetTriggerAliases() error

SetTriggerAliases appends the names of invoked trigger aliases to the DB

func (*Patch) SetVariantsTasks

func (p *Patch) SetVariantsTasks(variantsTasks []VariantTasks) error

SetVariantsTasks updates the variant/tasks pairs in the database. Also updates the Tasks and Variants fields to maintain backwards compatibility between the old and new fields.

func (*Patch) ShouldPatchFileWithDiff

func (p *Patch) ShouldPatchFileWithDiff(path string) bool

ShouldPatchFileWithDiff returns true if the patch should read with diff (i.e. is not a PR or CQ patch) and the config has changed.

func (*Patch) UnmarshalBSON

func (p *Patch) UnmarshalBSON(in []byte) error

func (*Patch) UpdateGithashProjectAndTasks

func (p *Patch) UpdateGithashProjectAndTasks() error

func (*Patch) UpdateMergeCommitSHA

func (p *Patch) UpdateMergeCommitSHA(sha string) error

UpdateMergeCommitSHA updates the merge commit SHA for the patch.

func (*Patch) UpdateModulePatch

func (p *Patch) UpdateModulePatch(modulePatch ModulePatch) error

UpdateModulePatch adds or updates a module within a patch.

func (*Patch) UpdateRepeatPatchId

func (p *Patch) UpdateRepeatPatchId(patchId string) error

UpdateRepeatPatchId updates the repeat patch Id value to be used for subsequent pr patches

func (*Patch) UpdateStatus

func (p *Patch) UpdateStatus(newStatus string) error

func (*Patch) UpdateVariantsTasks

func (p *Patch) UpdateVariantsTasks(variantsTasks []VariantTasks)

UpdateVariantsTasks updates the patch's Tasks and BuildVariants fields to match with the set in the given list of VariantTasks. This is to ensure schema backwards compatibility for T shaped patches. This mutates the patch in memory but does not update it in the database; for that, use SetVariantsTasks.

type PatchSet

type PatchSet struct {
	Patch          string               `bson:"patch,omitempty"`
	PatchFileId    string               `bson:"patch_file_id,omitempty"`
	CommitMessages []string             `bson:"commit_messages,omitempty"`
	Summary        []thirdparty.Summary `bson:"summary"`
}

PatchSet stores information about the actual patch

func CreatePatchSetForSHA

func CreatePatchSetForSHA(ctx context.Context, settings *evergreen.Settings, owner, repo, sha string) (PatchSet, error)

type PatchTriggerDefinition

type PatchTriggerDefinition struct {
	Alias          string          `bson:"alias" json:"alias"`
	ChildProject   string          `bson:"child_project" json:"child_project"`
	TaskSpecifiers []TaskSpecifier `bson:"task_specifiers" json:"task_specifiers"`
	// The parent status that the child patch should run on: failure, success, or *
	Status         string `bson:"status,omitempty" json:"status,omitempty"`
	ParentAsModule string `bson:"parent_as_module,omitempty" json:"parent_as_module,omitempty"`
	// The revision to base the downstream patch off of
	DownstreamRevision string `bson:"downstream_revision,omitempty" json:"downstream_revision,omitempty"`
}

type PatchesByCreateTime

type PatchesByCreateTime []Patch

func (PatchesByCreateTime) Len

func (p PatchesByCreateTime) Len() int

func (PatchesByCreateTime) Less

func (p PatchesByCreateTime) Less(i, j int) bool

func (PatchesByCreateTime) Swap

func (p PatchesByCreateTime) Swap(i, j int)

type SyncAtEndOptions

type SyncAtEndOptions struct {
	// BuildVariants filters which variants will sync.
	BuildVariants []string `bson:"build_variants,omitempty"`
	// Tasks filters which tasks will sync.
	Tasks []string `bson:"tasks,omitempty"`
	// VariantsTasks are the resolved pairs of build variants and tasks that
	// this patch can actually run task sync for.
	VariantsTasks []VariantTasks `bson:"variants_tasks,omitempty"`
	Statuses      []string       `bson:"statuses,omitempty"`
	Timeout       time.Duration  `bson:"timeout,omitempty"`
}

SyncAtEndOptions describes when and how tasks perform sync at the end of a task.

type TaskSpecifier

type TaskSpecifier struct {
	PatchAlias   string `bson:"patch_alias,omitempty" json:"patch_alias,omitempty"`
	TaskRegex    string `bson:"task_regex,omitempty" json:"task_regex,omitempty"`
	VariantRegex string `bson:"variant_regex,omitempty" json:"variant_regex,omitempty"`
}

type TriggerInfo

type TriggerInfo struct {
	Aliases              []string    `bson:"aliases,omitempty"`
	ParentPatch          string      `bson:"parent_patch,omitempty"`
	ParentProjectID      string      `bson:"parent_project_id,omitempty"`
	DownstreamRevision   string      `bson:"downstream_revision,omitempty"`
	SameBranchAsParent   bool        `bson:"same_branch_as_parent"`
	ChildPatches         []string    `bson:"child_patches,omitempty"`
	DownstreamParameters []Parameter `bson:"downstream_parameters,omitempty"`
}

type TriggerIntent

type TriggerIntent struct {
	Id              string `bson:"_id"`
	Requester       string `bson:"requester"`
	Author          string `bson:"author"`
	ProjectID       string `bson:"project_id"`
	ParentID        string `bson:"parent_id"`
	ParentProjectID string `bson:"parent_project"`
	ParentAsModule  string `bson:"parent_as_module"`
	// The parent status that the child patch should run on
	ParentStatus string                   `bson:"parent_status"`
	Definitions  []PatchTriggerDefinition `bson:"definitions"`
	// The revision to base the downstream patch off of
	DownstreamRevision string `bson:"downstream_revision"`

	Processed bool `bson:"processed"`
}

func (*TriggerIntent) GetAlias

func (t *TriggerIntent) GetAlias() string

func (*TriggerIntent) GetCalledBy

func (t *TriggerIntent) GetCalledBy() string

func (*TriggerIntent) GetType

func (t *TriggerIntent) GetType() string

GetType returns the patch intent, e.g., GithubIntentType.

func (*TriggerIntent) ID

func (t *TriggerIntent) ID() string

func (*TriggerIntent) Insert

func (t *TriggerIntent) Insert() error

func (*TriggerIntent) IsProcessed

func (t *TriggerIntent) IsProcessed() bool

func (*TriggerIntent) NewPatch

func (t *TriggerIntent) NewPatch() *Patch

func (*TriggerIntent) RepeatFailedTasksAndVariants

func (g *TriggerIntent) RepeatFailedTasksAndVariants() (string, bool)

func (*TriggerIntent) RepeatPreviousPatchDefinition

func (t *TriggerIntent) RepeatPreviousPatchDefinition() (string, bool)

func (*TriggerIntent) RequesterIdentity

func (t *TriggerIntent) RequesterIdentity() string

func (*TriggerIntent) SetProcessed

func (t *TriggerIntent) SetProcessed() error

func (*TriggerIntent) ShouldFinalizePatch

func (t *TriggerIntent) ShouldFinalizePatch() bool

type TriggerIntentOptions

type TriggerIntentOptions struct {
	Requester          string
	Author             string
	ProjectID          string
	ParentID           string
	ParentProjectID    string
	ParentAsModule     string
	ParentStatus       string
	DownstreamRevision string
	Definitions        []PatchTriggerDefinition
}

type VariantTasks

type VariantTasks struct {
	Variant      string        `bson:"variant"`
	Tasks        []string      `bson:"tasks"`
	DisplayTasks []DisplayTask `bson:"displaytasks"`
}

VariantTasks contains the variant name and the set of tasks to be scheduled for that variant

func MergeVariantsTasks

func MergeVariantsTasks(vts1, vts2 []VariantTasks) []VariantTasks

MergeVariantsTasks merges two slices of VariantsTasks into a single set.

Jump to

Keyboard shortcuts

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