Skip to content

Fix set -e abort after a successful deploy - #1

Merged
RootX22 merged 1 commit into
mainfrom
fix/set-e-prune-abort
Aug 23, 2026
Merged

RootX22 merged 1 commit into
mainfrom
fix/set-e-prune-abort

Conversation

@RootX22

@RootX22 RootX22 commented Aug 23, 2026

Copy link
Copy Markdown
Owner

CI caught a real bug in the pruning step.

(( pruned++ )) evaluates to 0 on the first increment, which is exit status 1. Under set -e that aborted the script after the release had gone live and the ERR trap had been disarmed — a fully successful deploy exited 1, which any CI pipeline would report as a failed deployment. [[ $pruned -gt 0 ]] && log had the same failure mode when there was nothing to prune.

Also fixes the three shellcheck findings gating CI:

Code Issue Fix
SC2155 readonly STAMP=$(date ...) masks date's exit status Split declaration from assignment
SC2015 A && B || true swallowed a failing reload during rollback Explicit if, reports the failure
SC2012 ls used to list releases find + sed (-printf is GNU-only)

Verified locally: six consecutive deploys with KEEP_RELEASES=3 all exit 0, three releases retained, current points at the newest.

The prune step used (( pruned++ )), which evaluates to 0 on the first
increment. Under set -e that is a non-zero status and aborted the script
*after* the release had gone live and the ERR trap had been disarmed —
so a completely successful deploy exited 1. CI caught it in the pruning
integration test. The trailing [[ $pruned -gt 0 ]] && log had the same
problem when nothing needed pruning.

Also addressed the shellcheck findings that gated CI:

- SC2155: split the readonly STAMP declaration from its assignment so a
  failing date(1) is not masked by the declaration's exit status.
- SC2015: the rollback reload used A && B || true, which swallowed a
  genuinely failing reload command. Replaced with an explicit if that
  reports the failure instead of hiding it.
- SC2012: replaced ls with find for the release listing. find -printf is
  GNU-only, so the basename is stripped with sed to match the portability
  already required by atomic_symlink.
@RootX22
RootX22 merged commit d240b84 into main Aug 23, 2026
5 checks passed
@RootX22
RootX22 deleted the fix/set-e-prune-abort branch August 23, 2026 21:20
RootX22 added a commit that referenced this pull request Aug 23, 2026
(( pruned++ )) returns 1 when pruned is 0, and set -e killed the
script right after the release had already gone live. also cleaned
up the shellcheck stuff while i was in there.
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