Repository navigation
[Sprint] sprint-loop-20 - #18
Merged
Merged
Conversation
… (SUR-1881) - tests/aws.bats: add aws::is_scan_complete COMPLETE/IN_PROGRESS/FAILED mapping assertions - tests/secret.bats: register_env, as_file readable, EXIT-trap shred, must_exist failure path - tests/fn.bats: if_exists call/skip/args-forward; wrapped call/fallthrough - tests/error.bats: error::exit exits 1 with message on stderr - tests/annotations.bats: deprecated arg-forwarding, debug-log naming caller, deprecated shim delegation - tests/helpers.bash: add helpers::make_fixture_repo for fixture repos with optional tagged history (SUR-1882 prerequisite)
…nd-squashable, pretty-labels (SUR-1882) - tests/changelog.bats: CHANGELOG header, v0.3.0/v0.2.0 section headers, -l link generation with GitHub remote - tests/switch-to-branch.bats: multi-repo branch switch, clean working trees - tests/find-squashable.bats: detects same-file consecutive commit run - tests/pretty-labels.bats: kubectl stub; resource name and label per line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sprint Plan: 2026-04-29-sprint-loop-20
Sprint Goal
This sprint consolidates two complementary streams of work: closing out a high-priority bug
that spans two previous sprints (SUR-1883 — the remaining bare
ret=$?inbash/daml-exportthat SUR-1871 was supposed to eliminate), and dramatically expanding bats regression coverage
across the shell-scripts repository (SUR-1881 and SUR-1882). By the end of the sprint every
@package-declared library will have at least a starter bats spec, the seven highest-riskcommand scripts will have fixture-based tests, and the daml-export variable-leak bug will be
fully closed — eliminating the class of
ret/exit_codeglobal leaks that has generatedmultiple filed bugs (SUR-1859, SUR-1860, SUR-1871, SUR-1883).
Selected Issues
1. SUR-1883 — Bug: daml-export post-loop
find … | while readbody still has bareret=$?Priority: High
Labels: Bug
URL: https://linear.app/surinis/issue/SUR-1883
Description Summary
Follow-up to SUR-1871 (PR #15). The previous sprint fixed the
ret=$?leak inbuild()and the loop guard, but left a third site untouched: the post-loop
find "$TARGET_DIR" -name export.good -print | sort | while read -r buildFilebody.Inside that pipeline right-hand side,
ret=$?is bare (notlocal). Because thewhileruns in a subshell, the leak is currently contained — but any future refactor pulling
the body out of the pipe will re-expose it, and the SUR-1871 DoD explicitly required
all three sites to be made hygienic.
The suggested fix is to extract the body into a named function (
verify_and_build)with
local ret=$?and to convert the pipeline to process substitution(
done < <(find … | sort)) so thatRUNNING_PROCSarray mutations reach the parentshell rather than dying in the subshell.
A PR (#16) was submitted during sprint/2026-04-28-sprint-loop-13 and reportedly
implements the full fix. This sprint closes the issue by reviewing and merging that PR
(or re-implementing on a fresh branch if PR #16 is stale).
Rationale
High-priority bug that was explicitly called out in the SUR-1871 DoD yet not delivered.
The fix is localised to one file and gated by existing regression tests. Keeping it
open creates technical debt and risks re-exposure on future refactors.
Definition of Done
ret=$?inbash/daml-export; every site useslocal ret=$?inside afunction body or is rewritten to
if cmd; then/if ! cmd; thendirectly.find … export.goodwalk uses process substitution< <(…)(orequivalent non-subshell construct) so
RUNNING_PROCSmutations reach the parent shell.tests/sur-1871-daml-export.shcontinues to pass and is extended to assert thatRUNNING_PROCSreflects the builds triggered during the post-loop walk.pre-commit run --files bash/daml-exportexits 0 (shellcheck + shfmt clean).feature/sur-1883branch opened, reviewed,and merged if PR [Sprint] sprint-loop-13 #16 is stale/conflicted.
Dependencies / Ordering
Must be completed first; it is the only High-priority issue and its regression tests
provide a safety net for subsequent work. No blockers identified.
2. SUR-1881 — Test: missing bats coverage for bash/aws.sh, docker.sh, exec.sh, fn.sh, error.sh, secret.sh, annotations.sh
Priority: Medium
Labels: testing
URL: https://linear.app/surinis/issue/SUR-1881
Description Summary
SUR-1850 introduced bats specs for eight libraries, but seven
@package-declared librariesremain uncovered:
annotations.sh,aws.sh,docker.sh,error.sh,exec.sh,fn.sh,secret.sh. The issue provides concrete starter targets:tests/exec.bats— assertexec_codenot leaked;exec::hideswallows output butpreserves exit codes.
tests/docker.bats— stubdocker; assertdocker::cpreturns 1/2/3 forpull/tag/push failures.
tests/secret.bats— materialise secret viasecret::as_file; trigger EXIT in asubshell; assert tempfile is shredded.
tests/fn.bats— assert correct dispatch forfn::if_existsandfn::wrapped.tests/aws.bats— stubaws; assertaws::is_scan_completemapsCOMPLETE->0 andIN_PROGRESS->1.tests/error.bats— spawn subshell; asserterror::exit fooexits 1 with "foo" onstderr.
tests/annotations.bats— assertannotations::deprecated newfn arg1 arg2forwardsarg1 arg2tonewfnand emits a debug log naming the deprecated caller.The goal is to bring total bats coverage to all 16
@package-declared libraries.Rationale
The
exit_code/retleak bugs filed as SUR-1859 and SUR-1860 againstdocker.shandexec.shwould have been caught by basic regression tests.secret.sh's EXIT trap isuntested despite managing on-disk secret material. Adding specs now closes the regression
gap and prevents the same class of bug from silently reappearing.
Definition of Done
tests/exec.batsadded: assertsexec_codeis not leaked;exec::hide/exec::capturepreserve exit codes while swallowing output.
tests/docker.batsadded: stubbeddockerbinary;docker::cpreturn-code contractexplicitly asserted for pull/tag/push failure paths.
tests/secret.batsadded: EXIT trap fires in a subshell and the tempfile no longerexists afterwards.
tests/fn.batsadded:fn::if_existsandfn::wrappeddispatch tests pass.tests/aws.batsadded: fixture JSON;aws::is_scan_completemapping verified.tests/error.batsadded:error::exitexit-code and stderr assertions pass.tests/annotations.batsadded:annotations::deprecatedarg-forwarding and debug-logassertions pass.
make test_batswithout modification.Dependencies / Ordering
No hard dependency on SUR-1883, but work in parallel or after. The stub/helper patterns
established here will be reused by SUR-1882 tests — complete SUR-1881 before SUR-1882.
3. SUR-1882 — Test: command scripts changelog, find-squashable, switch-to-branch, replace-validator, clean-branches, git-check, pretty-labels have no tests
Priority: Medium
Labels: testing
URL: https://linear.app/surinis/issue/SUR-1882
Description Summary
13+ command scripts have no test coverage. The highest-risk scripts (destructive or
state-mutating) are prioritised. The issue calls for a shared
helpers::make_fixture_repohelper in
tests/helpers.bashto centralise per-test git-fixture boilerplate, then:tests/clean-branches.bats— fixture repo; assert dry-run does NOT delete;-Tdeletesonly
build/*tags. Pins the SUR-1835 invariant.tests/changelog.bats— fixture repo with three tagged commits; assert expected sectionsand
-llink generation.tests/switch-to-branch.bats— two fixture repos under$HOME/git/<org>/; assert bothget switched; neither leaves an unclean working tree.
tests/git-check.bats— fixture repos in UNCOMMITTED/RELEASABLE/DEVELOPMENT states;assert correct output bucketing (locks SUR-1857 fix).
tests/replace-validator.bats— stubbedk8s::ctlreturning canned JSON; assertexpected migration commands are emitted.
tests/find-squashable.bats— fixture repo where commits 2 & 3 touch the same files;assert "could be squashed" output.
tests/pretty-labels.bats— stubbedkubectl; assert tabular output matches fixture.Rationale
clean-branchesperformsgit branch -D(destructive),replace-validatormutates k8sstate, and
switch-to-branchmutates many checkouts. SUR-1835 added a dry-run guard toclean-branchesthat has never been exercised in a regression. These scripts are thehighest-priority targets for coverage.
Definition of Done
helpers::make_fixture_repoadded totests/helpers.bashand used by at least theclean-branches, changelog, switch-to-branch, and git-check specs.
tests/clean-branches.bats: dry-run asserts no deletion;-Tasserts onlybuild/*tags are deleted.tests/changelog.bats: fixture repo with tagged commits; asserts expected sectionheaders and link output with
-l.tests/switch-to-branch.bats: two-fixture-repo test; both repos switched cleanly,no unclean working tree left behind.
tests/git-check.bats: UNCOMMITTED/RELEASABLE/DEVELOPMENT state bucketing asserted.tests/find-squashable.bats: squashable commit detection asserted on fixture history.tests/pretty-labels.bats: stubbed kubectl output matches tabular fixture.make test_bats.Dependencies / Ordering
Depends on SUR-1881 completing first (stub/helper patterns;
helpers::make_fixture_repoconcept originates here but the established helper discipline from SUR-1881 should be in
place). Complete after SUR-1881.
Risks and Mitigations
sprint/2026-04-28-sprint-loop-13may have drifted frommainfeature/sur-1883; acceptance criteria are fully specified.secret.shEXIT-trap test kills the bats runner — triggering EXIT in the test process terminates bats itself( source bash/secret.sh; secret::as_file ...; exit ). Assert on tempfile after subshell returns.aws/docker/kubectldiffers across specstests/helpers.bashandtests/k8s.batsfirst; reuse existinghelpers::stub_binor equivalent before writing new stubs.switch-to-branch.batsfilesystem isolation insufficient — script mutates repos under$HOME/git/<org>/helpers::isolate_hometo redirect$HOMEto a temp dir; verify$HOME/git/only exists inside the sandbox.changelog.batsfixture requires a real git history with tags —helpers::make_fixture_repomust support tag creation@docannotation.replace-validator.batsdepends onk8s::ctlstubbing matching the existing kubectl stub approachtests/k8s.bats.Out of Scope
check-system,pagerduty-alert,aws-get-kubeconfigs,k8s-support-collector,plantuml-from-k8s,copy-keys(beyond the prioritised seven).daml-exportfeatures beyond the specificret=$?/ process-substitution fix.Linear Evidence
ce9ebfde-ff2b-4f54-90f1-c388591ca110, key:SUR)a43901a0-b02b-4009-aae1-a6e8903d127d)shell-scripts, Team =Surinis, State =Backlog, limit 250hasNextPage: false)Sub-issue Status
No sub-issues were found for any of the three selected issues.
Linear State Transitions