Documentation
¶
Overview ¶
Package buildscope is the registry of the project's release components and the engine that computes each one's build closure: the module-local packages and files that compile into its entry-point binary.
It answers two questions that must agree, for two callers that must agree:
- change detection — which components a set of changed files affects (Affected), so CI builds and validates only what a change touched;
- scoped validation — which packages a component comprises (ClosurePackages), so `go vet` / `go test` run against just those.
walle (locally) and the changed-scope action (in CI) both import this package, so the answers cannot drift. The closure comes from `go list -deps`, not path globbing, because components share packages under internal/: a path prefix cannot say which binary an internal package compiles into, but the import graph can.
Index ¶
- Variables
- func Affected(ctx context.Context, changed []string) (map[string]bool, error)
- func AffectedIn(changed []string, closures map[string][]string) map[string]bool
- func AffectedNames(affected map[string]bool) []string
- func ClosurePackages(ctx context.Context, names ...string) ([]string, error)
- func Closures(ctx context.Context, names ...string) (map[string]Closure, error)
- func GitChanged(ctx context.Context, base string) ([]string, error)
- func ImportPath(ctx context.Context, c Component) (string, error)
- func Names() []string
- type Closure
- type Component
Constants ¶
This section is empty.
Variables ¶
var Components = []Component{
{Name: "example", EntryPkg: "./cmd/example"},
{Name: "walle", EntryPkg: "./cmd/walle"},
}
Components is the ordered set of release components. Order is the canonical order for reports and outputs. To add a component, add its cmd/<name> package and an entry here; walle, the changed-scope action and the build action all pick it up.
walle is a component so that a change to the tooling itself is in CI's scope: its closure covers every internal/ engine, so a PR touching only buildscope or buildrun still runs their vet and tests rather than being scoped to nothing.
Functions ¶
func Affected ¶
Affected reports, for every component, whether any changed file (module-relative) is in its closure.
func AffectedIn ¶
AffectedIn is Affected with the closures supplied, so the decision is testable without the toolchain. Every component appears in the result; one missing from closures is reported unaffected.
func AffectedNames ¶
AffectedNames returns the affected component names in canonical order.
func ClosurePackages ¶
ClosurePackages returns the sorted union of the named components' module-local packages — the argument list for `go vet` / `go test` to validate exactly those components. No names means every component.
func Closures ¶
Closures resolves the closures of the named components (all components when names is empty) concurrently. Each `go list -deps` costs roughly half a second to a second on a real module; they are independent and read-only, so running them in parallel makes Affected cost about one call instead of one per component.
func GitChanged ¶
GitChanged returns the module-relative paths changed between the merge base of base and HEAD, and HEAD — what a pull request changed, computed from the checkout rather than the GitHub API (no token, no pagination, no 3000-file API cap). The checkout needs enough history to find the merge base: actions/checkout with fetch-depth: 0.
git reports paths relative to the repository root; they match module-relative paths when the module is the repository root, which is this template's layout.
func ImportPath ¶
ImportPath returns a component's entry-point import path.
Types ¶
type Closure ¶
type Closure struct {
Packages []string // module-local import paths, sorted
Files []string // module-relative, forward-slashed paths, sorted; always includes go.mod and go.sum
}
Closure is a component's build closure within this module.