prow

package
v0.0.0-...-87426b5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// OrgName is the name of knative org
	OrgName = "knative"

	// BucketName is the gcs bucket for all knative builds
	BucketName = "knative-prow"
	// Latest is the filename storing latest build number
	Latest = "latest-build.txt"
	// BuildLog is the filename for build log
	BuildLog = "build-log.txt"
	// StartedJSON is the json file containing build started info
	StartedJSON = "started.json"
	// FinishedJSON is the json file containing build finished info
	FinishedJSON = "finished.json"
	// ArtifactsDir is the dir containing artifacts
	ArtifactsDir = "artifacts"

	// PresubmitJob means it runs on unmerged PRs.
	PresubmitJob = "presubmit"
	// PostsubmitJob means it runs on each new commit.
	PostsubmitJob = "postsubmit"
	// PeriodicJob means it runs on a time-basis, unrelated to git changes.
	PeriodicJob = "periodic"
	// BatchJob tests multiple unmerged PRs at the same time.
	BatchJob = "batch"
)

Variables

This section is empty.

Functions

func GetLocalArtifactsDir

func GetLocalArtifactsDir() string

GetLocalArtifactsDir gets the artifacts directory where prow looks for artifacts. By default, it will look at the env var ARTIFACTS.

func Initialize

func Initialize(serviceAccount string) error

Initialize wraps gcs authentication, have to be invoked before any other functions

Types

type Build

type Build struct {
	JobName     string
	StoragePath string
	BuildID     int
	Bucket      string // optional
	StartTime   *int64
	FinishTime  *int64
}

Build points to a build stored under a particular gcs path.

func (*Build) GetArtifacts

func (b *Build) GetArtifacts() []string

GetArtifacts gets gcs path for all artifacts of current build

func (*Build) GetArtifactsDir

func (b *Build) GetArtifactsDir() string

GetArtifactsDir gets gcs path for artifacts of current build

func (*Build) GetBuildLogPath

func (b *Build) GetBuildLogPath() string

GetBuildLogPath gets "build-log.txt" path for current build

func (*Build) GetFinishTime

func (b *Build) GetFinishTime() (int64, error)

GetFinishTime gets finished timestamp of a build, returning -1 if the build didn't finish or if it failed to get the timestamp

func (*Build) GetStartTime

func (b *Build) GetStartTime() (int64, error)

GetStartTime gets started timestamp of a build, returning -1 if the build didn't start or if it failed to get the timestamp

func (*Build) IsFinished

func (b *Build) IsFinished() bool

IsFinished check if build has finished by looking at "finished.json" file

func (*Build) IsStarted

func (b *Build) IsStarted() bool

IsStarted check if build has started by looking at "started.json" file

func (*Build) ParseLog

func (b *Build) ParseLog(checkLog func(s []string) *string) ([]string, error)

ParseLog parses the build log and returns the lines where the checkLog func does not return an empty slice, checkLog function should take in the log statement and return a part from that statement that should be in the log output.

func (*Build) ReadFile

func (b *Build) ReadFile(relPath string) ([]byte, error)

ReadFile reads given file of current build, relPath is the file path relative to build directory

type Finished

type Finished struct {
	// Timestamp is epoch seconds
	Timestamp  int64    `json:"timestamp"`
	Passed     bool     `json:"passed"`
	JobVersion string   `json:"job-version"`
	Metadata   Metadata `json:"metadata"`
}

Finished holds the finished.json values of the build

type Job

type Job struct {
	Name        string
	Type        string
	Bucket      string  // optional
	Repo        string  // optional
	StoragePath string  // optional
	PullID      int     // only for Presubmit jobs
	Builds      []Build // optional
}

Job struct represents a job directory in gcs. gcs job StoragePath will be derived from Type if it's defined,

func NewJob

func NewJob(jobName, jobType, repoName string, pullID int) *Job

NewJob creates new job struct pullID is only saved by Presubmit job for determining StoragePath

func (*Job) GetBuildIDs

func (j *Job) GetBuildIDs() []int

GetBuildIDs gets all build IDs from this job on gcs, scans all direct child of gcs directory for job, keeps the ones that can be parsed as integer

func (*Job) GetBuilds

func (j *Job) GetBuilds() []Build

GetBuilds gets all builds from this job on gcs, precomputes start/finish time of builds by parsing "Started.json" and "Finished.json" on gcs, could be very expensive if there are large number of builds

func (*Job) GetFinishedBuilds

func (j *Job) GetFinishedBuilds() []Build

GetFinishedBuilds gets all builds that have finished, by looking at existence of "finished.json" file

func (*Job) GetLatestBuildNumber

func (j *Job) GetLatestBuildNumber() (int, error)

GetLatestBuildNumber gets the latest build number for job

func (*Job) GetLatestBuilds

func (j *Job) GetLatestBuilds(count int) []Build

GetLatestBuilds get latest builds from gcs, sort by start time from newest to oldest, will return count number of builds

func (*Job) NewBuild

func (j *Job) NewBuild(buildID int) *Build

NewBuild gets build struct based on job info No gcs operation is performed by this function

func (*Job) PathExists

func (j *Job) PathExists() bool

PathExists checks if the storage path of a job exists in gcs or not

type Metadata

type Metadata map[string]interface{}

Metadata contains metadata in finished.json

type Started

type Started struct {
	Timestamp   int64             `json:"timestamp"` // epoch seconds
	RepoVersion string            `json:"repo-version"`
	Node        string            `json:"node"`
	Pull        string            `json:"pull"`
	Repos       map[string]string `json:"repos"` // {repo: branch_or_pull} map
}

Started holds the started.json values of the build.

Jump to

Keyboard shortcuts

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