execution

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 45 Imported by: 0

Documentation

Overview

Package execution discovers normalized CI definitions from registered local projects. It intentionally accepts store project records instead of arbitrary filesystem roots so callers cannot expand the service's discovery boundary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrencyDefinition added in v0.6.0

type ConcurrencyDefinition struct {
	Group            string `json:"group"`
	CancelInProgress bool   `json:"cancelInProgress,omitempty"`
	Limit            int    `json:"limit,omitempty"`
}

type Definition

type Definition struct {
	Key              string                 `json:"key"`
	ProjectID        string                 `json:"projectId,omitempty"`
	ProjectSlug      string                 `json:"projectSlug,omitempty"`
	ProjectPath      string                 `json:"projectPath"`
	Provider         Provider               `json:"provider"`
	File             string                 `json:"file"`
	Name             string                 `json:"name"`
	Environment      map[string]string      `json:"environment"`
	Stages           []string               `json:"stages"`
	Triggers         []string               `json:"triggers"`
	TriggerPolicies  []triggerpolicy.Policy `json:"triggerPolicies,omitempty"`
	Concurrency      *ConcurrencyDefinition `json:"concurrency,omitempty"`
	Jobs             []JobDefinition        `json:"jobs"`
	TopologicalOrder []string               `json:"topologicalOrder"`
}

Definition is a provider-neutral workflow definition ready to be stored by a control plane. File is always a slash-separated path relative to ProjectPath, while Key is stable for a registered project and source file.

func Discover

func Discover(projects []store.Project) ([]Definition, error)

Discover discovers GitHub Actions and GitLab CI definitions from the canonical local paths stored on registered projects. Projects without a CanonicalPath are intentionally skipped: remote-only records are not a filesystem discovery target.

Results are sorted by canonical project path, source file, and provider. Workflow files are checked before parsing, so symlinked paths and paths outside a registered project never reach a provider parser.

func DiscoverProject

func DiscoverProject(project store.Project) ([]Definition, error)

DiscoverProject is the single-project form of Discover. It has the same canonical-path and workflow-path safety guarantees.

type ErrRunnerUnavailable added in v0.11.0

type ErrRunnerUnavailable struct {
	Jobs []UnavailableRunnerJob `json:"jobs"`
}

func (*ErrRunnerUnavailable) Error added in v0.11.0

func (err *ErrRunnerUnavailable) Error() string

type JobDefinition

type JobDefinition struct {
	Key                  string                               `json:"key"`
	SourceKey            string                               `json:"sourceKey,omitempty"`
	Name                 string                               `json:"name"`
	Environment          map[string]string                    `json:"environment"`
	EnvironmentName      string                               `json:"environmentName,omitempty"`
	DeploymentTier       string                               `json:"deploymentTier,omitempty"`
	Needs                []string                             `json:"needs"`
	Requires             []string                             `json:"requires"`
	ArtifactDependencies []string                             `json:"artifactDependencies,omitempty"`
	DependenciesDefined  bool                                 `json:"dependenciesDefined,omitempty"`
	NeedsArtifacts       map[string]bool                      `json:"needsArtifacts,omitempty"`
	Stage                string                               `json:"stage,omitempty"`
	RunnerHint           string                               `json:"runnerHint,omitempty"`
	RunnerRequirements   []string                             `json:"runnerRequirements,omitempty"`
	RunnerGroup          string                               `json:"runnerGroup,omitempty"`
	RunnerMatch          runnerinventory.Match                `json:"runnerMatch"`
	AllowFailure         bool                                 `json:"allowFailure"`
	TimeoutMinutes       int                                  `json:"timeoutMinutes,omitempty"`
	RollbackCommand      string                               `json:"rollbackCommand,omitempty"`
	VerifyCommand        string                               `json:"verifyCommand,omitempty"`
	Matrix               map[string]string                    `json:"matrix,omitempty"`
	MatrixIndex          int                                  `json:"matrixIndex,omitempty"`
	MatrixTotal          int                                  `json:"matrixTotal,omitempty"`
	MatrixLabel          string                               `json:"matrixLabel,omitempty"`
	Condition            executionsemantics.ConditionContract `json:"condition"`
	Rules                []RuleDefinition                     `json:"rules,omitempty"`
	Only                 *OnlyExceptDefinition                `json:"only,omitempty"`
	Except               *OnlyExceptDefinition                `json:"except,omitempty"`
	When                 string                               `json:"when,omitempty"`
	ManualConfirmation   string                               `json:"manualConfirmation,omitempty"`
	Concurrency          *ConcurrencyDefinition               `json:"concurrency,omitempty"`
	Interruptible        bool                                 `json:"interruptible,omitempty"`
	FailFast             bool                                 `json:"failFast,omitempty"`
	MaxParallel          int                                  `json:"maxParallel,omitempty"`
	WorkflowCall         *types.WorkflowCall                  `json:"workflowCall,omitempty"`
	Container            *types.Container                     `json:"container,omitempty"`
	Services             map[string]*types.Service            `json:"services,omitempty"`
	Artifacts            *types.ArtifactConfig                `json:"artifacts,omitempty"`
	Cache                *types.CacheConfig                   `json:"cache,omitempty"`
	Outputs              map[string]string                    `json:"outputs,omitempty"`
	Steps                []StepDefinition                     `json:"steps"`
}

JobDefinition is a provider-neutral, persistence-ready job. Key is the source job identifier; Needs and Requires therefore reference keys rather than presentation names.

type Manager

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

Manager owns workflow synchronization, immutable run creation, and one local execution worker. The registered project path is snapshotted before a run enters the queue; workers never accept arbitrary paths or commands from HTTP requests.

func NewManager

func NewManager(database *store.Store, options ...Option) (*Manager, error)

func (*Manager) EnqueueDeploymentRollback

func (m *Manager) EnqueueDeploymentRollback(ctx context.Context, params store.EnqueueRollbackParams) (store.Run, error)

func (*Manager) EnqueueRunReplay

func (m *Manager) EnqueueRunReplay(ctx context.Context, params store.EnqueueReplayParams) (store.Run, error)

func (*Manager) EnqueueTriggered

func (m *Manager) EnqueueTriggered(ctx context.Context, workflowID, ref, commitSHA, trigger string) (store.Run, error)

func (*Manager) EnqueueWorkflow

func (m *Manager) EnqueueWorkflow(ctx context.Context, workflowID, ref, commitSHA string) (store.Run, error)

EnqueueWorkflow creates a complete immutable run graph from the currently active stored workflow definition.

func (*Manager) EnqueueWorkflowWithInputs added in v0.6.0

func (m *Manager) EnqueueWorkflowWithInputs(ctx context.Context, workflowID, ref, commitSHA string, inputs map[string]string) (store.Run, error)

func (*Manager) Notify

func (m *Manager) Notify()

func (*Manager) OpenRunArtifact added in v0.7.0

func (m *Manager) OpenRunArtifact(ctx context.Context, runID, artifactID string) (store.Artifact, *os.File, error)

func (*Manager) PlayManualJob added in v0.24.0

func (*Manager) ProcessNext

func (m *Manager) ProcessNext(ctx context.Context) (bool, error)

ProcessNext claims and executes at most one queued run. It is public to make deterministic service integration tests possible without timing sleeps.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context) error

Run recovers expired worker leases, then drains queued runs serially.

func (*Manager) RunnerInventory added in v0.11.0

func (m *Manager) RunnerInventory() runnerinventory.Inventory

func (*Manager) SyncProject

func (m *Manager) SyncProject(ctx context.Context, projectID string) ([]store.Workflow, error)

SyncProject discovers provider files beneath one registered project and makes that exact set active. Removed definitions stay stored but inactive so historical runs retain their workflow foreign key.

type OnlyExceptDefinition added in v0.6.0

type OnlyExceptDefinition struct {
	Refs      []string `json:"refs,omitempty"`
	Changes   []string `json:"changes,omitempty"`
	Variables []string `json:"variables,omitempty"`
}

type Option

type Option func(*Manager)

func WithDataRoot added in v0.7.0

func WithDataRoot(root string) Option

func WithRunnerInventory added in v0.11.0

func WithRunnerInventory(inventory runnerinventory.Inventory) Option

func WithSecretResolver

func WithSecretResolver(resolver SecretResolver) Option

func WithWorkspaceRoot

func WithWorkspaceRoot(root string) Option

type Provider

type Provider string

Provider identifies the CI provider that produced a Definition.

const (
	// ProviderGitHubActions is the normalized provider identifier for GitHub
	// Actions workflow files.
	ProviderGitHubActions Provider = "github"
	// ProviderGitLabCI is the normalized provider identifier for GitLab CI
	// configuration files.
	ProviderGitLabCI Provider = "gitlab"
)

type RuleDefinition added in v0.6.0

type RuleDefinition struct {
	Condition    executionsemantics.ConditionContract `json:"condition"`
	When         string                               `json:"when,omitempty"`
	Changes      []string                             `json:"changes,omitempty"`
	Exists       []string                             `json:"exists,omitempty"`
	Variables    map[string]string                    `json:"variables,omitempty"`
	AllowFailure bool                                 `json:"allowFailure,omitempty"`
}

type SecretResolver

type SecretResolver interface {
	ResolveProject(context.Context, string) (map[string]string, error)
}

type StepDefinition

type StepDefinition struct {
	Key              string                               `json:"key"`
	Name             string                               `json:"name"`
	Command          string                               `json:"command,omitempty"`
	Action           string                               `json:"action,omitempty"`
	Environment      map[string]string                    `json:"environment"`
	WorkingDirectory string                               `json:"workingDirectory,omitempty"`
	TimeoutMinutes   int                                  `json:"timeoutMinutes,omitempty"`
	Shell            string                               `json:"shell,omitempty"`
	AllowFailure     bool                                 `json:"allowFailure"`
	Condition        executionsemantics.ConditionContract `json:"condition"`
	Inputs           map[string]string                    `json:"inputs,omitempty"`
	Artifacts        *types.ArtifactConfig                `json:"artifacts,omitempty"`
	Cache            *types.CacheConfig                   `json:"cache,omitempty"`
}

StepDefinition is a provider-neutral, persistence-ready execution step. Command holds the shell/script command when available; Action preserves a provider action reference such as actions/checkout@v4.

type UnavailableRunnerJob added in v0.11.0

type UnavailableRunnerJob struct {
	Key     string   `json:"key"`
	Name    string   `json:"name"`
	Missing []string `json:"missing"`
	Reason  string   `json:"reason"`
}

Jump to

Keyboard shortcuts

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