Repository navigation
test(pipeline): shellcheck the composed scripts and test the shared helpers - #5
Merged
Merged
Conversation
…elpers TestShellcheck lints every embedded script as the operator runs it, the helper plus the stage body (sh for Stage, bash for Stream), plus runner/install-rclone.sh, and reports each finding at its source file and line. It skips without shellcheck; CI sets KARKIVE_REQUIRE_SHELLCHECK so a missing binary fails the job instead. New behaviour tests run the shared helpers under dash and bash with stub tools: step markers and .step-failed, the log file, truthy, the zstd level, decompression by suffix, s3_latest by modification time and the best-effort s3_prune. make test-scripts runs only the pipeline tests.
…ripts common.sh disables SC3028 for every Stage script: HOSTNAME is not POSIX, but the container runtime sets it to the pod name that scopes each pod's scratch directory. The Stage EXIT trap tests $? directly instead of through an unassigned-looking ec, and STAGE='compress' is quoted so it no longer reads as the compress command. The rest are intended and annotated where they occur: the dump-name globs in compress.sh and encrypt.sh must expand, the MariaDB sed filters use backticks as identifier quotes, the Redis RESP frame has a literal $6, and the Stream EXIT trap assigns rc inside its string.
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.
Lints every embedded pipeline script the way the operator runs it and adds behaviour tests for the shared helpers. Closes the shellcheck half of the "Tests" item in TODO.md; envtest stays open.
TestShellcheck: Stage scripts are linted ascommon.sh+ the stage body undersh, Stream scripts asstream/common.sh+backup.sh/restore.shunderbash, plusrunner/install-rclone.sh. Findings are reported at the source file and line; a helper finding is reported once, and unused-variable/function findings in a helper only when no script uses it.KARKIVE_REQUIRE_SHELLCHECK=1, so the test fails instead of skipping if the runner loses shellcheck.helpers_test.go: runs the helpers underdash/bashwith stub tools (step markers,.step-failed, log file,truthy, zstd level, decompression by suffix,s3_latestby modification time, best-efforts3_prune).make test-scriptsruns only the pipeline tests.The first CI run (shellcheck 0.11.0) reported 28 findings; the second commit clears them. One is a real fix (
STAGE='compress'read as a command assignment), one a simplification (the Stage EXIT trap tests$?directly), and the rest are intended and annotated where they occur:HOSTNAMEin POSIX sh (set by the container runtime), dump-name globs that must expand, MariaDB backtick identifiers in sed filters, a literal$6in a Redis RESP frame, andrcassigned inside the Stream EXIT trap.