Propagate the Ruby entrypoint exit status from bin/gdk
What does this merge request do and why?
bin/gdk captured the exit status of gem/bin/gdk but never returned it. A bash script with no trailing exit returns the status of its last command, which here is the closing if, so every gdk <command> exited 0 even when the Ruby command failed. Scripts and CI that check the return code of gdk update could not detect a failure. The "not a GDK" branch printed an error and also exited 0.
- Adds
exit "${gdk_exit_status}"at the end of the GDK branch, so the launcher forwards the Ruby entrypoint's status unchanged, including126after the asdf hint. - Makes the "not a GDK" branch
exit 1. - Points
components/siphon/GDK.rbat the singlesiphonservice. It still listed four service names from before they were consolidated, sogdk component list-servicesreportsunassigned: siphonand exits1.bin/gdkused to hide that. With the status forwarded,build-components-pipelinewould start failing without this change. - Adds
data/announcements/0051_gdk_exits_non_zero_on_failure.ymlso the behaviour change is surfaced to users on their nextgdk installorgdk update.
gem/bin/gdk and GDK::Command.run already compute the status correctly. This is the shell-side counterpart of !2060 (merged).
Behaviour change: gdk commands that failed but exited 0 now exit non-zero. A wrapper script or CI job that was silently passing on a failed gdk command will start failing.
Replaces !6166 (closed), which could not run its jobs from a personal fork.
Fixes #3366 (closed)
How to set up and validate locally
-
Run a command that fails and check the status:
$ ./bin/gdk rake nope:not-a-task >/dev/null 2>&1; echo "outer=$?" outer=1On
mainthis printsouter=0. -
Run it from a directory that is not a GDK:
(cd /tmp && /path/to/gdk/bin/gdk status >/dev/null 2>&1; echo "rc=$?")printsrc=1. -
A successful command still exits
0:./bin/gdk config get port; echo $?. -
./bin/gdk component list-services; echo $?printsunassigned: <none>and exits0.
Verification
bash -n bin/gdk passes. I ran the launcher against a stub gem/bin/gdk that exits with a requested code:
| Inner exit | main outer |
This MR outer |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 0 | 1 |
| 7 | 0 | 7 |
| 126 | 0 | 126 |
| nested subdirectory, inner 3 | 0 | 3 |
| not a GDK directory | 0 | 1 |
I could not run shellcheck or the Ruby specs locally. The main column is what #3366 (closed) reports, not something I re-ran. bin/gdk has no spec harness.
Impacted categories
- gdk-reliability - e.g. When a GDK action fails to complete.
- gdk-usability - e.g. Improvements or suggestions around how the GDK functions.
- gdk-performance - e.g. When a GDK action is slow or times out.
Merge request checklist
- This MR references an issue describing the change.
- This change is backward compatible. If not, include steps to communicate to users. (See the behaviour change above; announcement added.)
- Tests added for new functionality. If not, raise an issue to follow-up. (
bin/gdkhas no spec harness. Covered by the stub test above.) - Observability added/updated (logging, metrics, tracing).
- Documentation added/updated.
- Announcement added for notable changes.
-
gdk doctortest added. - This contribution was prepared with the help of an AI assistant. I reviewed the changes and take responsibility for them.