Documentation
¶
Index ¶
- func FormatResult(result *ValidationResult) string
- func Resolve(app *cli.App, args []string) string
- func RunTarget(app *cli.App, args []string) string
- func WorkflowPath(cfg *config.Config, pipelineName, workflowDir string) string
- type Invocation
- type Job
- type StaleInvocation
- type Step
- type ValidationResult
- type WorkflowDefinition
- type WorkflowJobYAML
- type WorkflowStepYAML
- type WorkflowYAML
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatResult ¶
func FormatResult(result *ValidationResult) string
FormatResult formats a validation result for display
func Resolve ¶
Resolve walks args down app's command tree and returns why they do not resolve, or "" when they do — including when the check cannot tell.
The root is always judged: cidx dispatches to a command, and urfave replaces a nil root action with the help printer at run time (which exits non-zero on an unknown topic — the 12-second failure of #239), so app.Action says nothing about whether the root accepts free arguments.
func RunTarget ¶
RunTarget returns the phase, tool or pipeline named by a `cidx run <target>` invocation, and "" for anything else — another subcommand, or a `run` whose target cannot be read with certainty.
`check workflow` used to look for the literal substring "cidx run " in the step, which lost the phase as soon as a flag sat between the binary and the subcommand: `./bin/cidx --verbose run test` reported no phase at all, so the command claimed a phase was missing from a workflow that runs it (issue #233). Reading the command line is what the parser above already does, flags included, so `run` is resolved the same way `validate` resolves every other invocation.
It inherits the refusals of Resolve: a target the shell would rewrite, or flags that cannot be parsed with certainty, yield no target rather than a wrong one.
func WorkflowPath ¶
WorkflowPath returns the path of the workflow file that implements the named pipeline, or "" when the pipeline is not implemented by a workflow — either because it declares `workflow = "none"`, or because the file it points at does not exist.
This is the single place the pipeline ↔ workflow pairing is decided, so `check workflow <pipeline>` and `check workflow` cannot answer differently.
Types ¶
type Invocation ¶
type Invocation struct {
File string // workflow file the invocation was found in
Line int // 1-based line in that file
Step string // name of the step, when the workflow gives one
Args []string // arguments passed to cidx, in order
}
Invocation is a cidx command line found in a workflow step.
func ExtractInvocations ¶
func ExtractInvocations(script string) []Invocation
ExtractInvocations returns the cidx invocations of a shell script, with Line set to the 1-based line of the script each was found on.
func WorkflowInvocations ¶
func WorkflowInvocations(dir string) ([]Invocation, error)
WorkflowInvocations returns every cidx invocation found in the workflow files of dir, in file then line order. A missing directory is not an error: there is simply nothing to check.
func (Invocation) String ¶
func (i Invocation) String() string
String renders the invocation the way it would be typed.
type Job ¶
type Job struct {
Name string // Job name
Needs []string // Dependencies (needs: [job1, job2])
Steps []Step // Steps in the job
}
Job represents a GitHub Actions job
type StaleInvocation ¶
type StaleInvocation struct {
Invocation
Reason string
}
StaleInvocation is an invocation that no longer resolves against the CLI.
type ValidationResult ¶
type ValidationResult struct {
Pipeline string // Pipeline name (e.g., "ci")
WorkflowFile string // Workflow file path
Success bool // Whether validation passed
MissingInGH []string // Phases in cidx.toml but not in GitHub workflow
MissingInLocal []string // Phases in GitHub workflow but not in cidx.toml
OrderMismatch bool // Whether phase order differs
LocalOrder []string // Order in cidx.toml
GitHubOrder []string // Order in GitHub workflow
}
ValidationResult contains the comparison result between a pipeline and workflow
func ValidateAllWorkflows ¶
func ValidateAllWorkflows(app *cli.App, cfg *config.Config, workflowDir string) ([]*ValidationResult, error)
ValidateAllWorkflows validates every pipeline that a workflow implements.
A pipeline with no workflow is skipped rather than compared against a file that merely shares its name: `release.yml` publishes a release natively and delegates a single phase to cidx, so it never was `[pipelines.release]`'s mirror (issue #233). Which pipelines have a workflow is read from the config — see config.Pipeline.WorkflowFile.
func ValidateWorkflow ¶
func ValidateWorkflow(app *cli.App, cfg *config.Config, pipelineName string, workflowPath string) (*ValidationResult, error)
ValidateWorkflow compares a pipeline definition with a GitHub Actions workflow
type WorkflowDefinition ¶
type WorkflowDefinition struct {
Name string // Workflow name (e.g., "ci", "release")
File string // Workflow file path
Jobs map[string]Job // Jobs defined in the workflow
Phases []string // Extracted phases from "cidx run <phase>" commands
}
WorkflowDefinition represents a GitHub Actions workflow
func ParseWorkflow ¶
func ParseWorkflow(app *cli.App, workflowPath string) (*WorkflowDefinition, error)
ParseWorkflow parses a GitHub Actions workflow file and extracts phase information. The command tree comes from the running app, so the phases are read off the same command line the CLI would parse (issue #233).
type WorkflowJobYAML ¶
type WorkflowJobYAML struct {
Name string `yaml:"name"`
Needs interface{} `yaml:"needs"` // Can be string or []string
Steps []WorkflowStepYAML `yaml:"steps"`
}
WorkflowJobYAML represents a job in the workflow YAML
type WorkflowStepYAML ¶
WorkflowStepYAML represents a step in a job
type WorkflowYAML ¶
type WorkflowYAML struct {
Name string `yaml:"name"`
Jobs map[string]WorkflowJobYAML `yaml:"jobs"`
}
WorkflowYAML represents the structure of a GitHub Actions workflow file