mirror of
https://github.com/dockersrc/go
synced 2026-06-24 14:01:08 -04:00
🔧 track exit codes and fix entrypoint invocation 🔧
- `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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user