Documentation
¶
Index ¶
- Constants
- func Analyse(ctx context.Context, logger logger.Logger, exec Executer, cloner Cloner, ...) error
- func Suppress(issues []db.Issue, max int) (int, []db.Issue)
- type Analyser
- type Cloner
- type Config
- type ConfigReader
- type Docker
- type DockerExecuter
- type Executer
- type FileSystem
- type FileSystemExecuter
- type FixedRef
- type MergeBase
- type NonZeroError
- type PullRequestCloner
- type PushCloner
- type RefReader
- type RepoConfig
- type Reporter
- type YAMLConfig
Constants ¶
const (
// ArgBaseBranch replaces tool arg with the name of the base branch
ArgBaseBranch = "%BASE_BRANCH%"
)
const ( // DockerDefaultImage defines the default docker image that can be used // to run checks. DockerDefaultImage = "gopherci/gopherci-env:latest" )
const MaxIssueComments = 10
MaxIssueComments is the maximum number of comments that will be written on a pull request by writeissues. a pr may have more comments written if writeissues is called multiple times, such is multiple syncronise events.
Variables ¶
This section is empty.
Functions ¶
func Analyse ¶
func Analyse(ctx context.Context, logger logger.Logger, exec Executer, cloner Cloner, configReader ConfigReader, refReader RefReader, config Config, analysis *db.Analysis) error
Analyse downloads a repository set in config in an environment provided by exec, running the series of tools. Writes results to provided analysis, or an error. The repository is expected to contain at least one Go package.
Types ¶
type Analyser ¶
type Analyser interface { // NewExecuter returns an Executer with the working directory set to // $GOPATH/src/<goSrcPath>. NewExecuter(ctx context.Context, goSrcPath string) (Executer, error) }
An Analyser is builds an isolated execution environment to run checks in. It should provide isolation from other environments and support being called concurrently.
type Cloner ¶
A Cloner uses the executer to clone the root of a repository into the current working directory.
type Config ¶
type Config struct { // HeadRef is the name of the reference containing changes. HeadRef string }
Config hold configuration options for use in analyser. All options are required.
type ConfigReader ¶
type ConfigReader interface {
Read(context.Context, Executer) (RepoConfig, error)
}
A ConfigReader returns a repository's configuration.
type Docker ¶
type Docker struct {
// contains filtered or unexported fields
}
Docker is an Analyser that provides an Executer to build projects inside Docker containers.
type DockerExecuter ¶
type DockerExecuter struct {
// contains filtered or unexported fields
}
DockerExecuter is an Executer that runs commands in a contained environment for a single project.
type Executer ¶
type Executer interface { // Execute executes a command and returns the combined stdout and stderr, // along with an error if any. Must not be called after Stop(). If the // command returns a non-zero exit code, an error of type NonZeroError // is returned. Execute(context.Context, []string) ([]byte, error) // Stop stops the executer and allows it to cleanup, if applicable. Stop(context.Context) error }
Executer executes a single command in a contained environment.
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem is an Analyser than provides an Executer to build contained environments on the file system.
FileSystem is safe to use concurrently, as all directories are created with random file names.
func NewFileSystem ¶
func NewFileSystem(base string, memLimit int) (*FileSystem, error)
NewFileSystem returns an FileSystem which uses the path base to build contained environments on the file system. If memLimit is > 0, limit the amount of memory (MiB) a process can use.
func (*FileSystem) NewExecuter ¶
NewExecuter implements the Analyser interface
type FileSystemExecuter ¶
type FileSystemExecuter struct {
// contains filtered or unexported fields
}
FileSystemExecuter is an Executer that runs commands in a contained environment.
type FixedRef ¶
type FixedRef struct {
BaseRef string
}
FixedRef is a RefReader for handling events where we know the base ref and can just return the string.
type MergeBase ¶
type MergeBase struct{}
MergeBase is a RefReader for handling pull requests by using git's merge-base tool to find the common ancestor between HEAD and FETCH_HEAD. It expects head to already be checked out, and base to be fetched with full history.
type NonZeroError ¶
type NonZeroError struct { ExitCode int // ExitCode is the non zero exit code // contains filtered or unexported fields }
NonZeroError maybe returned by an Executer when the command executed returns with a non-zero exit status.
func (*NonZeroError) Error ¶
func (e *NonZeroError) Error() string
Error implements the error interface.
type PullRequestCloner ¶
PullRequestCloner is a Cloner for handling cloning the HeadURL at HeadRef and also fetches BaseURL at BaseRef.
type PushCloner ¶
PushCloner is a Cloner for handling cloning of HeadURL and checking out HeadRef.
type RepoConfig ¶
RepoConfig contains the analyser configuration for the repository.
type YAMLConfig ¶
type YAMLConfig struct {
Tools []db.Tool // Preset tools to use, before per repo config has been applied
}
YAMLConfig implements a ConfigReader by reading a yaml configuration file from the repositories root.
func (*YAMLConfig) Read ¶
func (c *YAMLConfig) Read(ctx context.Context, exec Executer) (RepoConfig, error)
Read implements the ConfigReader interface.