diff --git a/.github/workflows/dynamic-readme.yaml b/.github/workflows/dynamic-readme.yaml index b2d9ff5..c7b992b 100644 --- a/.github/workflows/dynamic-readme.yaml +++ b/.github/workflows/dynamic-readme.yaml @@ -4,6 +4,8 @@ on: push: paths: - 'app/version' + branches-ignore: + - main permissions: contents: write diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml new file mode 100644 index 0000000..aaaeed0 --- /dev/null +++ b/.github/workflows/run_tests.yaml @@ -0,0 +1,40 @@ +name: Run Tests +on: + pull_request: + branches: + - main # Run on PRs targeting main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.13 + uses: actions/setup-python@v5 + with: + python-version: '3.13' + + - name: Run tests + id: run_tests + run: | + set -e # Exit immediately if a command exits with a non-zero status + ./ace --test + continue-on-error: false + + - name: Upload test results + if: always() # Run even if tests fail + uses: actions/upload-artifact@v4 + with: + name: pytest-results + path: | + .pytest_cache/ + tests/**/test-*.xml + tests/**/test-*.html + + # Force the workflow to fail if tests failed + - name: Fail workflow if tests failed + if: failure() + run: | + echo "Tests failed - failing workflow" + exit 1 diff --git a/ace b/ace index 85b50d7..1109cc1 100755 --- a/ace +++ b/ace @@ -10,8 +10,7 @@ run_tests() { pip install --upgrade -r tests/requirements python -m pytest tests/unit/ -v - deactivate - exit 0 + exit $? } run_ace() { @@ -22,7 +21,7 @@ run_ace() { ACE_LOGGER_FILE_NAME="startup" ACE_LOGGER_VERBOSE="$ACE_LOGGER_VERBOSE_ENV" ./startup.py "${@}" deactivate - exit 0 + exit $? } # MAIN @@ -60,4 +59,6 @@ main() { run_ace "${original_args[@]}" } +trap 'exit $?' ERR + main "$@" \ No newline at end of file diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 8209f3a..5ebd280 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -25,3 +25,8 @@ def pytest_sessionfinish(session, exitstatus): print(f"Warning: Could not remove {folder_path} - Permission denied") except Exception as e: print(f"Warning: Could not remove {folder_path} - {str(e)}") + if session.testsfailed > 0: + print("Tests failed!") + # Force exit status to 1 if any tests failed + session.exitstatus = 1 + return session.exitstatus diff --git a/tests/unit/logger/test_logger.py b/tests/unit/logger/test_logger.py index 8374e31..b0766c4 100644 --- a/tests/unit/logger/test_logger.py +++ b/tests/unit/logger/test_logger.py @@ -3,7 +3,6 @@ import json import logging import os -import shutil import signal import sys from unittest import mock