Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell_commands should fail immediately if one of the commands fails #957

Merged
merged 1 commit into from
Mar 17, 2020

Conversation

mostynb
Copy link
Contributor

@mostynb mostynb commented Mar 3, 2020

It seems that shell_commands are joined with newlines and then run in a single subprocess.run call, in which case the return value is that of the last command- any failures in previous commands are ignored.

Users probably expect such failures to cause the entire build to fail. Changing this behaviour feels like the right thing to do, even though it may cause some projects to fail CI until the corresponding errors are fixed.

By prepending "set -e" to the shell commands, the shell will exit immediately with an error code when a command fails (apart from some special cases like if conditions or commands followed by ||).

This might fix #938 for linux/mac.

It seems that shell_commands are joined with newlines and then run in
a single subprocess.run call, in which case the return value is that
of the last command- any failures in previous commands are ignored.

Users probably expect such failures to cause the entire build to fail.
Changing this behaviour feels like the right thing to do, even though
it may cause some projects to fail CI until the corresponding errors
are fixed.

By prepending "set -e" to the shell commands, the shell will exit
immediately with an error code when a command fails (apart from some
special cases like if conditions or commands followed by ||).

This might fix bazelbuild#938 for linux/mac.
mostynb added a commit to mostynb/remote-apis-sdks that referenced this pull request Mar 5, 2020
ola-rozenfeld pushed a commit to bazelbuild/remote-apis-sdks that referenced this pull request Mar 16, 2020
* presubmit: shell_commands should exit if any command fails

This may not be needed if this bazelci PR lands:
bazelbuild/continuous-integration#957

* presubmit: use consistent indentation
Copy link
Member

@philwo philwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Seems reasonable to me.

@philwo philwo merged commit 1444091 into bazelbuild:master Mar 17, 2020
@mostynb mostynb deleted the shell_commands_set_e branch March 17, 2020 22:09
philwo added a commit to bazelbuild/remote-apis-sdks that referenced this pull request Mar 19, 2020
ifoox pushed a commit to bazelbuild/remote-apis-sdks that referenced this pull request Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

only the last entry in shell_commands can fail the build
2 participants