Add automated test for docker-entrypoint.sh - #17
Conversation
docker-entrypoint.sh translates BACKUP_DIRECTORY, SCHEDULED_USERS and BACKUP_INTERVAL_MS into JVM system properties, but neither CI job executed it: `build` runs `mvn clean verify`, which cannot run a shell script, and `docker-build` only copies the script into the image without starting a container. Entrypoint changes therefore landed on a fully green CI run with the changed lines never having been run. docker-entrypoint-test.sh puts a stub `java` on PATH that prints its arguments wrapped in brackets, then asserts the argument list the entrypoint builds for seven cases: no variables set, each variable set individually, all three set together, all three set to the empty string (which must add no arguments), and a value containing a space (which must stay a single argument). The bracket delimiting is what makes the last case meaningful. The test runs as a step in the docker-build job, so it gates the same pull requests the image build already gates. Closes #13 Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
The NAME=VALUE parsing used eval to export a dynamically-named variable, which would mis-handle a value containing a quote or backtick and, more importantly, silently accepted a misspelled variable name: a case written against SCHEDULEDUSERS would export a variable the entrypoint never reads and still assert the empty-variable argument list, looking like coverage it did not provide. A case statement over the three variables docker-entrypoint.sh actually reads removes the eval and fails loudly on any other name. The comment on the empty-value case also named GITHUB_TOKEN, which the entrypoint does not read; it is trimmed to the two variables the case covers. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Self-review rubricScored against the diff and command output rather than judgement. Anchor: CI run 34021267770 on head
Findings
Verification not performedThe Merge disposition
This review was posted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
Summary
docker-entrypoint-test.shis added: a POSIX shell test that puts a stubjavaonPATH(one that prints its arguments rather than starting a JVM), runsdocker-entrypoint.shunder seven environment combinations, and asserts the argument list the entrypoint builds.BACKUP_DIRECTORY,SCHEDULED_USERSandBACKUP_INTERVAL_MSeach set individually; all three set together (argument order asserted); all three set to the empty string, which must add no arguments; and a value containing a space.Test entrypoint scriptstep is added to thedocker-buildjob in.github/workflows/build.yml, so the script is executed on every pull request rather than only copied into an image.README.mdgains anEntrypoint Script Testsubsection alongside the existingUnit Testssubsection,CONTRIBUTING.md's Testing section documents how to run it, andCHANGELOG.md's[Unreleased]section records the addition.Before this change, neither CI job executed the entrypoint:
buildrunsmvn clean verify, which cannot run a shell script, anddocker-buildonly confirms the script is copied and made executable. A typo in a property name would not have been caught until a container came up misconfigured.Test plan
mvn -B test— 54 tests run, 0 failures, 1 skipped (pre-existing skip inGitHubServiceTest),BUILD SUCCESSsh docker-entrypoint-test.sh— 7 of 7 cases pass, exit 0-Dbackup.scheduled.interval.ms=renamed to-Dbackup.scheduled.intervalms=indocker-entrypoint.sh→ 2 cases FAIL, exit 1; restored → all pass[ -n "$SCHEDULED_USERS" ]guard replaced withif true→ 5 cases FAIL including the empty-value case, exit 1; restored → all passdocker-buildjob itself, since Docker is unavailable in this environment. The new CI step is plainshonubuntu-latestand needs no container, and the script was executed directly under/bin/sh; the CI run on this PR head is the anchor for the workflow wiring.Notes
shellcheck, mentioned as optional in the issue, is deliberately not added here: it could not be run locally to confirmdocker-entrypoint.shpasses cleanly, so wiring it into CI would have risked a red run for reasons unrelated to this change. It is left as a separate, independently verifiable step..github/workflows/build.ymlis on this loop's do-not-auto-merge list, so this pull request is left open for maintainer review rather than merged autonomously.Issues deferred this cycle
Dockerfile) — deferred because its body explicitly leaves the direction to the maintainer: the three proposed fixes differ in whether the released artifact keeps its version in the filename, which also affects the release workflow's upload glob.LICENSEfile) — deferred because adding a license file requires choosing a copyright holder and year, which is a maintainer decision rather than a text-accuracy correction.Closes #13
This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson