Skip to content

Skip PostDeploy convention when the main script fails#425

Merged
ppXD merged 1 commit into
mainfrom
fix/skip-postdeploy-on-main-script-failure
Jun 10, 2026
Merged

Skip PostDeploy convention when the main script fails#425
ppXD merged 1 commit into
mainfrom
fix/skip-postdeploy-on-main-script-failure

Conversation

@ppXD

@ppXD ppXD commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • A non-zero main-script exit does not throw, so the Calamari pipeline carried on and ran the PostDeploy convention against a failed deploy. PostDeploy hosts smoke tests, cache warm-up, and service-mesh registration — running them on an already-failed deploy is worse than skipping them.
  • Add a single-source RunScriptCommandContext.DeployHasFailed predicate (an upstream step threw or the main script exited non-zero) and gate PostDeploy on it via an opt-in skipWhenDeployFailed flag on ConventionScriptStep. PostDeploy passes true; PreDeploy keeps the default false (it runs before the main script, so the failure state is never set when it is evaluated).
  • DeployFailedConventionStep now consults the same DeployHasFailed predicate, so the skip-PostDeploy gate and the run-DeployFailed gate can never disagree about whether the deploy failed (previously the predicate was duplicated inline).
  • Non-breaking: skipWhenDeployFailed is an optional constructor parameter, so every existing call site / test is unchanged. Only PostDeploy's behaviour on a failed main script changes. The separate IIS DeployToIISWebSite.ps1 convention system already skips PostDeploy on failure and is untouched.

Test plan

  • E2E (real bash, RunScriptCommandTests): main exit 3 + PostDeploy.sh + DeployFailed.sh present → PostDeploy sentinel absent (skipped), DeployFailed sentinel present (ran), ExitCode == 3
  • E2E (real bash): main exit 0 → PostDeploy runs, DeployFailed skipped (happy-path regression guard)
  • Unit (ConventionScriptStepTests): IsEnabled gating — flag+non-zero-exit → skip; flag+ExecutionFailed → skip; flag+exit-0 → run; default-flag ignores failure state (PreDeploy unaffected)
  • Unit: DeployHasFailed predicate [Theory] over (executionFailed × exitCode) branches
  • Regression: full Squid.Calamari.Tests suite 556/556 green; dotnet build Squid.sln 0 errors

@ppXD ppXD added this to the 1.8.17 milestone Jun 10, 2026
A non-zero main-script exit did not throw, so the pipeline carried on and
ran the PostDeploy convention against a failed deploy. PostDeploy is where
smoke tests, cache warm-up, and service-mesh registration live — running
them on a deploy that already failed is worse than not running them at all.

Gate PostDeploy on a single-source DeployHasFailed predicate (an upstream
step threw OR the main script exited non-zero) via an opt-in
skipWhenDeployFailed flag on ConventionScriptStep. PreDeploy keeps the
default (false): it runs before the main script, so the failure state is
never set when it is evaluated. DeployFailedConventionStep now consults the
same predicate, so the skip-PostDeploy gate and the run-DeployFailed gate
can never disagree about whether the deploy failed.

The flag is an optional constructor parameter, so every existing call site
is unchanged; only PostDeploy's behaviour on a failed main script changes.
@ppXD
ppXD force-pushed the fix/skip-postdeploy-on-main-script-failure branch from c69a46b to 5a435a3 Compare June 10, 2026 08:00
@ppXD
ppXD merged commit d120e19 into main Jun 10, 2026
14 of 15 checks passed
@ppXD
ppXD deleted the fix/skip-postdeploy-on-main-script-failure branch June 10, 2026 08:09
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.

1 participant