Skip to content

Commit 1a0d26b

Browse files
committed
.github: fix samples/tasks CI step killed by default set -e
The "Smoke-test database_task argv parsing" step was failing on the first run after the workflow landed: Process completed with exit code 1. Root cause: GitHub Actions' `shell: bash` wraps the run script with `bash --noprofile --norc -eo pipefail {0}` -- the `-e` is implicit, not opt-in. The step deliberately invokes `./database_task` with no arguments, expecting exit status 1 so it can assert on it. But `-e` fires on that non-zero exit before the `rc=$?` capture runs, and the step terminates at the invocation line with no output past it. Confirmed the failure mode locally by running the original script under the exact same shell contract (`bash --noprofile --norc -eo pipefail`) -- it exits 1 with no output, matching the CI log. The libretro-common/samples workflow doesn't hit this because every binary in that job's run allowlist is expected to exit 0; only the deliberate-nonzero case exposes the issue. Fix: capture the exit status in the same statement with `|| rc=$?`, which suppresses `-e` for the known-nonzero case. Initialize rc=0 up front so the assert branch is reached even if the command somehow succeeds. Comment added explaining why the idiom is needed -- this is a CI-specific gotcha, not obvious from reading the script. Reproduced the fix under the same shell contract: [pass] database_task no-args exit=1 (expected non-zero) step exit: 0 The archive_name_safety_test step is left unchanged. That step's command (`timeout 60 ./archive_name_safety_test`) expects exit 0; non-zero means a real regression and `set -e` terminating the step is the correct behaviour there.
1 parent 0ef2531 commit 1a0d26b

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/Linux-samples-tasks.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,15 @@ jobs:
6464
# loop can only be terminated externally (by timeout or
6565
# signal). The full loop is exercised in local testing; in
6666
# CI we settle for the argv smoke.
67-
./database_task > /dev/null 2>&1
68-
rc=$?
67+
#
68+
# We capture the exit status via "|| rc=$?" so that the
69+
# expected non-zero exit does NOT trip the default "set -e"
70+
# that GitHub Actions' bash shell injects (it wraps with
71+
# "bash --noprofile --norc -eo pipefail"). Without this
72+
# guard the step exits at the binary invocation before our
73+
# assertion runs.
74+
rc=0
75+
./database_task > /dev/null 2>&1 || rc=$?
6976
if [[ $rc -eq 0 ]]; then
7077
echo "::error title=Test failed::database_task with no args exited 0; expected non-zero (usage)"
7178
exit 1

0 commit comments

Comments
 (0)