diff --git a/rootfs/usr/local/bin/entrypoint.sh b/rootfs/usr/local/bin/entrypoint.sh index f47c8bc..62037d8 100755 --- a/rootfs/usr/local/bin/entrypoint.sh +++ b/rootfs/usr/local/bin/entrypoint.sh @@ -508,7 +508,7 @@ if [ "$START_SERVICES" = "yes" ] || [ -z "$1" ]; then CONTAINER_INIT="${CONTAINER_INIT:-no}" # No user command: run default Go workflow instead of blocking if [ $# -eq 0 ]; then - go-workflow + go-workflow "$@" exit $? fi fi diff --git a/rootfs/usr/local/bin/go-workflow b/rootfs/usr/local/bin/go-workflow index 4068ece..7779c53 100755 --- a/rootfs/usr/local/bin/go-workflow +++ b/rootfs/usr/local/bin/go-workflow @@ -6,6 +6,7 @@ set -euo pipefail # Resolve the working directory — prefer /app if mounted, else cwd +GO_EXITCODE=0 WORK_DIR="${GOWORKDIR:-${PWD}}" cd "$WORK_DIR" @@ -24,24 +25,35 @@ echo "" run_step() { local label="$1"; shift + local exitCode=0 echo "── ${label}" "$@" + exitCode=$? echo "" + return $exitCode } # 1. Sync module graph and go.sum before anything reads them run_step "go mod tidy" go mod tidy - +retVal=$? +GO_EXITCODE=$((GO_EXITCODE + retVal)) # 2. Format all Go source files in place run_step "gofmt -w ." gofmt -w . - +retVal=$? +GO_EXITCODE=$((GO_EXITCODE + retVal)) # 3. Catch suspicious constructs run_step "go vet ./..." go vet ./... - +retval=$? +GO_EXITCODE=$((GO_EXITCODE + retVal)) # 4. Run tests — fail fast before wasting time on a build run_step "go test ./..." go test ./... - +retVal=$? +GO_EXITCODE=$((GO_EXITCODE + retVal)) # 5. Build all main packages; output lands alongside source in each package dir run_step "go build ./..." go build ./... +retVal=$? +GO_EXITCODE=$((GO_EXITCODE + retVal)) echo "✅ Done." +exit $GO_EXITCODE +