repotracker

package
v0.0.0-...-e25005f 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: 14

Documentation

Overview

Package repotracker tracks GitHub repositories, listening for new commits and pull requests.

Index

Constants

View Source
const (
	// determines the default maximum number of revisions to fetch for a newly tracked repo
	// if not specified in configuration file
	DefaultNumNewRepoRevisionsToFetch = 200
	DefaultMaxRepoRevisionsToSearch   = 50
)
View Source
const (
	// the repotracker polls version control (github) for new commits
	RunnerName = "repotracker"
)

Variables

This section is empty.

Functions

func ActivateBuildsForProject

func ActivateBuildsForProject(ctx context.Context, project model.ProjectRef, ts time.Time) (bool, error)

func AddBuildBreakSubscriptions

func AddBuildBreakSubscriptions(v *model.Version, projectRef *model.ProjectRef) error

AddBuildBreakSubscriptions will subscribe admins of a project to a version if no one else would receive a build break notification

func CheckGithubAPIResources

func CheckGithubAPIResources(ctx context.Context) bool

CheckGithubAPIResources returns true when the github API is ready, accessible and with sufficient quota to satisfy our needs

func CollectRevisionsForProject

func CollectRevisionsForProject(ctx context.Context, conf *evergreen.Settings, project model.ProjectRef) error

func CreateVersionFromConfig

func CreateVersionFromConfig(ctx context.Context, projectInfo *model.ProjectInfo,
	metadata model.VersionMetadata, ignore bool, versionErrs *VersionErrors) (*model.Version, error)

CreateVersionFromConfig will create a version document from a project config and insert it into the database along with its associated tasks and builds.

func NewMockRepoPoller

func NewMockRepoPoller(mockProject *model.ParserProject, mockRevisions []model.Revision) *mockRepoPoller

Creates a new MockRepo poller with the given project settings

func ShellVersionFromRevision

func ShellVersionFromRevision(ref *model.ProjectRef, metadata model.VersionMetadata) (*model.Version, error)

ShellVersionFromRevision populates a new Version with metadata from a model.Revision. Does not populate its config or store anything in the database.

Types

type GithubRepositoryPoller

type GithubRepositoryPoller struct {
	ProjectRef *model.ProjectRef
}

GithubRepositoryPoller is a struct that implements GitHub specific behavior required of a RepoPoller

func NewGithubRepositoryPoller

func NewGithubRepositoryPoller(projectRef *model.ProjectRef) *GithubRepositoryPoller

NewGithubRepositoryPoller constructs and returns a pointer to a GithubRepositoryPoller struct

func (*GithubRepositoryPoller) GetChangedFiles

func (gRepoPoller *GithubRepositoryPoller) GetChangedFiles(ctx context.Context, commitRevision string) ([]string, error)

GetRemoteConfig fetches the contents of a remote github repository's configuration data as at a given revision

func (*GithubRepositoryPoller) GetRecentRevisions

func (gRepoPoller *GithubRepositoryPoller) GetRecentRevisions(maxRevisions int) ([]model.Revision, error)

GetRecentRevisions fetches the most recent 'numRevisions'

func (*GithubRepositoryPoller) GetRemoteConfig

func (gRepoPoller *GithubRepositoryPoller) GetRemoteConfig(ctx context.Context, projectFileRevision string) (model.ProjectInfo, error)

GetRemoteConfig fetches the contents of a remote github repository's configuration data as at a given revision

func (*GithubRepositoryPoller) GetRevisionsSince

func (gRepoPoller *GithubRepositoryPoller) GetRevisionsSince(revision string, maxRevisionsToSearch int) ([]model.Revision, error)

GetRevisionsSince fetches the all commits from the corresponding project ref that were made after 'revision'. If it finds the revision within the maxRevisionsToSearch limit, it will return all commits more recent than that revision, in order of most recent to least recent. Otherwise, if it cannot find the revision, it will attempt to add the base revision between the most recent commit and the given revision.

type RepoPoller

type RepoPoller interface {
	// Fetches the contents of a remote repository's configuration data as at
	// the given revision.
	GetRemoteConfig(ctx context.Context, revision string) (model.ProjectInfo, error)

	// Fetches a list of all filepaths modified by a given revision.
	GetChangedFiles(ctx context.Context, revision string) ([]string, error)

	// Fetches all changes since the 'revision' specified - with the most recent
	// revision appearing as the first element in the slice.
	//
	// 'maxRevisionsToSearch' determines the maximum number of revisions we
	// allow to search through - in order to find 'revision' - before we give
	// up. A value <= 0 implies we allow to search through till we hit the first
	// revision for the project.
	GetRevisionsSince(sinceRevision string, maxRevisions int) ([]model.Revision, error)
	// Fetches the most recent 'numNewRepoRevisionsToFetch' revisions for a
	// project - with the most recent revision appearing as the first element in
	// the slice.
	GetRecentRevisions(numNewRepoRevisionsToFetch int) ([]model.Revision, error)
}

The RepoPoller interface specifies behavior required of all repository poller implementations

type RepoTracker

type RepoTracker struct {
	*evergreen.Settings
	*model.ProjectRef
	RepoPoller
}

RepoTracker is used to manage polling repository changes and storing such changes. It contains a number of interfaces that specify behavior required by client implementations

func (*RepoTracker) FetchRevisions

func (repoTracker *RepoTracker) FetchRevisions(ctx context.Context) error

The FetchRevisions method is used by a RepoTracker to run the pipeline for tracking repositories. It performs everything from polling the repository to persisting any changes retrieved from the repository reference.

func (*RepoTracker) GetProjectConfig

func (repoTracker *RepoTracker) GetProjectConfig(ctx context.Context, revision string) (model.ProjectInfo, error)

GetProjectConfig fetches the project configuration for a given repository returning a remote config if the project references a remote repository configuration file - via the Id. Otherwise it defaults to the local project file. An erroneous project file may be returned along with an error.

func (*RepoTracker) StoreRevisions

func (repoTracker *RepoTracker) StoreRevisions(ctx context.Context, revisions []model.Revision) error

StoreRevisions constructs all versions stored from recent repository revisions. The revisions should be given in order of most recent to least recent commit. The additional complexity is due to support for project modifications on patch builds. We need to parse the remote config as it existed when each revision was created. The return value is the most recent version created as a result of storing the revisions. This function is idempotent with regard to storing the same version multiple times.

type VersionErrors

type VersionErrors struct {
	Errors   []string
	Warnings []string
}

Jump to

Keyboard shortcuts

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