Skip to content

fix(generate): gate promote rollback inputs and dry_run on the callee's declared inputs - #705

Merged
reka18 merged 7 commits into
mainfrom
fix/promote-rollback-declared-inputs-698
Dec 3, 2026
Merged

reka18 merged 7 commits into
mainfrom
fix/promote-rollback-declared-inputs-698

Conversation

@reka18

@reka18 reka18 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

What was wrong

What changed

  • Declared-input gating: promote's rollback (local and external-block deploys) now passes environment and sha only when the callee declares them. The dry_run passthrough on all three deploy paths (matrix, single-environment and prod) now follows the callee's declared inputs. supports_dry_run now drives only the dry-run skip guards. A cross-repo callee, whose inputs can't be read, falls back to the standard contract, as the hotfix lanes do. The hotfix generator's input-reading helper is now package-level, so both generators share it.
  • No more SHA as image_tag: preflight resolves no image tag for the rollback target, so rollback no longer sends image_tag at all.
  • Generate refuses a rollback it can't satisfy. When a deploy gets a rollback job and its callee requires image_tag or image_digest, cascade generate-workflow now fails:
    required input validation failed:
      - deploy-app requires input 'image_tag' but the promote rollback jobs have no source for it yet (#664)
    
    This is a deliberate break for a manifest that relied on a SHA being passed as image_tag. Making the input optional fixes it, and the CHANGELOG says so. A deploy with no rollback job is unaffected, and so is a callee that only declares the input as optional. I checked the 41 reusable deploy workflows across the cascade-example-* fleet: none requires either input.
  • Docs: guides/hotfix.md and reference/cli.md now describe the deploy the prod gate actually runs. callbacks.md and manifest.md describe the new dry_run and cross-repo rules.

How it's tested

  • go test ./... with actionlint v1.7.12 and shellcheck on PATH, so the actionlint feature-matrix tests run. The new tests pin:
    • the parsed with: blocks of the rollback and deploy jobs;
    • the cross-repo fallback;
    • a callee that can't be read;
    • the dry_run passthrough on each deploy path;
    • the refusal cases.
  • golangci-lint v2.10.1 on go1.26.11, and gofmt.
  • No e2e scenario changes. The harness can't show a callee being called with only its declared inputs: act doesn't run GitHub's reusable-workflow input validation. The e2e module builds, and its harness tests pass.

Closes #698

…n declared inputs

The promote generator's rollback jobs threaded environment and sha to the
deploy callback without checking whether the callee declares them, and the
dry_run passthrough keyed on supports_dry_run rather than on the callee's
declared workflow_call inputs, so a promote could emit a with: block GitHub
rejects at parse. Promote's own deploy jobs check, and the hotfix lanes have
since #696.

Rollback now gates environment and sha on the callee's declared inputs with
the standard cross-repo contract as the fallback for a callee whose workflow
cannot be read locally, so a local callee that declares none of the contract
inputs gets no with: block and one declaring only some of them receives
those alone. The dry_run passthrough follows the same rule on every deploy
path (matrix, single, and prod): a callback that declares dry_run receives
the null-safe boolean passthrough - including cross-repo callees via the
contract fallback - and supports_dry_run keeps its own role of running the
deploy job during dry-run promotes instead of skipping it. Promote's
required-input validation counts the passthrough for a declaring callee,
mirroring orchestrate's validation/emission agreement (#684), so a callback
declaring dry_run required passes generation instead of being rejected as
unprovidable while the emitted with: block satisfies it.

The declared-inputs helper the hotfix generator introduced is now a
package-level function both generators call, so promote reuses it instead of
carrying a third copy.

Closes #698

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
Review of the #698 change surfaced one real defect and a set of accuracy
and coverage gaps; this commit fixes them without changing the intended
behavior.

The matrix deploy path emitted the dry_run passthrough without the
manifest-wired guard its environment and sha neighbors carry, so an
operator wiring dry_run under inputs: on a declaring callback got a with:
block with a duplicate mapping key - yaml.v3 rejects duplicates outright,
and GitHub does the same at parse. The passthrough now stays silent when
the manifest wires dry_run, letting the matrix entry thread it.

The CHANGELOG, code comments, and reference docs claimed the rollback
gating matches the rollback workflow and promote's single/prod deploy
jobs, which still pass environment and sha unconditionally; the wording
now names only the hotfix lanes (#696) the rule actually matches, and the
callback-contract row states the cross-repo assumption and
supports_dry_run's remaining role (the dry-run skip guard) instead of
comparing dry_run to sha.

Tests: the no-with-block assertion now rejects a bare with: header, and
new subtests pin the previously untested paths - an unreadable local
callee, an external-block deploy whose workflow lives in the primary repo
(local gating, not the cross-repo fallback), a matrix deploy with
undeclared dry_run under supports_dry_run, the manifest-wired dry_run
precedence, and the cross-repo prod deploy job.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…llback

The promote rollback jobs threaded preflight's changelog_base_sha as the
image_tag input when the deploy callback declared it. That output is the
target environment's pre-promote commit SHA, not an image tag: on the
deploy paths image_tag carries the promoted artifact's version
(preflight's source_image_tag).

Preflight resolves no image tag for the rollback target - rollback_sha is
the same pre-promote commit SHA - so there is no honest value to thread
today. Remove the image_tag emission from the rollback with: block and the
extraLines plumbing writeRollbackWith carried for it, leaving the
declared-input gating of environment and sha intact: a declared image_tag
is simply not satisfied on rollback, and the rollback redeploys by sha
alone. Wiring the rollback target's real image tag needs a new preflight
output and is left as follow-up work (#698).

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
The hotfix guide's "Prod is a valid target" bullet still said the job
behind the environment gate was the placeholder and that approval does not
run the configured deploy workflow - stale since #696 made the deploy and
rollback lanes invoke the configured callback, which also removed the
placeholder section the bullet pointed at. It now says approval runs the
configured deploy workflow with the contract environment, sha, and dry_run
inputs, each passed only when the callee declares it, and that protection
applies through the environment: key the callback declares on its own job
(the generated caller is a uses: job and cannot carry one).

The CLI reference's hotfix entry carried the same stale placeholder claim
("placeholders that do not yet invoke the configured deploy workflow") and
its pointer to the guide "and the limitation". It now describes the
cherry-pick, build, and deploy running in the generated workflow with the
deploy and rollback jobs invoking the configured callback, the rollback
keyed on the environment's pre-hotfix SHA.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…ge tag

Since 4110f12 the promote rollback with: block threads no image_tag, so a
deploy callback that declares image_tag or image_digest as required gets a
rollback call that omits a required input and fails its dispatch.
PromoteGenerator.validateRequiredInputs counted both as available because
the deploy lanes thread preflight's source_image_* outputs; the rollback
lane has no source for either, and preflight resolves no image tag for the
rollback target.

Generation now refuses that shape: when writeRollbackJobs will emit a
rollback job for a deploy - its own condition, at least one environment
and at least one deploy, local or external-block - a callee that requires
image_tag or image_digest fails with an error naming the deploy and the
input and saying the promote rollback jobs have no source for it yet
(#664 tracks giving rollback a real image-tag source). External-block
deploys with a local workflow are parsed for their required inputs too,
since discoverDeployInputs walks only config.Deploys. Deploys that get no
rollback job are unaffected, and a callee that declares image_tag only as
optional still generates: the rollback omits it and the callee's default
applies.

This is a deliberate break for manifests that generated before: what they
relied on was a commit SHA being passed as image_tag. Make the input
optional until rollback resolves the rollback target's real image tag.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
Review on 1bfa994..HEAD found the new generatedJobFromContent helper
duplicating the YAML parse-and-extract tail of generatedJobFromDir
line for line. generatedJobFromDir now generates the workflow and
delegates the extraction to generatedJobFromContent, which moves next
to it in external_rollback_test.go so the job-lookup helper family
lives in one place. Behavior is unchanged for every caller: both
helpers carry t.Helper(), and the only difference was the Generate
call, which stays in generatedJobFromDir.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
@reka18

reka18 commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts on this branch.

…declared-inputs-698

# Conflicts:
#	CHANGELOG.md

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Dec 3, 2026

Copy link
Copy Markdown

@copilot resolve the merge conflicts on this branch.

Resolved in merge commit f186f0a. Generator tests, actionlint, and CodeQL passed. The full Go suite encountered Git-backed test failures in this environment, including its safe.bareRepository=explicit restriction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

promote: rollback jobs pass environment and sha without checking the callee's declared inputs

3 participants