Skip to content

fix: target first environment in PR-preview dry-run - #196

Merged
joshua-temple merged 1 commit into
mainfrom
fix/pr-preview-environment
Jun 17, 2026
Merged

joshua-temple merged 1 commit into
mainfrom
fix/pr-preview-environment

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Problem

The generated cascade-pr-preview.yaml ran its "Compute plan (dry-run)" step as cascade --dry-run orchestrate setup --config <manifest> --sha $HEAD_SHA with no --environment. The flag defaults to "". For any manifest that declares environments, calculateVersion looks the empty value up in the environments list, finds no match, and fails with:

Error: setup failed: failed to calculate version: environment "" not found

So the PR-preview workflow could never succeed for any multi-environment repo.

Fix

internal/generate/pr_preview.go writeDeployDryRunStep now emits --environment <environments[0]> when the manifest declares environments, mirroring how the orchestrate workflow defaults its setup environment (generator.go uses Environments[0] likewise). Version calculation resolves against that environment. A manifest with no environments still omits the flag and runs the no-environment path. The step stays read-only (--dry-run hard-coded) regardless of which environment it reports on.

Verification

  • Unit: new TestPRPreviewGenerator_DryRunResolvesEnvironment (multi-env asserts --environment staging; no-env asserts the flag is omitted). Written failing first, then green.
  • e2e scenario 16-pr-preview.yaml now uses [staging, prod] and asserts --environment staging in the generated workflow.
  • Reproduced the original failure on a multi-env repo (environment "" not found); confirmed orchestrate setup --environment staging --dry-run resolves v0.1.0-rc.0 with exit 0 and no error.
  • go build ./... && go test ./... && golangci-lint run ./... all green (1398 tests). e2e module builds and vets clean.

The generated cascade-pr-preview.yaml ran orchestrate setup with no
--environment. For a manifest that declares environments, version
calculation looks the empty value up in the environments list, finds no
match, and fails the preview with environment "" not found, so the
PR-preview workflow could never succeed for any multi-environment repo.

Pass --environment with the first (lowest) environment, mirroring how the
orchestrate workflow defaults its setup environment. Version calculation
then resolves against that environment. A manifest with no environments
still omits the flag and runs the no-environment path.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple
joshua-temple merged commit c6ba165 into main Jun 17, 2026
7 checks passed
@joshua-temple
joshua-temple deleted the fix/pr-preview-environment branch June 17, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant