feat: add internal/scaffold package for cascade init - #169
Merged
Merged
Conversation
Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After the inline
run:removal, cascade callbacks are reusable-workflow-only, so a cold start requires hand-authoringworkflow_callfiles. There is no programmatic way to produce a known-good starter manifest plus the build/deploy stubs it references.Fix
Adds a new
internal/scaffoldpackage (PR1 ofcascade init, no CLI yet). It produces an in-memory set of files for a chosen topology and guarantees they are never handed out broken.Scaffold(project, trunkBranch, envs, ...Option)returns a path->content map: a starter.github/manifest.yamlplus the build (and, when environments exist, deploy) reusable-workflow stubs it references. An emptyenvsslice yields the no-env, release-only topology.# yaml-language-server: $schema=...directive for editor autocomplete (inert YAML comment), pinscli_versiontoconfig.DefaultCLIVersion, and applies environment names positionally.on: workflow_callreusable workflows declaring theenvironment/sha/dry_runinputs cascade passes; the build stub wires theartifact_idoutput through, matching the callback contract.SelfCheck(files)writes the files to a temp dir and confirms they parse (config.ParseManifestFile), validate (config.Validate), and generate (internal/generateorchestrate + promote) without error.Scaffoldruns it before returning.no-env[],two-env[dev prod],three-env[dev staging prod],four-env[dev test uat prod].Verification
go build ./..., fullgo test ./...(all packages green), andgolangci-lint run ./...pass.$schemadirective and positional env ordering are checked; negativeSelfCheckcases (invalid env name, malformed YAML, build missingworkflow:) exercise real validation failures.internal/scaffold/; no dogfood-workflow drift.PR2 will wire the
cascade initcobra command on top of this package;cascade adoptwill reuse the same writer and self-check.