Documentation ¶
Index ¶
- Constants
- Variables
- func ExecConfigurationFile(env *Env, file *ReviewpadFile) (ExitStatus, *Program, error)
- func GetDefaultMockPullRequestDetails() *github.PullRequest
- func Lint(file *ReviewpadFile, reserved []string, logger *logrus.Entry) error
- func MockGithubClient(clientOptions []mock.MockBackendOption) *gh.GithubClient
- func MustUnmarshal(data []byte, v interface{})
- func MustWriteBytes(w io.Writer, data []byte)
- type CheckState
- type Env
- type ExitStatus
- type GroupKind
- type GroupType
- type Interpreter
- type LoadEnv
- type NormalizeRule
- type PadCheck
- type PadDictionary
- type PadGroup
- type PadImport
- type PadLabel
- type PadPipeline
- type PadRule
- type PadStage
- type PadWorkflow
- type PadWorkflowRule
- type PadWorkflowRunBlock
- type PadWorkflowRunForEachBlock
- type Program
- type ReviewpadFile
- type Statement
Constants ¶
View Source
const ( 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 = &entities.EventDetails{ EventName: DefaultMockEventName, EventAction: DefaultMockEventAction, }
View Source
var DefaultMockEventPayload = &github.CheckRunEvent{}
View Source
var DefaultMockLogger = logrus.NewEntry(logrus.New())
View Source
var DefaultMockTargetEntity = &entities.TargetEntity{ Owner: DefaultMockPrOwner, Repo: DefaultMockPrRepoName, Number: DefaultMockPrNum, Kind: entities.PullRequest, }
Functions ¶
func ExecConfigurationFile ¶ added in v4.10.0
func ExecConfigurationFile(env *Env, file *ReviewpadFile) (ExitStatus, *Program, error)
ExecConfigurationFile processes Pre-condition Lint(file) == nil
func GetDefaultMockPullRequestDetails ¶
func GetDefaultMockPullRequestDetails() *github.PullRequest
func MockGithubClient ¶
func MockGithubClient(clientOptions []mock.MockBackendOption) *gh.GithubClient
func MustUnmarshal ¶
func MustUnmarshal(data []byte, v interface{})
func MustWriteBytes ¶
Types ¶
type CheckState ¶
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 *entities.TargetEntity EventDetails *entities.EventDetails Logger *logrus.Entry }
func MockEnvWith ¶
func MockEnvWith(githubClient *gh.GithubClient, interpreter Interpreter, targetEntity *entities.TargetEntity, eventDetails *entities.EventDetails) (*Env, error)
func NewEvalEnv ¶
func NewEvalEnv( ctx context.Context, logger *logrus.Entry, dryRun bool, githubClient *gh.GithubClient, collector collector.Collector, targetEntity *entities.TargetEntity, interpreter Interpreter, eventDetails *entities.EventDetails, ) (*Env, error)
type ExitStatus ¶
type ExitStatus int
const ExitStatusFailure ExitStatus = 1
const ExitStatusSuccess ExitStatus = 0
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 GetCheckRunConclusion() string ProcessIterable(expr string) (lang.Value, error) StoreTemporaryVariable(name string, value lang.Value) ProcessDictionary(name string, dictionary map[string]string) error }
type NormalizeRule ¶
type NormalizeRule struct { Validators []validator Modificators []modificator }
func NewNormalizeRule ¶
func NewNormalizeRule() *NormalizeRule
func (*NormalizeRule) Do ¶
func (n *NormalizeRule) Do(file *ReviewpadFile) (*ReviewpadFile, error)
func (*NormalizeRule) WithModificators ¶
func (n *NormalizeRule) WithModificators(m ...modificator)
func (*NormalizeRule) WithValidators ¶
func (n *NormalizeRule) WithValidators(v ...validator)
type PadDictionary ¶ added in v4.14.0
type PadPipeline ¶
type PadWorkflow ¶
type PadWorkflow struct { Name string `yaml:"name"` On []entities.TargetEntityKind `yaml:"on"` Description string `yaml:"description"` AlwaysRun bool `yaml:"always-run"` Rules []PadWorkflowRule `yaml:"-"` Actions []string `yaml:"-"` Runs []PadWorkflowRunBlock `yaml:"-"` NonNormalizedRules any `yaml:"if"` NonNormalizedActions any `yaml:"then"` NonNormalizedElse any `yaml:"else"` NonNormalizedRun any `yaml:"run"` }
type PadWorkflowRule ¶
type PadWorkflowRunBlock ¶ added in v4.7.0
type PadWorkflowRunBlock struct { If []PadWorkflowRule Then []PadWorkflowRunBlock Else []PadWorkflowRunBlock Actions []string ForEach *PadWorkflowRunForEachBlock }
type PadWorkflowRunForEachBlock ¶ added in v4.12.0
type PadWorkflowRunForEachBlock struct { Key string Value string In string Do []PadWorkflowRunBlock }
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
func BuildProgram ¶
func EvalCommand ¶
EvalCommand generates the program to be executed when a command is received
func EvalConfigurationFile ¶
func EvalConfigurationFile(file *ReviewpadFile, env *Env) (*Program, error)
EvalConfigurationFile generates the program to be executed Pre-condition Lint(file) == nil
func (*Program) GetProgramStatements ¶
type ReviewpadFile ¶
type ReviewpadFile struct { 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"` Checks map[string]PadCheck `yaml:"checks"` Rules []PadRule `yaml:"rules"` Labels map[string]PadLabel `yaml:"labels"` Workflows []PadWorkflow `yaml:"workflows"` Pipelines []PadPipeline `yaml:"pipelines"` Recipes map[string]*bool `yaml:"recipes"` Dictionaries []PadDictionary `yaml:"dictionaries"` }
type Statement ¶
type Statement struct {
// contains filtered or unexported fields
}
func BuildStatement ¶
func (*Statement) GetStatementCode ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.