Skip to content

Multi-shell convention hooks (PreDeploy.ps1 / PostDeploy.ps1 / DeployFailed.ps1)

Placeholder ppxd requested to merge feat/calamari-multi-shell-conventions into main

Summary

Extends PR-4 (#374) multi-shell support to convention hooks. Operators can ship a convention as {name}.sh (bash) OR {name}.ps1 (PowerShell); Calamari finds which exists and dispatches to the matching executor + variable preamble.

Resolution rules (ConventionScriptResolver)

Files present Resolves to
Neither step skips (unchanged)
Only .sh bash — back-compat: every pre-PR-7 package
Only .ps1 PowerShell
Both the one matching the main script's syntax (from context.ScriptPath) — PowerShell app → PowerShell convention; bash app → bash convention

Deterministic, intuitive, no OS-mocking in tests.

What's in the box

Layer File
Resolver src/Squid.Calamari/Commands/Conventions/ConventionScriptResolver.cs (new)
Shared bootstrap (Pre/Post + DeployFailed) src/Squid.Calamari/Commands/Conventions/ConventionBootstrap.cs (new)
ConventionScriptStep updated dispatch by resolved syntax
DeployFailedConventionStep updated same
Tests ConventionScriptResolverTests.cs (6) + ConventionScriptStepTests (+2)

Test plan

  • Squid.Calamari.Tests: 481/481 (was 473; +8)
  • Squid.UnitTests: 5625/5625 (unchanged)
  • Build: 0 errors
  • All 31 existing convention tests pass unchanged — back-compat
  • PreDeploy.ps1 → PowerShell syntax + $env: preamble + .ps1 temp extension
  • Both-variants tie-break: main-script syntax wins

Non-breaking guarantee

Surface Status
.sh-only convention packages Resolve to bash exactly as before
Wire literals / convention filenames Unchanged (PreDeploy/PostDeploy/DeployFailed stems)
Pipeline order Unchanged
SquidWeb Untouched — file-based convention

Merge request reports

Loading