diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml new file mode 100644 index 0000000..bbf05c2 --- /dev/null +++ b/.github/workflows/python-ci.yml @@ -0,0 +1,53 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python CI + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.11.9 + uses: actions/setup-python@v3 + if: ${{ hashFiles('./test') != '' }} + with: + python-version: "3.11.9" + - name: Install dependencies + if: ${{ hashFiles('./test') != '' }} + run: | + python -m pip install --upgrade pip + if [ -f system/requirements/requirements_unit_test.txt ]; then + pip install -r system/requirements/requirements_unit_test.txt; + fi + - name: Test with pytest + if: ${{ hashFiles('./test') != '' }} + run: | + pytest test --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + - name: Surface failing tests + if: always() + uses: pmeier/pytest-results-action@v0.6.0 + with: + # A list of JUnit XML files, directories containing the former, and wildcard + # patterns to process. + # See @actions/glob for supported patterns. + path: junit/test-results.xml + + # (Optional) Add a summary of the results at the top of the report + summary: true + + # (Optional) Select which results should be included in the report. + # Follows the same syntax as `pytest -r` + display-options: fEX + + # (Optional) Fail the workflow if no JUnit XML was found. + fail-on-empty: false + + # (Optional) Title of the test results section in the workflow summary + title: Test results \ No newline at end of file diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..a635c5c --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +pythonpath = . diff --git a/system/requirements/requirements_unit_test.txt b/system/requirements/requirements_unit_test.txt new file mode 100644 index 0000000..e7c14f1 --- /dev/null +++ b/system/requirements/requirements_unit_test.txt @@ -0,0 +1,4 @@ +filelock>=3.16.1 +pydantic>=2.7.0 +pytest>=8.3.3 +pytest-cov>=6.0.0 \ No newline at end of file