generate

package
v0.2.0-rc.23 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultJobTimeoutMinutes = 30

DefaultJobTimeoutMinutes is the timeout-minutes applied to cascade-owned jobs (setup, finalize, inline run: callbacks, retry shims, and passthrough artifact helper jobs) when config.job_timeout_minutes is not set. GitHub Actions defaults jobs to 360 minutes (6 hours); cascade's orchestration jobs are meant to be fast, so a hung git push, CLI download, or API call should not hold a runner for six hours. Override per manifest via config.job_timeout_minutes.

Variables

This section is empty.

Functions

func GenerateLocalActions

func GenerateLocalActions(baseDir string, cfg *config.TrunkConfig) error

GenerateLocalActions creates the local action files in the user's repo Uses cfg.GetActionFolder() for the folder name (default: "manage-release")

func NewCommand

func NewCommand() *cobra.Command

NewCommand creates the generate-workflow command

func ParseWorkflowInputs

func ParseWorkflowInputs(data []byte) ([]string, error)

ParseWorkflowInputs extracts input names from a workflow file

func ParseWorkflowOutputs

func ParseWorkflowOutputs(data []byte) ([]string, error)

ParseWorkflowOutputs extracts output names from a workflow file

func ParseWorkflowRequiredInputs

func ParseWorkflowRequiredInputs(data []byte) ([]string, error)

ParseWorkflowRequiredInputs extracts required input names from a workflow file An input is required if it has required: true and no default value

Types

type CallbackInfo

type CallbackInfo struct {
	Name           string // Original name from config (e.g., "app")
	JobID          string // Prefixed job ID (e.g., "build-app")
	DisplayName    string // Display name (e.g., "Build (app)")
	Type           string // "build" or "deploy" or "validate"
	Workflow       string
	Run            string // Inline command; when set the callback is emitted as a cascade-owned inline-step job instead of a reusable-workflow call
	Shell          string // Shell for the inline run step (default bash; only meaningful with Run)
	RunPolicy      string
	OnFailure      string
	Retries        int
	TimeoutMinutes int                  // Job-level timeout-minutes (omitted when 0)
	Matrix         *config.MatrixConfig // Build fan-out; nil for deploys and validate
	SupportsDryRun bool                 // When true, dry-run promotes invoke the callback with dry_run: true instead of skipping it

	// Per-callback job attributes for cascade-owned inline run: jobs. These are
	// emitted only on inline-run jobs (never on reusable-workflow uses: callbacks,
	// where GHA forbids runs-on/concurrency); schema validation already rejects
	// runs_on/concurrency on reusable callbacks.
	RunsOn      *config.RunsOn            // Per-callback runner selection (#12)
	Permissions map[string]string         // Per-callback job permissions, incl. id-token: write OIDC (#35, #15)
	Concurrency *config.ConcurrencyConfig // Per-callback concurrency override (#17)

	// PassthroughArtifact declares GHA artifact upload/download steps to inject
	// around this job's callback invocation, enabling inter-job artifact passing
	// within a single orchestrate run (#16).
	PassthroughArtifact *config.PassthroughArtifact

	// Secrets holds the per-callback secrets passing config. Nil means inherit
	// (the default). When non-nil and Inherit is true, secrets: inherit is emitted.
	// When non-nil with an explicit Map, a secrets: block with per-entry
	// ${{ secrets.CALLER_NAME }} expressions is emitted instead.
	Secrets *config.SecretsConfig
}

CallbackInfo holds information about a callback

type DependencyGraph

type DependencyGraph struct {
	Nodes map[string]CallbackInfo // job ID -> info
	Edges map[string][]string     // job ID -> hard dependencies (as job IDs)

	// OptionalEdges holds optional_depends_on edges (job ID -> dependencies as
	// job IDs). Optional deps add to a job's needs: for ordering but do NOT
	// contribute a skip-gate to its if: condition. The job still runs when an
	// optional dep was skipped because its triggers didn't match (#18).
	OptionalEdges map[string][]string
}

DependencyGraph represents the callback dependency graph Uses prefixed job IDs (build-app, deploy-app) to allow name reuse across sections

func BuildDependencyGraph

func BuildDependencyGraph(cfg *config.TrunkConfig) *DependencyGraph

BuildDependencyGraph creates a dependency graph from config Uses prefixed job IDs to support same names in builds and deploys

func (*DependencyGraph) GetAllDependencies

func (g *DependencyGraph) GetAllDependencies(node string) []string

GetAllDependencies returns all transitive dependencies for a node

func (*DependencyGraph) GetDirectDependencies

func (g *DependencyGraph) GetDirectDependencies(node string) []string

GetDirectDependencies returns only direct (hard) dependencies for a node

func (*DependencyGraph) GetOptionalDependencies added in v0.2.0

func (g *DependencyGraph) GetOptionalDependencies(node string) []string

GetOptionalDependencies returns the optional_depends_on dependencies for a node. These add to needs: for ordering only; they do not skip-gate the job.

func (*DependencyGraph) TopologicalSort

func (g *DependencyGraph) TopologicalSort() ([]string, error)

TopologicalSort returns nodes in dependency order

type ExternalUpdateGenerator

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

ExternalUpdateGenerator handles external-update workflow generation

func NewExternalUpdateGenerator

func NewExternalUpdateGenerator(cfg *config.TrunkConfig, baseDir string) *ExternalUpdateGenerator

NewExternalUpdateGenerator creates a new external-update workflow generator

func (*ExternalUpdateGenerator) Generate

func (g *ExternalUpdateGenerator) Generate() (string, error)

Generate creates the external-update workflow content

type Generator

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

Generator handles workflow file generation

func NewGenerator

func NewGenerator(cfg *config.TrunkConfig, baseDir string) *Generator

NewGenerator creates a new workflow generator

func (*Generator) Generate

func (g *Generator) Generate() (string, error)

Generate creates the orchestration workflow content

func (*Generator) SetState added in v0.2.0

func (g *Generator) SetState(state map[string]*config.EnvState)

SetState threads the manifest state block into the generator so ${{ state.<env>.<field> }} input references resolve at generation time.

func (*Generator) Validate

func (g *Generator) Validate() []string

Validate checks for potential issues and returns warnings

type MergeQueueGenerator added in v0.2.0

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

MergeQueueGenerator emits the opt-in merge-queue validation lane. When config.merge_queue.enabled is set, cascade generates a merge_group-triggered workflow that validates the prospective trunk commit with cascade's own logic: it runs `cascade parse-config` as a validity gate and a dry-run `cascade orchestrate setup` to preview the build/deploy decisions against the merge-group candidate ref. The lane is read-only (no state writes, no releases, no deploys) and reports a status the merge queue can require.

This generator owns the LANE behavior. The raw merge_group trigger itself is expressible separately under extra_triggers.merge_group; the two are intentionally distinct.

func NewMergeQueueGenerator added in v0.2.0

func NewMergeQueueGenerator(cfg *config.TrunkConfig, baseDir string) *MergeQueueGenerator

NewMergeQueueGenerator creates a merge-queue validation-lane generator.

func (*MergeQueueGenerator) Enabled added in v0.2.0

func (g *MergeQueueGenerator) Enabled() bool

Enabled reports whether the manifest opts in to the merge-queue lane.

func (*MergeQueueGenerator) Generate added in v0.2.0

func (g *MergeQueueGenerator) Generate() (string, error)

Generate renders the merge-queue validation-lane workflow.

type PRPreviewGenerator added in v0.2.0

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

PRPreviewGenerator emits the opt-in read-only PR plan-preview workflow (#40).

The workflow runs on pull_request and is strictly read-only: it validates the manifest, detects which builds/deploys this merge would trigger against the PR diff, and dry-runs the applicable deploy callbacks, then writes a human-readable plan to $GITHUB_STEP_SUMMARY. When Comment is set it also posts (or updates) that plan as a PR comment via actions/github-script.

dry_run is enforced (--dry-run is always passed, never sourced from an input) so the preview can never create a release, write state, or trigger a deploy.

func NewPRPreviewGenerator added in v0.2.0

func NewPRPreviewGenerator(cfg *config.TrunkConfig, baseDir string) *PRPreviewGenerator

NewPRPreviewGenerator creates a new PR plan-preview workflow generator.

func (*PRPreviewGenerator) Generate added in v0.2.0

func (g *PRPreviewGenerator) Generate() (string, error)

Generate creates the PR plan-preview workflow content.

type PromoteGenerator

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

PromoteGenerator handles promote workflow generation

func NewPromoteGenerator

func NewPromoteGenerator(cfg *config.TrunkConfig, baseDir string) *PromoteGenerator

NewPromoteGenerator creates a new promote workflow generator

func (*PromoteGenerator) Generate

func (g *PromoteGenerator) Generate() (string, error)

Generate creates the promote workflow content

func (*PromoteGenerator) SetState added in v0.2.0

func (g *PromoteGenerator) SetState(state map[string]*config.EnvState)

SetState threads the manifest state block into the promote generator so ${{ state.<env>.<field> }} input references resolve at generation time.

type ReleaseGenerator

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

ReleaseGenerator handles release workflow generation for single-environment projects

func NewReleaseGenerator

func NewReleaseGenerator(cfg *config.TrunkConfig, baseDir string) *ReleaseGenerator

NewReleaseGenerator creates a new release workflow generator

func (*ReleaseGenerator) Generate

func (g *ReleaseGenerator) Generate() (string, error)

Generate creates the release workflow content for single-environment projects

type ValidateCheckGenerator added in v0.2.0

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

ValidateCheckGenerator emits the opt-in manifest-validation PR check. When config.validate_check.enabled is set, cascade generates a lightweight pull_request workflow that runs `cascade parse-config` against the manifest and fails when the manifest is invalid, so a malformed configuration cannot merge to trunk. The check validates cascade's own configuration only: it does not run the consumer's build/test CI, requests contents: read alone, and has no dry-run or comment side effects.

func NewValidateCheckGenerator added in v0.2.0

func NewValidateCheckGenerator(cfg *config.TrunkConfig, baseDir string) *ValidateCheckGenerator

NewValidateCheckGenerator creates a manifest-validation PR-check generator.

func (*ValidateCheckGenerator) Enabled added in v0.2.0

func (g *ValidateCheckGenerator) Enabled() bool

Enabled reports whether the manifest opts in to the validation check.

func (*ValidateCheckGenerator) Generate added in v0.2.0

func (g *ValidateCheckGenerator) Generate() (string, error)

Generate renders the manifest-validation PR-check workflow.

type WorkflowCallConfig

type WorkflowCallConfig struct {
	Inputs  map[string]WorkflowInput  `yaml:"inputs"`
	Outputs map[string]WorkflowOutput `yaml:"outputs"`
}

WorkflowCallConfig represents the workflow_call trigger configuration

type WorkflowFile

type WorkflowFile struct {
	Name string                 `yaml:"name"`
	On   map[string]interface{} `yaml:"on"`
}

WorkflowFile represents a GitHub Actions workflow file structure

type WorkflowInput

type WorkflowInput struct {
	Type        string      `yaml:"type"`
	Description string      `yaml:"description"`
	Required    bool        `yaml:"required"`
	Default     interface{} `yaml:"default"`
}

WorkflowInput represents an input parameter

type WorkflowOutput

type WorkflowOutput struct {
	Description string `yaml:"description"`
	Value       string `yaml:"value"`
}

WorkflowOutput represents an output value

Jump to

Keyboard shortcuts

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