Skip to content

Commit 4c01d99

Browse files
author
Datanoise
committed
Fix: Simplify and correct exit code handling in CI startup test
1 parent 55729e6 commit 4c01d99

1 file changed

Lines changed: 13 additions & 22 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,30 +78,21 @@ jobs:
7878
7979
echo "Starting TinyIce in background for 5 seconds to check for startup errors..."
8080
chmod +x "$BINARY_PATH" # Add execute permissions
81-
# Use a non-default port and tmp config to avoid conflicts
82-
timeout 5s sh -c "$BINARY_PATH -port 8080 -config /tmp/tinyice-test-linux-${GOARCH}.json" &
83-
PID=$!
8481
85-
# Wait for the process to finish for up to 6 seconds (slightly more than timeout)
86-
if ! wait $PID; then
87-
EXIT_CODE=$?
88-
if [ $EXIT_CODE -eq 124 ]; then
89-
echo "TinyIce ran for more than 5 seconds or was killed by timeout. This is considered a pass (successful startup)."
90-
exit 0 # Treat timeout as success (program didn't crash immediately)
91-
else
92-
echo "TinyIce exited with an unexpected error code: $EXIT_CODE within 5 seconds. This indicates a startup failure."
93-
exit 1 # Treat any other non-zero exit code as failure
94-
fi
82+
# Run TinyIce with timeout. We want to pass if it exits 0 (graceful stop) or 124 (timeout).
83+
# We fail if it exits with any other non-zero code.
84+
timeout 5s sh -c "$BINARY_PATH -port 8080 -config /tmp/tinyice-test-linux-${GOARCH}.json"
85+
TIMEOUT_EXIT_CODE=$?
86+
87+
if [ $TIMEOUT_EXIT_CODE -eq 0 ]; then
88+
echo "TinyIce exited gracefully within 5 seconds. Test passed."
89+
exit 0 # Pass
90+
elif [ $TIMEOUT_EXIT_CODE -eq 124 ]; then
91+
echo "TinyIce ran for more than 5 seconds or was killed by timeout. Test passed (successful startup)."
92+
exit 0 # Pass
9593
else
96-
# Process exited naturally within 5 seconds
97-
EXIT_CODE=$?
98-
if [ $EXIT_CODE -eq 0 ]; then
99-
echo "TinyIce exited gracefully within 5 seconds. This is considered a pass (successful short-lived execution)."
100-
exit 0 # Treat graceful exit as success
101-
else
102-
echo "TinyIce exited with an error code: $EXIT_CODE within 5 seconds. This indicates a startup failure."
103-
exit 1 # Treat non-zero exit code as failure
104-
fi
94+
echo "TinyIce exited with an unexpected error code: $TIMEOUT_EXIT_CODE within 5 seconds. This indicates a startup failure."
95+
exit 1 # Fail
10596
fi
10697
10798
release:

0 commit comments

Comments
 (0)