Documentation
¶
Overview ¶
Package dag resolves a named dependency graph into levels: each node's distance from having no unmet dependencies, and a flat execution order grouped by ascending level. It's shared by any provider whose jobs declare "run after" dependencies on sibling jobs (CircleCI's workflow `requires:`, GitHub Actions' job `needs:`), so the same algorithm and error handling (unknown dependency, circular dependency, duplicate node) isn't reimplemented per provider.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Levels ¶
Levels assigns each node the length of its longest dependency chain (0 for a node with no dependencies), so nodes at the same level can run one after another while still guaranteeing every dependency's level is lower than its dependents'. It also returns a flat execution order: nodes grouped by ascending level, stable within a level by the order given in nodes.
Types ¶
type Node ¶
Node is one entry in a dependency graph: a name and the names of other nodes in the same graph it depends on.
func FilterSkipped ¶ added in v0.3.1
func FilterSkipped(nodes []Node, skipped map[string]string) (kept []Node, reasons map[string]string)
FilterSkipped removes every node named in skipped from nodes, along with any node that (transitively, through Depends) needs one of them — a job that depends on a job PolyCI can't run can't run either. It's how a provider parser turns a handful of individually-unsupported jobs (e.g. a GitHub Actions job with no container:) into a pipeline where every other job, including ones that don't depend on the unsupported one, still runs normally instead of the whole file failing to parse.
It returns the surviving nodes (in the same relative order as nodes) and the full skip reason for every name that ended up skipped: unchanged for names already in skipped, and a generated "depends on skipped job ..." reason — composing through any chain, however long — for every node skipped only because of the cascade.