repotracker

package
Version: v0.0.0-...-e4b0c48 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: Apache-2.0 Imports: 25 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
	DefaultNumConcurrentRequests      = 10
)
View Source
const (
	// the repotracker polls version control (github) for new commits
	RunnerName = "repotracker"
)

Variables

This section is empty.

Functions

func ActivateBuildsForProject

func ActivateBuildsForProject(project model.ProjectRef) (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, githubToken string) 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 CreateManifest

func CreateManifest(v model.Version, proj *model.Project, projectRef *model.ProjectRef, settings *evergreen.Settings) (*manifest.Manifest, error)

func CreateVersionFromConfig

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

func NewMockRepoPoller

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

Creates a new MockRepo poller with the given project settings

Types

type GithubRepositoryPoller

type GithubRepositoryPoller struct {
	ProjectRef *model.ProjectRef
	OauthToken string
}

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

func NewGithubRepositoryPoller

func NewGithubRepositoryPoller(projectRef *model.ProjectRef, oauthToken string) *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.Project, *model.ParserProject, 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 Github ProjectRef that were made after '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.Project, *model.ParserProject, 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.Project, *model.ParserProject, 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

Constructs all versions stored from recent repository revisions 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
t or T : Toggle theme light dark auto
y or Y : Canonical URL