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

run(:local) { command "..." } should abort on failure (or be removed) #609

Open
jackc opened this issue Feb 28, 2018 · 2 comments
Open

run(:local) { command "..." } should abort on failure (or be removed) #609

jackc opened this issue Feb 28, 2018 · 2 comments

Comments

@jackc
Copy link

jackc commented Feb 28, 2018

The local run environment does not check the results of its tasks.

  run(:local) do
    command "false"
    command "something-else"
  end

I would expect the task to be aborted and something-else not to run. Instead the error return code is ignored that something-else is run.

However, it is easy to work around. Given we are in rake we can use sh.

sh "false"
sh "something-else"

Given that sh is built-in, perhaps the best solution is to remove/deprecate run(:local) in favor of sh. Otherwise, perhaps it could be implemented in terms of sh instead of system.

@coreyworrell
Copy link
Contributor

The deploy commands are all chained together with && as you can see when using mina deploy --simulate. But local commands are just placed inline.

My temporary fix is to do

run :local do
  command "something || exit 1"
  command "something else && another || exit 1"
end

But that's not very nice to look at, or have to remember. And if you try to use in_path then it will still bypass any failures because in_path wraps commands into a subprocess:

in_path("some/path") do
  command "echo first"
  command "false"
  command "echo last"
end

produces something like

...
(cd project/some/path && echo first && false && echo last && cd -)
another command
# "echo last" will not be called, but "another command" will

@SwagDevOps
Copy link

My temporary fix is to do

run :local do
  command "something || exit 1"
  command "something else && another || exit 1"
end

What about the following?

run :local do
  command 'set -e'
  command 'something'
  command 'something else'
  command 'another'
end

See : The Set Builtin (Bash Reference Manual)

Even it is preferable to a behavior similar to rake's sh method (throwing exceptions to interrupt workflows a a default).

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

No branches or pull requests

3 participants