Repository navigation
fix(generate): gate promote rollback inputs and dry_run on the callee's declared inputs - #705
Merged
Merged
Conversation
…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>
joshua-temple
approved these changes
Dec 3, 2026
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>
Resolved in merge commit |
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.
What was wrong
environmentandshawithout checking the callee. GitHub rejects a call that passes an input the callee doesn't declare. Promote's deploy jobs already checked, and so have the hotfix lanes since fix(generate): invoke the configured deploy and rollback callbacks in the hotfix workflow #696.dry_runwheneversupports_dry_runwas set, whether or not the callee declared the input, so it could send an undeclareddry_runthe same way.changelog_base_shaasimage_tag. That value is a commit SHA, not an image tag.What changed
environmentandshaonly when the callee declares them. Thedry_runpassthrough on all three deploy paths (matrix, single-environment and prod) now follows the callee's declared inputs.supports_dry_runnow 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.image_tag: preflight resolves no image tag for the rollback target, so rollback no longer sendsimage_tagat all.image_tagorimage_digest,cascade generate-workflownow fails: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 thecascade-example-*fleet: none requires either input.guides/hotfix.mdandreference/cli.mdnow describe the deploy the prod gate actually runs.callbacks.mdandmanifest.mddescribe the newdry_runand 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:with:blocks of the rollback and deploy jobs;dry_runpassthrough on each deploy path;Closes #698