Skip PostDeploy convention when the main script fails
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.DeployHasFailedpredicate (an upstream step threw or the main script exited non-zero) and gate PostDeploy on it via an opt-inskipWhenDeployFailedflag onConventionScriptStep. PostDeploy passestrue; PreDeploy keeps the defaultfalse(it runs before the main script, so the failure state is never set when it is evaluated). -
DeployFailedConventionStepnow consults the sameDeployHasFailedpredicate, 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:
skipWhenDeployFailedis an optional constructor parameter, so every existing call site / test is unchanged. Only PostDeploy's behaviour on a failed main script changes. The separate IISDeployToIISWebSite.ps1convention system already skips PostDeploy on failure and is untouched.
Test plan
-
E2E (real bash, RunScriptCommandTests): mainexit 3+PostDeploy.sh+DeployFailed.shpresent → 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):IsEnabledgating — flag+non-zero-exit → skip; flag+ExecutionFailed→ skip; flag+exit-0 → run; default-flag ignores failure state (PreDeploy unaffected) -
Unit: DeployHasFailedpredicate[Theory]over (executionFailed × exitCode) branches -
Regression: full Squid.Calamari.Testssuite 556/556 green;dotnet build Squid.sln0 errors