From 4b8f03509140631140c84986f65d2a7f5dbe78b6 Mon Sep 17 00:00:00 2001 From: casjay Date: Fri, 12 Jun 2026 14:10:04 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20track=20exit=20codes=20and=20fix?= =?UTF-8?q?=20entrypoint=20invocation=20=F0=9F=94=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `go-workflow`: accumulate step exit codes into `GO_EXITCODE` and `exit $GO_EXITCODE` so failures propagate to the caller - `run_step`: capture and return each step's exit code instead of silently swallowing it - `entrypoint.sh`: replace `__exec_command go-workflow` with direct `go-workflow "$@"` so the process and args are passed correctly - Strip trailing whitespace from `@@Other` and `@@Resource` header fields rootfs/usr/local/bin/entrypoint.sh rootfs/usr/local/bin/go-workflow --- rootfs/usr/local/bin/entrypoint.sh | 2 +- rootfs/usr/local/bin/go-workflow | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) 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 +