client

package
v0.12.9 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeStateSuccess = "success"
	NodeStateFailure = "failure"
	NodeStateSkipped = "skipped"
)

Node and run state values used throughout the DAG engine.

View Source
const (
	StableEventArtifactInitiate      = "artifact.initiate"
	StableEventArtifactPublished     = "artifact.published"
	StableEventSystemFailure         = "system.failure"
	StableEventSecurityAlarm         = "security.alarm"
	StableEventCommunicationReceived = "communication.received"
)
View Source
const (
	WorkflowActionRunCommand          = "run_command"
	WorkflowActionLegacyCommand       = "command"
	WorkflowActionHTTPRequest         = "send_http_request"
	WorkflowActionProjectMessage      = "send_project_message"
	WorkflowActionTriggerProjectEvent = "trigger_project_event"

	ResponseModeNoop        = "noop"
	ResponseModeSendData    = "send_data"
	ResponseModeIterateData = "iterate_data"
)
View Source
const (
	WorkflowScopeRepo   = "repo"
	WorkflowScopeGlobal = "global"
)

Workflow scope values.

Variables

View Source
var ErrStableEventBuiltIn = errors.New("built-in stable events cannot be deleted or renamed")
View Source
var GitHubWebhookEvents = map[string][]string{
	"branch_protection_configuration": {"disabled", "enabled"},
	"branch_protection_rule":          {"created", "deleted", "edited"},
	"check_run":                       {"completed", "created", "requested_action", "rerequested"},
	"check_suite":                     {"completed", "requested", "rerequested"},
	"code_scanning_alert":             {"appeared_in_branch", "closed_by_user", "created", "fixed", "reopened", "reopened_by_user"},
	"commit_comment":                  {"created"},
	"create":                          {},
	"custom_property":                 {"created", "deleted", "updated"},
	"custom_property_values":          {"updated"},
	"delete":                          {},
	"dependabot_alert":                {"auto_dismissed", "auto_reopened", "created", "dismissed", "fixed", "reintroduced", "reopened"},
	"deploy_key":                      {"created", "deleted"},
	"deployment":                      {"created"},
	"deployment_protection_rule":      {"requested"},
	"deployment_review":               {"approved", "rejected", "requested"},
	"deployment_status":               {"created"},
	"discussion":                      {"answered", "category_changed", "created", "deleted", "edited", "labeled", "locked", "pinned", "transferred", "unanswered", "unlabeled", "unlocked", "unpinned"},
	"discussion_comment":              {"created", "deleted", "edited"},
	"fork":                            {},
	"github_app_authorization":        {"revoked"},
	"gollum":                          {},
	"installation":                    {"created", "deleted", "new_permissions_accepted", "suspend", "unsuspend"},
	"installation_repositories":       {"added", "removed"},
	"installation_target":             {"renamed"},
	"issue_comment":                   {"created", "deleted", "edited"},
	"issues":                          {"assigned", "closed", "deleted", "demilestoned", "edited", "labeled", "locked", "milestoned", "opened", "pinned", "reopened", "transferred", "unassigned", "unlabeled", "unlocked", "unpinned"},
	"label":                           {"created", "deleted", "edited"},
	"marketplace_purchase":            {"cancelled", "changed", "pending_change", "pending_change_cancelled", "purchased"},
	"member":                          {"added", "edited", "removed"},
	"membership":                      {"added", "removed"},
	"merge_group":                     {"checks_requested", "destroyed"},
	"meta":                            {"deleted"},
	"milestone":                       {"closed", "created", "deleted", "edited", "opened"},
	"org_block":                       {"blocked", "unblocked"},
	"organization":                    {"deleted", "member_added", "member_invited", "member_removed", "renamed"},
	"package":                         {"published", "updated"},
	"page_build":                      {},
	"personal_access_token_request":   {"approved", "cancelled", "created", "denied"},
	"ping":                            {},
	"project":                         {"closed", "created", "deleted", "edited", "reopened"},
	"project_card":                    {"converted", "created", "deleted", "edited", "moved"},
	"project_column":                  {"created", "deleted", "edited", "moved"},
	"projects_v2":                     {"closed", "created", "deleted", "edited", "reopened"},
	"projects_v2_item":                {"archived", "converted", "created", "deleted", "edited", "reordered", "restored"},
	"projects_v2_status_update":       {"created", "deleted", "edited"},
	"public":                          {},
	"pull_request":                    {"assigned", "auto_merge_disabled", "auto_merge_enabled", "closed", "converted_to_draft", "demilestoned", "dequeued", "edited", "enqueued", "labeled", "locked", "milestoned", "opened", "ready_for_review", "reopened", "review_request_removed", "review_requested", "synchronize", "unassigned", "unlabeled", "unlocked"},
	"pull_request_review":             {"dismissed", "edited", "submitted"},
	"pull_request_review_comment":     {"created", "deleted", "edited"},
	"pull_request_review_thread":      {"resolved", "unresolved"},
	"push":                            {},
	"registry_package":                {"published", "updated"},
	"release":                         {"created", "deleted", "edited", "prereleased", "published", "released", "unpublished"},
	"repository":                      {"archived", "created", "deleted", "edited", "privatized", "publicized", "renamed", "transferred", "unarchived"},
	"repository_advisory":             {"published", "reported"},
	"repository_dispatch":             {},
	"repository_import":               {},
	"repository_ruleset":              {"created", "deleted", "edited"},
	"repository_vulnerability_alert":  {"create", "dismiss", "resolve"},
	"secret_scanning_alert":           {"created", "resolved", "reopened", "validated"},
	"secret_scanning_alert_location":  {"created"},
	"security_advisory":               {"performed", "published", "updated", "withdrawn"},
	"security_and_analysis":           {},
	"sponsorship":                     {"cancelled", "created", "edited", "pending_cancellation", "pending_tier_change", "tier_changed"},
	"star":                            {"created", "deleted"},
	"status":                          {},
	"sub_issues":                      {"parent_issue_added", "parent_issue_removed", "sub_issue_added", "sub_issue_removed"},
	"team":                            {"added_to_repository", "created", "deleted", "edited", "removed_from_repository"},
	"team_add":                        {},
	"watch":                           {"started"},
	"workflow_dispatch":               {},
	"workflow_job":                    {"completed", "in_progress", "queued", "waiting"},
	"workflow_run":                    {"completed", "in_progress", "requested"},
}

GitHubWebhookEvents maps each GitHub webhook event type to its known action values. Events with an empty slice have no action field. This reference is provided for the workflow editor's event-type dropdowns; it is NOT used for runtime validation since GitHub may add new events or actions at any time.

Source: https://docs.github.com/en/webhooks/webhook-events-and-payloads

View Source
var Version = "dev"

Version is set at build time via -ldflags "-X main.version=...". It is copied from the main package at startup.

Functions

func Checkout

func Checkout(repoPath string, event protocol.EventMsg) error

Checkout switches to the correct ref based on the event.

func CurrentGitState added in v0.7.0

func CurrentGitState(repoPath string) (string, string, error)

CurrentGitState returns the checked-out ref name and commit hash for a repo.

func EnsureRepo

func EnsureRepo(reposDir, repoName, cloneURL string) (string, error)

EnsureRepo clones the repo if it doesn't exist, or fetches if it does.

func ProviderEventOptions added in v0.12.9

func ProviderEventOptions() []selectOption

func Run

func Run(ctx context.Context, cfg Config)

Run connects to the relay and processes events. Reconnects on failure.

func RunHookWithOutput

func RunHookWithOutput(ctx context.Context, repoPath, hook, hookLabel string, event protocol.EventMsg) (string, error)

RunHookWithOutput executes a single shell command in the repo directory with the standard EVENTIC_* environment and returns its trimmed combined output.

func ShouldNotify added in v0.5.0

func ShouldNotify(notifyOn []string, state string) bool

ShouldNotify checks whether a notification should fire based on the notify_on filter and the current state. An empty filter means always notify.

func StartAutoUpdater added in v0.2.0

func StartAutoUpdater(ctx context.Context)

StartAutoUpdater runs a background loop that checks for new releases every 5 minutes. When a newer version is found it replaces the running binary and exits so systemd (or the parent supervisor) can restart the service.

func StartRepoChecker added in v0.3.0

func StartRepoChecker(ctx context.Context, cfg Config)

StartRepoChecker runs a background loop that periodically walks the repos directory and verifies every cloned repository is healthy. Repos that are missing a .git directory or fail a basic git sanity check are re-cloned on the default branch. Repos already checked out on a branch are left as-is.

Repos are checked one at a time to avoid overwhelming the system.

func StartWebConsole added in v0.6.0

func StartWebConsole(ctx context.Context, cfg Config, logStore *ExecutionLog, projectStore *ProjectStore, replay ReplayDispatcher) error

func Validate added in v0.12.0

func Validate(g Graph) error

Validate checks referential integrity (every edge endpoint references a known node) and rejects cycles via a Kahn topological sort. It returns a descriptive error on the first dangling edge or detected cycle.

Types

type ApprovalData added in v0.5.0

type ApprovalData struct {
	Repos   map[string]bool `json:"repos"`
	Senders map[string]bool `json:"senders"`
}

type ApprovalStore added in v0.5.0

type ApprovalStore struct {
	Data ApprovalData
	// contains filtered or unexported fields
}

ApprovalStore manages persistent approval of repositories and senders.

func NewApprovalStore added in v0.5.0

func NewApprovalStore(path string) *ApprovalStore

func (*ApprovalStore) ApproveRepo added in v0.5.0

func (s *ApprovalStore) ApproveRepo(repo string) error

func (*ApprovalStore) ApproveSender added in v0.5.0

func (s *ApprovalStore) ApproveSender(sender string) error

func (*ApprovalStore) IsApproved added in v0.5.0

func (s *ApprovalStore) IsApproved(repo, sender string) bool

func (*ApprovalStore) List added in v0.5.0

func (s *ApprovalStore) List() string

func (*ApprovalStore) RevokeRepo added in v0.5.0

func (s *ApprovalStore) RevokeRepo(repo string) error

func (*ApprovalStore) RevokeSender added in v0.5.0

func (s *ApprovalStore) RevokeSender(sender string) error

type Config

type Config struct {
	Relay           string          `yaml:"relay"`
	Token           string          `yaml:"token"`
	ClientID        string          `yaml:"client_id"`
	ReposDir        string          `yaml:"repos_dir"`
	Subscribe       []string        `yaml:"subscribe"`
	AutoUpdate      bool            `yaml:"auto-update"`
	AutoCheck       *bool           `yaml:"auto-check"`
	MaxWorkers      int             `yaml:"max-workers"`
	MaxNodeWorkers  int             `yaml:"max-node-workers"`
	LogLevel        string          `yaml:"log-level"`
	DefaultNotify   string          `yaml:"default-notify"`
	DefaultNotifyOn []string        `yaml:"default-notify-on"`
	Notifier        notifier.Config `yaml:"notifier"`
	RequireApproval bool            `yaml:"require_approval"`
	ApprovalsPath   string          `yaml:"approvals_path"`
	Web             WebConfig       `yaml:"web"`
	State           StateConfig     `yaml:"state"`
}

type DAGEdge added in v0.12.0

type DAGEdge struct {
	From      string // source node key
	To        string // destination node key
	Condition string // "", "always", "success", "failure", or "NAME == value" / "NAME != value"
}

DAGEdge is a directed, optionally-conditional link from one node to another.

type DAGStep added in v0.12.0

type DAGStep struct {
	Key             string        // unique node key within the graph
	Name            string        // human-readable label
	Type            string        // typed action executed by the NodeRunner
	Command         string        // shell command for run_command nodes
	Capture         string        // when non-empty, the var name to store trimmed stdout under
	ContinueOnError bool          // a failure here does not fail the overall run
	Timeout         time.Duration // per-node timeout; 0 means no timeout
	Config          string        // action-specific JSON configuration
}

DAGStep is a single executable node in a workflow graph. It is intentionally free of persistence and execution concerns so the engine stays unit-testable.

type EventMapping added in v0.12.7

type EventMapping struct {
	ID                int64             `json:"id"`
	MappingID         string            `json:"mapping_id"`
	Provider          string            `json:"provider"`
	Name              string            `json:"name"`
	Enabled           bool              `json:"enabled"`
	Priority          int64             `json:"priority"`
	Conditions        map[string]string `json:"conditions"`
	TargetStableEvent string            `json:"target_stable_event"`
	CreatedAt         time.Time         `json:"created_at"`
	UpdatedAt         time.Time         `json:"updated_at"`
}

EventMapping maps provider-specific webhook fields to one stable internal event key used by workflow resolution.

type ExecutionEvent added in v0.6.0

type ExecutionEvent struct {
	ID             string          `json:"id"`
	DeliveryID     string          `json:"delivery_id"`
	Repo           string          `json:"repo"`
	Ref            string          `json:"ref,omitempty"`
	Event          string          `json:"event"`
	StableEvent    string          `json:"stable_event,omitempty"`
	Provider       string          `json:"provider,omitempty"`
	ExternalEvent  string          `json:"external_event,omitempty"`
	ExternalAction string          `json:"external_action,omitempty"`
	Action         string          `json:"action,omitempty"`
	Sender         string          `json:"sender,omitempty"`
	State          string          `json:"state"`
	Description    string          `json:"description,omitempty"`
	StartedAt      time.Time       `json:"started_at"`
	FinishedAt     *time.Time      `json:"finished_at,omitempty"`
	UpdatedAt      time.Time       `json:"updated_at"`
	DurationMillis int64           `json:"duration_ms,omitempty"`
	Hooks          []HookExecution `json:"hooks"`
}

ExecutionEvent is a compact, local-only view of an Eventic event execution.

type ExecutionLog added in v0.6.0

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

func NewExecutionLog added in v0.6.0

func NewExecutionLog(cfg WebConfig) *ExecutionLog

func (*ExecutionLog) AddHook added in v0.6.0

func (l *ExecutionLog) AddHook(deliveryID, name, state, output string)

func (*ExecutionLog) Events added in v0.6.0

func (l *ExecutionLog) Events() []ExecutionEvent

func (*ExecutionLog) FinishEvent added in v0.6.0

func (l *ExecutionLog) FinishEvent(deliveryID, state, desc string) *ExecutionEvent

func (*ExecutionLog) FinishHook added in v0.6.0

func (l *ExecutionLog) FinishHook(deliveryID, name, state, output string)

func (*ExecutionLog) StartEvent added in v0.6.0

func (l *ExecutionLog) StartEvent(event protocol.EventMsg) ExecutionEvent

func (*ExecutionLog) StartHook added in v0.6.0

func (l *ExecutionLog) StartHook(deliveryID, name string)

func (*ExecutionLog) Subscribe added in v0.6.0

func (l *ExecutionLog) Subscribe() (<-chan ExecutionEvent, func())

type Graph added in v0.12.0

type Graph struct {
	Nodes map[string]DAGStep
	Order []string
	Edges []DAGEdge
}

Graph is a resolved workflow ready for validation and execution. Order preserves the authored node sequence so deterministic (single-worker) execution mirrors author intent.

func BuildGraph added in v0.12.0

func BuildGraph(nodes []WorkflowNode, edges []WorkflowEdge) (Graph, error)

BuildGraph converts persisted workflow nodes and edges into an executable Graph. Node order follows the authored node slice order.

type HookExecution added in v0.6.0

type HookExecution struct {
	Name           string     `json:"name"`
	State          string     `json:"state"`
	Output         string     `json:"output,omitempty"`
	StartedAt      time.Time  `json:"started_at"`
	FinishedAt     *time.Time `json:"finished_at,omitempty"`
	DurationMillis int64      `json:"duration_ms,omitempty"`
}

HookExecution records one local hook run and its bounded combined output.

type NodeResult added in v0.12.0

type NodeResult struct {
	Key      string
	State    string
	ExitCode int
	Output   string
}

NodeResult records the terminal outcome of a single node. State is one of NodeStateSuccess, NodeStateFailure, or NodeStateSkipped.

func Execute added in v0.12.0

func Execute(ctx context.Context, g Graph, rc *RunContext, run NodeRunner, maxNodeWorkers int) ([]NodeResult, error)

Execute runs the graph honoring DAG dependencies, conditional edges, skip propagation, and a per-run concurrency bound (maxNodeWorkers). It returns the results for every node in authored order (including skipped nodes).

Scheduling rules:

  • A node is ELIGIBLE once all parents have reached a terminal state.
  • A node RUNS if it is a root (no parents) OR at least one incoming edge whose source actually ran (not skipped) has a satisfied condition. Otherwise the node is SKIPPED. Skips propagate downstream.
  • Eligible, runnable nodes execute concurrently under a semaphore.

type NodeRunner added in v0.12.0

type NodeRunner func(ctx context.Context, step DAGStep, rc *RunContext) NodeResult

NodeRunner executes a single step and returns its result. It is injected into Execute so the scheduler has no direct dependency on os/exec or the DB.

type NormalizedEvent added in v0.12.7

type NormalizedEvent struct {
	ID                  string            `json:"id"`
	Source              string            `json:"source"`
	StableEvent         string            `json:"stable_event"`
	Timestamp           time.Time         `json:"timestamp"`
	Actor               string            `json:"actor,omitempty"`
	Metadata            map[string]string `json:"metadata,omitempty"`
	RawPayloadReference string            `json:"raw_payload_reference,omitempty"`
}

NormalizedEvent is the strict shape produced by the inbound normalization layer before a workflow is resolved.

func NormalizeInboundEvent added in v0.12.7

func NormalizeInboundEvent(ctx context.Context, store *ProjectStore, event protocol.EventMsg) (protocol.EventMsg, NormalizedEvent, error)

NormalizeInboundEvent applies persisted declarative mappings to an event. The returned EventMsg keeps the original provider event fields intact and only fills StableEvent when a mapping matches or the sender already supplied one.

type ProjectEvent added in v0.8.0

type ProjectEvent struct {
	Repo           string     `json:"repo"`
	DeliveryID     string     `json:"delivery_id"`
	Ref            string     `json:"ref,omitempty"`
	Hash           string     `json:"hash,omitempty"`
	Event          string     `json:"event,omitempty"`
	Action         string     `json:"action,omitempty"`
	State          string     `json:"state"`
	LatestOutput   string     `json:"latest_output,omitempty"`
	Description    string     `json:"description,omitempty"`
	StartedAt      time.Time  `json:"started_at"`
	FinishedAt     *time.Time `json:"finished_at,omitempty"`
	UpdatedAt      time.Time  `json:"updated_at"`
	DurationMillis int64      `json:"duration_ms,omitempty"`
}

ProjectEvent is a bounded persisted execution history item for one repo.

type ProjectState added in v0.7.0

type ProjectState struct {
	Repo           string         `json:"repo"`
	Ref            string         `json:"ref,omitempty"`
	Hash           string         `json:"hash,omitempty"`
	Event          string         `json:"event,omitempty"`
	Action         string         `json:"action,omitempty"`
	DeliveryID     string         `json:"delivery_id,omitempty"`
	State          string         `json:"state"`
	LatestOutput   string         `json:"latest_output,omitempty"`
	Description    string         `json:"description,omitempty"`
	StartedAt      time.Time      `json:"started_at"`
	FinishedAt     *time.Time     `json:"finished_at,omitempty"`
	UpdatedAt      time.Time      `json:"updated_at"`
	DurationMillis int64          `json:"duration_ms,omitempty"`
	RecentEvents   []ProjectEvent `json:"recent_events,omitempty"`
}

ProjectState is the persisted latest state for a managed repository.

type ProjectStore added in v0.7.0

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

func OpenMemoryProjectStore added in v0.9.0

func OpenMemoryProjectStore(ctx context.Context) (*ProjectStore, error)

func OpenProjectStore added in v0.7.0

func OpenProjectStore(ctx context.Context, cfg StateConfig) (*ProjectStore, error)

func (*ProjectStore) Close added in v0.7.0

func (s *ProjectStore) Close() error

func (*ProjectStore) CreateEventMapping added in v0.12.7

func (s *ProjectStore) CreateEventMapping(ctx context.Context, mapping *EventMapping) (int64, error)

func (*ProjectStore) CreateStableEvent added in v0.12.9

func (s *ProjectStore) CreateStableEvent(ctx context.Context, stableEvent *StableEventDefinition) (int64, error)

func (*ProjectStore) CreateWorkflow added in v0.12.0

func (s *ProjectStore) CreateWorkflow(ctx context.Context, wf *Workflow) (int64, error)

CreateWorkflow inserts a new workflow plus its nodes and edges in a single transaction and returns the new workflow id.

func (*ProjectStore) DeleteEventMapping added in v0.12.7

func (s *ProjectStore) DeleteEventMapping(ctx context.Context, id int64) error

func (*ProjectStore) DeleteStableEvent added in v0.12.9

func (s *ProjectStore) DeleteStableEvent(ctx context.Context, id int64) error

func (*ProjectStore) DeleteWorkflow added in v0.12.0

func (s *ProjectStore) DeleteWorkflow(ctx context.Context, id int64) error

DeleteWorkflow removes a workflow and its nodes/edges.

func (*ProjectStore) FinishProject added in v0.7.0

func (s *ProjectStore) FinishProject(ctx context.Context, event ExecutionEvent)

func (*ProjectStore) FinishRun added in v0.12.0

func (s *ProjectStore) FinishRun(ctx context.Context, runID int64, state string)

FinishRun marks a run terminal, recording its final state and duration derived from its recorded start time.

func (*ProjectStore) FinishRunNode added in v0.12.0

func (s *ProjectStore) FinishRunNode(ctx context.Context, runID int64, nodeKey, state string, exitCode int, output string)

FinishRunNode marks a run node terminal, recording its state, exit code, and bounded output. The node duration is derived from its recorded start time.

func (*ProjectStore) GetProject added in v0.7.0

func (s *ProjectStore) GetProject(ctx context.Context, repo string) (*ProjectState, error)

func (*ProjectStore) GetRun added in v0.12.0

func (s *ProjectStore) GetRun(ctx context.Context, id int64) (*WorkflowRun, error)

GetRun returns a single run with its per-node execution records.

func (*ProjectStore) GetStableEvent added in v0.12.9

func (s *ProjectStore) GetStableEvent(ctx context.Context, id int64) (*StableEventDefinition, error)

func (*ProjectStore) GetWorkflow added in v0.12.0

func (s *ProjectStore) GetWorkflow(ctx context.Context, id int64) (*Workflow, error)

GetWorkflow returns a single workflow with its nodes and edges populated.

func (*ProjectStore) ListEventMappings added in v0.12.7

func (s *ProjectStore) ListEventMappings(ctx context.Context) ([]EventMapping, error)

func (*ProjectStore) ListProjectEvents added in v0.8.0

func (s *ProjectStore) ListProjectEvents(ctx context.Context, repo string, limit int) ([]ProjectEvent, error)

func (*ProjectStore) ListProjectSummaries added in v0.12.3

func (s *ProjectStore) ListProjectSummaries(ctx context.Context, org, search string) ([]ProjectSummary, error)

func (*ProjectStore) ListProjects added in v0.7.0

func (s *ProjectStore) ListProjects(ctx context.Context) ([]string, error)

func (*ProjectStore) ListRuns added in v0.12.0

func (s *ProjectStore) ListRuns(ctx context.Context, repo string, limit int) ([]WorkflowRun, error)

ListRuns returns recent run summaries (without per-node detail) for a repo, newest first. An empty repo lists across all repos.

func (*ProjectStore) ListStableEvents added in v0.12.9

func (s *ProjectStore) ListStableEvents(ctx context.Context) ([]StableEventDefinition, error)

func (*ProjectStore) ListWorkflows added in v0.12.0

func (s *ProjectStore) ListWorkflows(ctx context.Context, scope, repo, eventType string) ([]Workflow, error)

ListWorkflows returns workflow summaries (without nodes/edges) filtered by the supplied scope, repo, and eventType. Empty filter values are ignored.

func (*ProjectStore) PruneProjectEvents added in v0.8.0

func (s *ProjectStore) PruneProjectEvents(ctx context.Context, repo string, retain int)

func (*ProjectStore) PruneRuns added in v0.12.0

func (s *ProjectStore) PruneRuns(ctx context.Context, repo string, retain int)

PruneRuns retains only the newest `retain` runs for a repo, deleting older runs and their node records.

func (*ProjectStore) RecordProjectEvent added in v0.8.0

func (s *ProjectStore) RecordProjectEvent(ctx context.Context, event ExecutionEvent)

func (*ProjectStore) ResolveWorkflow added in v0.12.0

func (s *ProjectStore) ResolveWorkflow(ctx context.Context, repo, eventType, action string) (*Workflow, error)

ResolveWorkflow selects the most specific enabled workflow for an event using the precedence:

(repo, event.action) → (repo, event) → (global, event.action) → (global, event)

It returns (nil, nil) when no enabled workflow matches.

func (*ProjectStore) SeedFromReposDir added in v0.7.0

func (s *ProjectStore) SeedFromReposDir(ctx context.Context, reposDir string, _ Config)

func (*ProjectStore) SetWorkflowEnabled added in v0.12.0

func (s *ProjectStore) SetWorkflowEnabled(ctx context.Context, id int64, enabled bool) error

SetWorkflowEnabled toggles a workflow's enabled flag.

func (*ProjectStore) StartProject added in v0.7.0

func (s *ProjectStore) StartProject(ctx context.Context, event ExecutionEvent)

func (*ProjectStore) StartRun added in v0.12.0

func (s *ProjectStore) StartRun(ctx context.Context, run *WorkflowRun) (int64, error)

StartRun inserts a workflow_runs row in the running state and returns its id.

func (*ProjectStore) StartRunNode added in v0.12.0

func (s *ProjectStore) StartRunNode(ctx context.Context, runID int64, nodeKey string)

StartRunNode inserts (or resets) a workflow_run_nodes row in the running state.

func (*ProjectStore) UpdateEventMapping added in v0.12.7

func (s *ProjectStore) UpdateEventMapping(ctx context.Context, mapping *EventMapping) error

func (*ProjectStore) UpdateGitState added in v0.7.0

func (s *ProjectStore) UpdateGitState(ctx context.Context, repo, ref, hash string)

func (*ProjectStore) UpdateOutput added in v0.7.0

func (s *ProjectStore) UpdateOutput(ctx context.Context, repo string, _ protocol.EventMsg, _, state, output string)

UpdateOutput records the latest output and state for a repo's current run on both the projects summary row and the active project_events history row.

func (*ProjectStore) UpdateStableEvent added in v0.12.9

func (s *ProjectStore) UpdateStableEvent(ctx context.Context, stableEvent *StableEventDefinition) error

func (*ProjectStore) UpdateWorkflow added in v0.12.0

func (s *ProjectStore) UpdateWorkflow(ctx context.Context, wf *Workflow) error

UpdateWorkflow updates a workflow's metadata and fully replaces its nodes and edges inside a transaction, bumping the workflow version.

func (*ProjectStore) UpsertManagedProject added in v0.7.0

func (s *ProjectStore) UpsertManagedProject(ctx context.Context, repo, ref, hash string)

type ProjectSummary added in v0.12.3

type ProjectSummary struct {
	Repo      string    `json:"repo"`
	Owner     string    `json:"owner"`
	Name      string    `json:"name"`
	State     string    `json:"state"`
	UpdatedAt time.Time `json:"updated_at"`
}

ProjectSummary is the compact repository shape used by navigation and overview lists.

type ProviderEvent added in v0.12.9

type ProviderEvent struct {
	Provider    string            `json:"provider"`
	Event       string            `json:"event"`
	Action      string            `json:"action,omitempty"`
	Label       string            `json:"label"`
	Description string            `json:"description,omitempty"`
	Conditions  map[string]string `json:"conditions"`
}

ProviderEvent describes a provider-facing event pattern that can be dragged onto a stable event target to create a declarative mapping.

func FilterProviderEvents added in v0.12.9

func FilterProviderEvents(provider string) []ProviderEvent

func ProviderEventCatalog added in v0.12.9

func ProviderEventCatalog() []ProviderEvent

type ReplayDispatcher added in v0.11.4

type ReplayDispatcher func(context.Context, protocol.EventMsg)

type ReplayRef added in v0.11.4

type ReplayRef struct {
	Ref  string `json:"ref"`
	Type string `json:"type"`
	Hash string `json:"hash,omitempty"`
}

type RepoLocks added in v0.3.0

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

RepoLocks provides per-repository mutual exclusion so that concurrent events targeting the same repo are serialized (queued), while events for different repos run in parallel.

func NewRepoLocks added in v0.3.0

func NewRepoLocks() *RepoLocks

func (*RepoLocks) Lock added in v0.3.0

func (r *RepoLocks) Lock(repo string)

Lock acquires the mutex for the given repository. If another goroutine holds the lock for the same repo, the caller blocks until it is released.

func (*RepoLocks) Unlock added in v0.3.0

func (r *RepoLocks) Unlock(repo string)

Unlock releases the mutex for the given repository.

type RunContext added in v0.12.0

type RunContext struct {
	Vars         map[string]string
	WorkspaceDir string
	BaseEnv      []string
}

RunContext is the shared, mutable execution context handed to every node. Vars accumulates captured outputs (and seeds condition evaluation); WorkspaceDir is a per-run scratch directory; BaseEnv is the inherited process environment the NodeRunner extends.

type StableEventDefinition added in v0.12.7

type StableEventDefinition struct {
	ID             int64     `json:"id,omitempty"`
	Event          string    `json:"event"`
	Title          string    `json:"title"`
	Group          string    `json:"group"`
	Description    string    `json:"description"`
	Enabled        bool      `json:"enabled"`
	BuiltIn        bool      `json:"built_in"`
	ExampleSources []string  `json:"example_sources"`
	WorkflowUses   []string  `json:"workflow_uses"`
	CreatedAt      time.Time `json:"created_at,omitempty"`
	UpdatedAt      time.Time `json:"updated_at,omitempty"`
}

StableEventDefinition describes one workflow-facing event key. These values are intentionally provider-agnostic and are safe for workflow subscriptions.

func StableEventDefinitions added in v0.12.7

func StableEventDefinitions() []StableEventDefinition

StableEventDefinitions returns the canonical stable event catalog shown in the dashboard and used by workflow dropdowns.

type StateConfig added in v0.7.0

type StateConfig struct {
	Enabled bool   `yaml:"enabled"`
	Path    string `yaml:"path"`
}

StateConfig controls the client-local persistent project database.

type WebConfig added in v0.6.0

type WebConfig struct {
	Enabled        bool   `yaml:"enabled"`
	Listen         string `yaml:"listen"`
	MaxEvents      int    `yaml:"max_events"`
	MaxOutputBytes int    `yaml:"max_output_bytes"`
	// StaticDir, when set and containing an index.html, is served at "/" so the
	// user can drop a custom ndesign dashboard there. When empty a minimal
	// embedded shell is served instead.
	StaticDir string `yaml:"static_dir"`
	// Token, when set, gates the live WebSocket stream: clients must supply a
	// matching "?token=" query parameter. When empty the stream is open (the
	// localhost console default).
	Token string `yaml:"token"`
}

WebConfig controls the client-local execution console.

type Workflow added in v0.12.0

type Workflow struct {
	ID        int64          `json:"id"`
	Scope     string         `json:"scope"`
	Repo      string         `json:"repo"`
	EventType string         `json:"event_type"`
	Name      string         `json:"name"`
	Enabled   bool           `json:"enabled"`
	Version   int64          `json:"version"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	Nodes     []WorkflowNode `json:"nodes,omitempty"`
	Edges     []WorkflowEdge `json:"edges,omitempty"`
}

Workflow is a per-(scope, repo, event_type) DAG of command nodes authored from the dashboard. Nodes and Edges are populated by GetWorkflow and consumed by CreateWorkflow/UpdateWorkflow.

type WorkflowEdge added in v0.12.0

type WorkflowEdge struct {
	ID        int64  `json:"id"`
	FromNode  string `json:"from_node"`
	ToNode    string `json:"to_node"`
	Condition string `json:"condition"`
}

WorkflowEdge is a directed, optionally-conditional link between two nodes.

type WorkflowNode added in v0.12.0

type WorkflowNode struct {
	ID              int64   `json:"id"`
	NodeKey         string  `json:"node_key"`
	Name            string  `json:"name"`
	Type            string  `json:"type"`
	Command         string  `json:"command"`
	Capture         string  `json:"capture"`
	ContinueOnError bool    `json:"continue_on_error"`
	TimeoutSeconds  int64   `json:"timeout_seconds"`
	PosX            float64 `json:"pos_x"`
	PosY            float64 `json:"pos_y"`
	Config          string  `json:"config"`
}

WorkflowNode is a single command step within a workflow DAG.

type WorkflowRun added in v0.12.0

type WorkflowRun struct {
	ID             int64             `json:"id"`
	WorkflowID     int64             `json:"workflow_id"`
	Repo           string            `json:"repo"`
	EventType      string            `json:"event_type"`
	DeliveryID     string            `json:"delivery_id"`
	Ref            string            `json:"ref,omitempty"`
	Hash           string            `json:"hash,omitempty"`
	Trigger        string            `json:"trigger,omitempty"`
	State          string            `json:"state"`
	StartedAt      time.Time         `json:"started_at"`
	FinishedAt     *time.Time        `json:"finished_at,omitempty"`
	DurationMillis int64             `json:"duration_ms,omitempty"`
	Nodes          []WorkflowRunNode `json:"nodes,omitempty"`
}

WorkflowRun is a single execution of a workflow against an event.

type WorkflowRunNode added in v0.12.0

type WorkflowRunNode struct {
	ID             int64      `json:"id"`
	RunID          int64      `json:"run_id"`
	NodeKey        string     `json:"node_key"`
	State          string     `json:"state"`
	ExitCode       int64      `json:"exit_code"`
	Output         string     `json:"output,omitempty"`
	StartedAt      *time.Time `json:"started_at,omitempty"`
	FinishedAt     *time.Time `json:"finished_at,omitempty"`
	DurationMillis int64      `json:"duration_ms,omitempty"`
}

WorkflowRunNode is the per-node execution record for a workflow run.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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