engine

package
v3.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: LGPL-3.0 Imports: 23 Imported by: 2

README

engine

Documentation

Index

Constants

View Source
const (
	PROFESSIONAL_EDITION string = "professional"
	TEAM_EDITION         string = "team"
	SILENT_MODE          string = "silent"
	VERBOSE_MODE         string = "verbose"
)
View Source
const DefaultMockEventAction = "opened"
View Source
const DefaultMockEventName = "pull_request"
View Source
const DefaultMockPrID = 1234

Use only for tests

View Source
const DefaultMockPrNum = 6
View Source
const DefaultMockPrOwner = "foobar"
View Source
const DefaultMockPrRepoName = "default-mock-repo"

Variables

View Source
var DefaultMockCollector, _ = collector.NewCollector("", "distinctId", "pull_request", "runnerName", nil)
View Source
var DefaultMockCtx = context.Background()

Use only for tests

View Source
var DefaultMockEventDetails = &handler.EventDetails{
	EventName:   DefaultMockEventName,
	EventAction: DefaultMockEventAction,
}
View Source
var DefaultMockEventPayload = &github.CheckRunEvent{}
View Source
var DefaultMockLogger = logrus.NewEntry(logrus.New())
View Source
var DefaultMockTargetEntity = &handler.TargetEntity{
	Owner:  DefaultMockPrOwner,
	Repo:   DefaultMockPrRepoName,
	Number: DefaultMockPrNum,
	Kind:   handler.PullRequest,
}

Functions

func GetDefaultMockPullRequestDetails added in v3.1.0

func GetDefaultMockPullRequestDetails() *github.PullRequest

func Lint

func Lint(file *ReviewpadFile, logger *logrus.Entry) error

func MockGithubClient added in v3.1.0

func MockGithubClient(clientOptions []mock.MockBackendOption) *gh.GithubClient

func MustUnmarshal added in v3.17.0

func MustUnmarshal(data []byte, v interface{})

func MustWriteBytes added in v3.17.0

func MustWriteBytes(w io.Writer, data []byte)

Types

type CheckState added in v3.24.0

type CheckState string
const (
	CheckStateError   CheckState = "error"
	CheckStateFailure CheckState = "failure"
	CheckStatePending CheckState = "pending"
	CheckStateSuccess CheckState = "success"
)

type Env

type Env struct {
	Ctx          context.Context
	DryRun       bool
	GithubClient *gh.GithubClient
	Collector    collector.Collector
	Interpreter  Interpreter
	TargetEntity *handler.TargetEntity
	EventDetails *handler.EventDetails
	Logger       *logrus.Entry
}

func MockEnvWith added in v3.2.0

func MockEnvWith(githubClient *gh.GithubClient, interpreter Interpreter, targetEntity *handler.TargetEntity, eventDetails *handler.EventDetails) (*Env, error)

func NewEvalEnv

func NewEvalEnv(
	ctx context.Context,
	logger *logrus.Entry,
	dryRun bool,
	githubClient *gh.GithubClient,
	collector collector.Collector,
	targetEntity *handler.TargetEntity,
	interpreter Interpreter,
	eventDetails *handler.EventDetails,
) (*Env, error)

type ExitStatus added in v3.2.0

type ExitStatus int
const ExitStatusFailure ExitStatus = 1
const ExitStatusSuccess ExitStatus = 0

type GroupKind

type GroupKind string
const GroupKindDeveloper GroupKind = "developer"

type GroupType

type GroupType string
const GroupTypeFilter GroupType = "filter"
const GroupTypeStatic GroupType = "static"

type Interpreter

type Interpreter interface {
	ProcessGroup(name string, kind GroupKind, typeOf GroupType, expr, paramExpr, whereExpr string) error
	ProcessLabel(id, name string) error
	ProcessRule(name, spec string) error
	EvalExpr(kind, expr string) (bool, error)
	ExecProgram(program *Program) (ExitStatus, error)
	ExecStatement(statement *Statement) error
	Report(mode string, safeMode bool) error
	ReportMetrics() error
}

type LoadEnv

type LoadEnv struct {
	Visited map[string]bool
	Stack   map[string]bool
}

type NormalizeRule added in v3.6.0

type NormalizeRule struct {
	Validators   []validator
	Modificators []modificator
}

func NewNormalizeRule added in v3.6.0

func NewNormalizeRule() *NormalizeRule

func (*NormalizeRule) Do added in v3.6.0

func (*NormalizeRule) WithModificators added in v3.6.0

func (n *NormalizeRule) WithModificators(m ...modificator)

func (*NormalizeRule) WithValidators added in v3.6.0

func (n *NormalizeRule) WithValidators(v ...validator)

type PadGroup

type PadGroup struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Kind        string `yaml:"kind"`
	Type        string `yaml:"type"`
	Spec        string `yaml:"spec"`
	Param       string `yaml:"param"`
	Where       string `yaml:"where"`
}

type PadImport

type PadImport struct {
	Url string `yaml:"url"`
}

type PadLabel

type PadLabel struct {
	Name        string `yaml:"name"`
	Color       string `yaml:"color"`
	Description string `yaml:"description"`
}

type PadPipeline added in v3.2.0

type PadPipeline struct {
	Name        string     `yaml:"name"`
	Description string     `yaml:"description"`
	Trigger     string     `yaml:"trigger"`
	Stages      []PadStage `yaml:"stages"`
}

type PadRule

type PadRule struct {
	Name        string `yaml:"name"`
	Kind        string `yaml:"kind"`
	Description string `yaml:"description"`
	Spec        string `yaml:"spec"`
}

type PadStage added in v3.2.0

type PadStage struct {
	Actions []string `yaml:"actions"`
	Until   string   `yaml:"until"`
}

type PadWorkflow

type PadWorkflow struct {
	Name               string                     `yaml:"name"`
	On                 []handler.TargetEntityKind `yaml:"on"`
	Description        string                     `yaml:"description"`
	AlwaysRun          bool                       `yaml:"always-run"`
	Rules              []PadWorkflowRule          `yaml:"-"`
	Actions            []string                   `yaml:"then"`
	NonNormalizedRules []interface{}              `yaml:"if"`
}

type PadWorkflowRule

type PadWorkflowRule struct {
	Rule         string   `yaml:"rule"`
	ExtraActions []string `yaml:"extra-actions" mapstructure:"extra-actions"`
}

type Program

type Program struct {
	// contains filtered or unexported fields
}

func BuildProgram added in v3.2.0

func BuildProgram(statements []*Statement) *Program

func EvalCommand added in v3.22.0

func EvalCommand(command string, env *Env) (*Program, error)

EvalCommand generates the program to be executed when a command is received

func EvalConfigurationFile added in v3.22.0

func EvalConfigurationFile(file *ReviewpadFile, env *Env) (*Program, error)

EvalConfigurationFile generates the program to be executed Pre-condition Lint(file) == nil

func (*Program) GetProgramStatements added in v3.2.0

func (p *Program) GetProgramStatements() []*Statement

type ReviewpadFile

type ReviewpadFile struct {
	Version        string              `yaml:"api-version"`
	Edition        string              `yaml:"edition"`
	Mode           string              `yaml:"mode"`
	IgnoreErrors   *bool               `yaml:"ignore-errors"`
	MetricsOnMerge *bool               `yaml:"metrics-on-merge"`
	Imports        []PadImport         `yaml:"imports"`
	Extends        []string            `yaml:"extends"`
	Groups         []PadGroup          `yaml:"groups"`
	Rules          []PadRule           `yaml:"rules"`
	Labels         map[string]PadLabel `yaml:"labels"`
	Workflows      []PadWorkflow       `yaml:"workflows"`
	Pipelines      []PadPipeline       `yaml:"pipelines"`
	Recipes        map[string]*bool    `yaml:"recipes"`
}

func Load

func Load(ctx context.Context, logger *logrus.Entry, githubClient *gh.GithubClient, data []byte) (*ReviewpadFile, error)

type Statement

type Statement struct {
	// contains filtered or unexported fields
}

func BuildStatement added in v3.2.0

func BuildStatement(code string) *Statement

func (*Statement) GetStatementCode added in v3.2.0

func (s *Statement) GetStatementCode() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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