cmmorrow / build-magic

A general purpose build/install/deploy tool.
MIT License
9 stars 2 forks source link

Fix the exit code returned at the end of the Engine.run() method. #12

Closed cmmorrow closed 3 years ago

cmmorrow commented 3 years ago

Is your feature request related to a problem? Please describe. Corresponds to the TODO here: https://github.com/cmmorrow/build-magic/blob/main/build_magic/core.py#L160

Describe the solution you'd like Need to bubble up the exit code from the last failing command and make sure it's propagated to the end of the Engine.run() method.

The problem occurs here: https://github.com/cmmorrow/build-magic/blob/main/build_magic/core.py#L436.

# Set the exit code.
fails = map(lambda r: True if r.exit_code > 0 else False, self._results)
if any(fails):
    self._result = 1

If any command fails during stage execution, self._result is set to 1 and is returned instead of the exit code from the failing command. The condition when if any(fails) is True should be changed to instead set self._result to the last non-zero exit code in fails.

ayush714 commented 3 years ago

Can you describe this problem??

cmmorrow commented 3 years ago

Hello @ayush714, I've updated the comment to better describe the problem. Let me know if you have any other questions and thank you for your interest.

cmmorrow commented 3 years ago

After spending some time working on this, I don't like bubbling up the max error code to the CLI. This causes the error code to be unpredictable, where as today, an error code of 1 always indicates a command in a stage failed.