Implement resume, skip, and stage selection

This commit is contained in:
2026-05-02 11:38:42 -05:00
parent 77f421feef
commit bec784f1ec
11 changed files with 518 additions and 23 deletions

View File

@@ -8,10 +8,11 @@ import (
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
"gitea.maximumdirect.net/eric/narratio/internal/config"
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
)
// Plan validates configuration, prepares the local workdir, and prints stage order.
func Plan(_ context.Context, args []string, out io.Writer) error {
func Plan(ctx context.Context, args []string, out io.Writer) error {
fs := flag.NewFlagSet("plan", flag.ContinueOnError)
fs.SetOutput(io.Discard)
@@ -46,17 +47,32 @@ func Plan(_ context.Context, args []string, out io.Writer) error {
return fmt.Errorf("plan: prepare workdir: %w", err)
}
_ = force // TODO: use --force in future skip/stale planning behavior.
stages := BuildFullPlan()
var m *manifest.Manifest
m, err = loadManifestIfPresent(ctx, cfg)
if err != nil {
return fmt.Errorf("plan: %w", err)
}
decisions := decideStageActions(stages, m, force)
runCount := 0
skipCount := 0
if _, err := fmt.Fprintf(out, "narratio plan: workdir prepared at %s\n", paths.Root); err != nil {
return err
}
for _, s := range stages {
if _, err := fmt.Fprintln(out, s.Name()); err != nil {
for _, d := range decisions {
if d.Action == stageActionRun {
runCount++
} else {
skipCount++
}
if _, err := fmt.Fprintf(out, "%s: %s\n", d.Stage.Name(), d.Action); err != nil {
return err
}
}
if _, err := fmt.Fprintf(out, "totals: run=%d skip=%d\n", runCount, skipCount); err != nil {
return err
}
return nil
}