I have a python script that exits with an error code inside a Github action, but the action still shows a success. I'd like for it to show an error when a non-zero exit code is thrown. Is there anything that should be changed in the script or workflow?
Python script:
import sys
import os
error_code = 256
print(f'error_code: {error_code}')
os._exit(error_code)
# have also tried sys.exit(error_code)
Github Workflow:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: test
run: python3 ./test_error_exit.py
CodePudding user response:
There is no such exit code as 256.
Testing on linux showed that running an exit function with an exit code of 256 actually returned an exit code of 0, meaning no errors occured.
Please try again with an exit code like 5.
import sys
sys.exit(5)