build

package
v0.0.0-...-900fa13 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Collection = "builds"

The MongoDB collection for build documents.

View Source
const IdTimeLayout = "06_01_02_15_04_05"

IdTimeLayout is used time time.Time.Format() to produce timestamps for our ids.

Variables

View Source
var (
	// bson fields for the build struct
	IdKey                  = bsonutil.MustHaveTag(Build{}, "Id")
	CreateTimeKey          = bsonutil.MustHaveTag(Build{}, "CreateTime")
	StartTimeKey           = bsonutil.MustHaveTag(Build{}, "StartTime")
	FinishTimeKey          = bsonutil.MustHaveTag(Build{}, "FinishTime")
	PushTimeKey            = bsonutil.MustHaveTag(Build{}, "PushTime")
	VersionKey             = bsonutil.MustHaveTag(Build{}, "Version")
	ProjectKey             = bsonutil.MustHaveTag(Build{}, "Project")
	RevisionKey            = bsonutil.MustHaveTag(Build{}, "Revision")
	BuildVariantKey        = bsonutil.MustHaveTag(Build{}, "BuildVariant")
	BuildNumberKey         = bsonutil.MustHaveTag(Build{}, "BuildNumber")
	StatusKey              = bsonutil.MustHaveTag(Build{}, "Status")
	ActivatedKey           = bsonutil.MustHaveTag(Build{}, "Activated")
	ActivatedTimeKey       = bsonutil.MustHaveTag(Build{}, "ActivatedTime")
	RevisionOrderNumberKey = bsonutil.MustHaveTag(Build{}, "RevisionOrderNumber")
	TasksKey               = bsonutil.MustHaveTag(Build{}, "Tasks")
	TimeTakenKey           = bsonutil.MustHaveTag(Build{}, "TimeTaken")
	DisplayNameKey         = bsonutil.MustHaveTag(Build{}, "DisplayName")
	RequesterKey           = bsonutil.MustHaveTag(Build{}, "Requester")

	// bson fields for the task caches
	TaskCacheIdKey            = bsonutil.MustHaveTag(TaskCache{}, "Id")
	TaskCacheDisplayNameKey   = bsonutil.MustHaveTag(TaskCache{}, "DisplayName")
	TaskCacheStatusKey        = bsonutil.MustHaveTag(TaskCache{}, "Status")
	TaskCacheStatusDetailsKey = bsonutil.MustHaveTag(TaskCache{}, "StatusDetails")
	TaskCacheStartTimeKey     = bsonutil.MustHaveTag(TaskCache{}, "StartTime")
	TaskCacheTimeTakenKey     = bsonutil.MustHaveTag(TaskCache{}, "TimeTaken")
	TaskCacheActivatedKey     = bsonutil.MustHaveTag(TaskCache{}, "Activated")
)
View Source
var All = db.Query(nil)

All returns all builds.

Functions

func ByAfterRevision

func ByAfterRevision(project, buildVariant string, revision int) db.Q

ByAfterRevision builds a query that returns all builds that happened at or after the given revision for the project/variant. Results are sorted by revision order, ascending.

func ByBeforeRevision

func ByBeforeRevision(project, buildVariant string, revision int) db.Q

ByBeforeRevision builds a query that returns all builds that happened before the given revision for the project/variant. Results are sorted by revision order, descending.

func ByBetweenBuilds

func ByBetweenBuilds(current, previous *Build) db.Q

ByBetweenBuilds returns all builds that happened between the current and previous build.

func ByFinishedAfter

func ByFinishedAfter(finishTime time.Time, project string, requester string) db.Q

ByFinishedAfter creates a query that returns all builds for a project/requester that were finished after the given time.

func ById

func ById(id string) db.Q

ById creates a query that finds a build by its _id.

func ByIds

func ByIds(ids []string) db.Q

ByIds creates a query that finds all builds with the given ids.

func ByProject

func ByProject(proj string) db.Q

ByProject creates a query that finds all builds for a given project id.

func ByRecentlyActivatedForProjectAndVariant

func ByRecentlyActivatedForProjectAndVariant(revision int, project, variant, requester string) db.Q

ByRecentlyActivatedForProjectAndVariant builds a query that returns all builds before a given revision that were activated for a project + variant. Builds are sorted from most to least recent.

func ByRecentlySuccessfulForProjectAndVariant

func ByRecentlySuccessfulForProjectAndVariant(revision int, project, variant string) db.Q

ByRecentlySuccessfulForProjectAndVariant builds a query that returns all builds before a given revision that were sucessful for a project + variant. Builds are sorted from most to least recent.

func ByRevision

func ByRevision(revision string) db.Q

ByRevision creates a query that returns all builds for a revision.

func ByRevisionAndVariant

func ByRevisionAndVariant(revision, variant string) db.Q

ByRevisionAndVariant creates a query that returns the non-patch build for a revision + buildvariant combionation.

func ByVariant

func ByVariant(bv string) db.Q

ByVariant creates a query that finds all builds for a given variant.

func ByVersion

func ByVersion(version string) db.Q

ByVersion creates a query that returns all builds for a given version.

func ByVersions

func ByVersions(vIds []string) db.Q

ByVersions creates a query that finds all builds with the given version ids.

func Remove

func Remove(id string) error

Remove deletes the build of the given id from the database

func ResetCachedTask

func ResetCachedTask(buildId, taskId string) error

ResetCachedTask resets the given task in the cache of the given build.

func SetCachedTaskActivated

func SetCachedTaskActivated(buildId, taskId string, active bool) error

SetCachedTaskActivated sets the given task to active or inactive in the cache of the given build.

func SetCachedTaskDispatched

func SetCachedTaskDispatched(buildId, taskId string) error

SetCachedTaskDispatched sets the given task to "dispatched" in the cache of the given build.

func SetCachedTaskFinished

func SetCachedTaskFinished(buildId, taskId string, detail *apimodels.TaskEndDetail, timeTaken time.Duration) error

SetCachedTaskFinished sets the given task to "finished" along with a time taken in the cache of the given build.

func SetCachedTaskStarted

func SetCachedTaskStarted(buildId, taskId string, startTime time.Time) error

SetCachedTaskStarted sets the given task to "started" in the cache of the given build.

func SetCachedTaskUndispatched

func SetCachedTaskUndispatched(buildId, taskId string) error

SetCachedTaskUndispatched sets the given task to "undispatched" in the cache of the given build.

func SetTasksCache

func SetTasksCache(buildId string, tasks []TaskCache) error

SetTasksCache updates one build with the given id to contain the given task caches.

func TryMarkStarted

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

TryMarkBuildStarted attempts to mark a b as started if it isn't already marked as such

func UpdateActivation

func UpdateActivation(buildId string, active bool) error

UpdateActivation updates one build with the given id to the given activation setting.

func UpdateOne

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

UpdateOne updates one build.

Types

type Build

type Build struct {
	Id                  string        `bson:"_id" json:"_id"`
	CreateTime          time.Time     `bson:"create_time" json:"create_time,omitempty"`
	StartTime           time.Time     `bson:"start_time" json:"start_time,omitempty"`
	FinishTime          time.Time     `bson:"finish_time" json:"finish_time,omitempty"`
	PushTime            time.Time     `bson:"push_time" json:"push_time,omitempty"`
	Version             string        `bson:"version" json:"version,omitempty"`
	Project             string        `bson:"branch" json:"branch,omitempty"`
	Revision            string        `bson:"gitspec" json:"gitspec,omitempty"`
	BuildVariant        string        `bson:"build_variant" json:"build_variant,omitempty"`
	BuildNumber         string        `bson:"build_number" json:"build_number,omitempty"`
	Status              string        `bson:"status" json:"status,omitempty"`
	Activated           bool          `bson:"activated" json:"activated,omitempty"`
	ActivatedTime       time.Time     `bson:"activated_time" json:"activated_time,omitempty"`
	RevisionOrderNumber int           `bson:"order,omitempty" json:"order,omitempty"`
	Tasks               []TaskCache   `bson:"tasks" json:"tasks,omitempty"`
	TimeTaken           time.Duration `bson:"time_taken" json:"time_taken,omitempty"`
	DisplayName         string        `bson:"display_name" json:"display_name,omitempty"`

	// build requester - this is used to help tell the
	// reason this build was created. e.g. it could be
	// because the repotracker requested it (via tracking the
	// repository) or it was triggered by a developer
	// patch request
	Requester string `bson:"r" json:"r,omitempty"`
}

Build represents a set of tasks on one variant of a Project

	e.g. one build might be "Ubuntu with Python 2.4" and
 another might be "OSX with Python 3.0", etc.

func Find

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

Find returns all builds that satisfy the query.

func FindOne

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

FindOne returns one build that satisfies the query.

func (*Build) FindBuildOnBaseCommit

func (b *Build) FindBuildOnBaseCommit() (*Build, error)

FindBuildOnBaseCommit returns the build that a patch build is based on.

func (*Build) FindIntermediateBuilds

func (b *Build) FindIntermediateBuilds(previous *Build) ([]Build, error)

Find all builds on the same project + variant + requester between the current b and the specified previous build.

func (*Build) Insert

func (b *Build) Insert() error

Insert writes the b to the db.

func (*Build) IsFinished

func (b *Build) IsFinished() bool

Returns whether or not the build has finished, based on its status.

func (*Build) MarkFinished

func (b *Build) MarkFinished(status string, finishTime time.Time) error

MarkFinished sets the build to finished status in the database (this does not update task or version data).

func (*Build) PreviousActivated

func (b *Build) PreviousActivated(project string, requester string) (*Build, error)

Find the most recent activated build with the same variant + requester + project as the current build.

func (*Build) PreviousSuccessful

func (b *Build) PreviousSuccessful() (*Build, error)

Find the most recent b on with the same build variant + requester + project as the current build, with any of the specified statuses.

func (*Build) UpdateStatus

func (b *Build) UpdateStatus(status string) error

UpdateStatus sets the build status to the given string.

type TaskCache

type TaskCache struct {
	Id            string                  `bson:"id" json:"id"`
	DisplayName   string                  `bson:"d" json:"display_name"`
	Status        string                  `bson:"s" json:"status"`
	StatusDetails apimodels.TaskEndDetail `bson:"ed" json:"task_end_details"`
	StartTime     time.Time               `bson:"st" json:"start_time"`
	TimeTaken     time.Duration           `bson:"tt" json:"time_taken"`
	Activated     bool                    `bson:"a" json:"activated"`
}

TaskCache represents some duped information about tasks, mainly for ui purposes.

func NewTaskCache

func NewTaskCache(id string, displayName string, activated bool) TaskCache

Creates a new task cache with the specified id, display name, and value for activated.

Jump to

Keyboard shortcuts

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