Documentation
¶
Index ¶
- Constants
- Variables
- func EvaluateProfile(profile *model.MergeProfile, pr *model.PullRequest, checks []model.CheckRun) (bool, string)
- func FormatDecisionComment(decision *model.PolicyDecision, profileName string) string
- func FormatDecisionJSON(decision *model.PolicyDecision) (string, error)
- func GetProfile(name string) *model.MergeProfile
- func ListProfiles() []string
- func LoadProfileFromBytes(data []byte) (*model.MergeProfile, error)
- func LoadProfileFromFile(path string) (*model.MergeProfile, error)
- func OutcomeEmoji(outcome model.DecisionOutcome) string
- func SaveProfileToFile(profile *model.MergeProfile, path string) error
- type CedarEngine
- func (e *CedarEngine) CanMerge(ctx context.Context, pctx *model.PolicyContext) (*model.PolicyDecision, error)
- func (e *CedarEngine) CanReview(ctx context.Context, pctx *model.PolicyContext) (*model.PolicyDecision, error)
- func (e *CedarEngine) Evaluate(ctx context.Context, action model.PolicyAction, pctx *model.PolicyContext) (*model.PolicyDecision, error)
- func (e *CedarEngine) LoadPolicies(path string) error
- func (e *CedarEngine) PolicyCount() int
- func (e *CedarEngine) Profile() *model.MergeProfile
- type ContextBuilder
- type Engine
- func (e *Engine) CanMerge(ctx context.Context, pr *model.PullRequest, checks []model.CheckRun) (*model.PolicyDecision, error)
- func (e *Engine) CanRelease(ctx context.Context) (*model.PolicyDecision, error)
- func (e *Engine) CanReview(ctx context.Context, pr *model.PullRequest, checks []model.CheckRun) (*model.PolicyDecision, error)
- func (e *Engine) Evaluate(ctx context.Context, action model.PolicyAction, pr *model.PullRequest, ...) (*model.PolicyDecision, error)
Constants ¶
const CommentMarker = "<!-- versionconductor-decision -->"
CommentMarker is used to identify VersionConductor comments for updates.
Variables ¶
var ( // ProfileAggressive merges all passing PRs immediately. ProfileAggressive = model.MergeProfile{ Name: "aggressive", Description: "Merge all passing dependency PRs immediately", MinAgeHours: 0, MinAgeDays: 0, MaxAgeHours: 0, AutoMergePatch: true, AutoMergeMinor: true, AutoMergeMajor: true, RequireAllChecks: true, AllowPendingChecks: false, MergeStrategy: "squash", DeleteBranch: true, RequireApproval: false, MaxPRsPerRun: 0, } // ProfileBalanced waits 24h and only merges patch/minor updates. ProfileBalanced = model.MergeProfile{ Name: "balanced", Description: "Wait 24h, auto-merge patch and minor updates only", MinAgeHours: 24, MinAgeDays: 1, MaxAgeHours: 0, AutoMergePatch: true, AutoMergeMinor: true, AutoMergeMajor: false, RequireAllChecks: true, AllowPendingChecks: false, MergeStrategy: "squash", DeleteBranch: true, RequireApproval: false, MaxPRsPerRun: 10, } // ProfileConservative requires manual review for all but patch updates. ProfileConservative = model.MergeProfile{ Name: "conservative", Description: "Auto-merge only patch updates after 48h, manual review for others", MinAgeHours: 48, MinAgeDays: 2, MaxAgeHours: 0, AutoMergePatch: true, AutoMergeMinor: false, AutoMergeMajor: false, RequireAllChecks: true, AllowPendingChecks: false, MergeStrategy: "squash", DeleteBranch: true, RequireApproval: true, MaxPRsPerRun: 5, } // ProfileQuarantine implements N+5 day waiting period for Go dependencies. // This is the recommended profile for automated Go dependency updates. ProfileQuarantine = model.MergeProfile{ Name: "quarantine", Description: "N+5 day quarantine: auto-merge patch/minor after 5 days, Go-only", MinAgeHours: 120, MinAgeDays: 5, MaxAgeHours: 0, AutoMergePatch: true, AutoMergeMinor: true, AutoMergeMajor: false, RequireAllChecks: true, AllowPendingChecks: false, MergeStrategy: "squash", DeleteBranch: true, RequireApproval: false, MaxPRsPerRun: 1, } )
Predefined merge profiles.
Functions ¶
func EvaluateProfile ¶
func EvaluateProfile(profile *model.MergeProfile, pr *model.PullRequest, checks []model.CheckRun) (bool, string)
EvaluateProfile evaluates a PR against a merge profile. Returns true if the PR should be merged according to the profile.
func FormatDecisionComment ¶ added in v0.4.0
func FormatDecisionComment(decision *model.PolicyDecision, profileName string) string
FormatDecisionComment formats a PolicyDecision as a markdown comment for PR audit trail.
func FormatDecisionJSON ¶ added in v0.4.0
func FormatDecisionJSON(decision *model.PolicyDecision) (string, error)
FormatDecisionJSON formats a PolicyDecision as JSON for machine consumption. This is useful for GitHub Action outputs.
func GetProfile ¶
func GetProfile(name string) *model.MergeProfile
GetProfile returns a merge profile by name.
func LoadProfileFromBytes ¶
func LoadProfileFromBytes(data []byte) (*model.MergeProfile, error)
LoadProfileFromBytes loads a merge profile from YAML bytes.
func LoadProfileFromFile ¶
func LoadProfileFromFile(path string) (*model.MergeProfile, error)
LoadProfileFromFile loads a merge profile from a YAML file.
func OutcomeEmoji ¶ added in v0.4.0
func OutcomeEmoji(outcome model.DecisionOutcome) string
OutcomeEmoji returns an appropriate emoji for the decision outcome.
func SaveProfileToFile ¶
func SaveProfileToFile(profile *model.MergeProfile, path string) error
SaveProfileToFile saves a merge profile to a YAML file.
Types ¶
type CedarEngine ¶ added in v0.4.0
type CedarEngine struct {
// contains filtered or unexported fields
}
CedarEngine evaluates Cedar policies for PR merge decisions.
func NewCedarEngine ¶ added in v0.4.0
func NewCedarEngine(policyPath string, profileName string) (*CedarEngine, error)
NewCedarEngine creates a new Cedar policy engine. If policyPath is empty, uses the default profile-based evaluation. If policyPath is provided, loads Cedar policies from that file or directory.
func (*CedarEngine) CanMerge ¶ added in v0.4.0
func (e *CedarEngine) CanMerge(ctx context.Context, pctx *model.PolicyContext) (*model.PolicyDecision, error)
CanMerge evaluates whether a PR can be auto-merged.
func (*CedarEngine) CanReview ¶ added in v0.4.0
func (e *CedarEngine) CanReview(ctx context.Context, pctx *model.PolicyContext) (*model.PolicyDecision, error)
CanReview evaluates whether a PR can be auto-reviewed.
func (*CedarEngine) Evaluate ¶ added in v0.4.0
func (e *CedarEngine) Evaluate(ctx context.Context, action model.PolicyAction, pctx *model.PolicyContext) (*model.PolicyDecision, error)
Evaluate evaluates the policy for the given action and context.
func (*CedarEngine) LoadPolicies ¶ added in v0.4.0
func (e *CedarEngine) LoadPolicies(path string) error
LoadPolicies loads Cedar policies from a file or directory.
func (*CedarEngine) PolicyCount ¶ added in v0.4.0
func (e *CedarEngine) PolicyCount() int
PolicyCount returns the number of loaded policies.
func (*CedarEngine) Profile ¶ added in v0.4.0
func (e *CedarEngine) Profile() *model.MergeProfile
Profile returns the merge profile associated with this engine.
type ContextBuilder ¶
type ContextBuilder struct{}
ContextBuilder builds PolicyContext from PR and check information.
func NewContextBuilder ¶
func NewContextBuilder() *ContextBuilder
NewContextBuilder creates a new context builder.
func (*ContextBuilder) Build ¶
func (b *ContextBuilder) Build(pr *model.PullRequest, repo *model.Repo, checks []model.CheckRun) *model.PolicyContext
Build creates a PolicyContext from a PR and its checks.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine evaluates policies for PR merge decisions. This is a simplified implementation that uses merge profiles. Cedar policy support can be added in a future version.
func NewEngineWithProfile ¶
func NewEngineWithProfile(profile *model.MergeProfile) *Engine
NewEngineWithProfile creates a new policy engine with the given profile.
func (*Engine) CanMerge ¶
func (e *Engine) CanMerge(ctx context.Context, pr *model.PullRequest, checks []model.CheckRun) (*model.PolicyDecision, error)
CanMerge evaluates whether a PR can be auto-merged.
func (*Engine) CanRelease ¶
CanRelease evaluates whether a release can be created.
func (*Engine) CanReview ¶
func (e *Engine) CanReview(ctx context.Context, pr *model.PullRequest, checks []model.CheckRun) (*model.PolicyDecision, error)
CanReview evaluates whether a PR can be auto-reviewed.
func (*Engine) Evaluate ¶
func (e *Engine) Evaluate(ctx context.Context, action model.PolicyAction, pr *model.PullRequest, checks []model.CheckRun) (*model.PolicyDecision, error)
Evaluate evaluates the policy for the given action and context.