pyinfra-dev / pyinfra

pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.
https://pyinfra.com
MIT License
3.85k stars 374 forks source link

pyinfra does not exit with failure when operations are wrapped in python.call #1050

Closed wookayin closed 6 months ago

wookayin commented 8 months ago

Describe the bug

pyinfra does not exit with failure (non-zero exit code) when operations wrapped in python.call are failed. When something goes wrong and there are Errors, the command line should report a non-zero exit code.

To Reproduce

Steps to reproduce the behavior, please include where possible:

from pyinfra.operations import python, server

def foo():
    # fails
    server.shell("/bin/false")

python.call(foo)

Run: pyinfra @local deploy.py

--> Results:
    Groups: @local
    [@local]   Changed: 1   No cahnge: 0   Errors: 1

The process exit code is 0!

Expected behavior

non-zero exit code.

Meta

    System: Linux
      Platform: Linux-5.15.0-91-generic-x86_64-with-glibc2.35
      Release: 5.15.0-91-generic
      Machine: x86_64
    pyinfra: v2.8
    Executable: /SOME/PATH/.venv/bin/pyinfra
    Python: 3.10.12 (CPython, GCC 11.4.0)
Fizzadar commented 6 months ago

This should now be fixed in https://github.com/pyinfra-dev/pyinfra/commit/87e73c68c9890b965e359e4cf4d3f1bf4439873a, released just now in v2.9.1.