Tests #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: add all job names to the deploy-status.needs. | |
name: Tests | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- main | |
env: | |
COLUMNS: 120 | |
jobs: | |
test_py_os_variations: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install tox tox-gh-actions | |
- name: Test with tox py${{ matrix.python-version }}-${{ matrix.os }} | |
run: tox -v | |
linters_checkers: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.12 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install .[tests] | |
- name: Mypy, Flake, Bandit, Black | |
run: tox -e mypy,flake8,bandit,black | |
test_full: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.12 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install .[tests] | |
- name: Test pytest | |
run: | | |
pytest --compile -n auto --all --junitxml=./compile-test-results.xml | |
pytest --run -n auto --all --junitxml=./run-test-results.xml | |
- name: Show tests results | |
if: always() | |
uses: pmeier/pytest-results-action@main | |
with: | |
path: ./*-test-results.xml | |
# This allows us to have a branch protection rule this entire workflow | |
deploy-status: | |
runs-on: ubuntu-latest | |
needs: [ test_py_os_variations, linters_checkers, test_full ] | |
if: always() | |
steps: | |
- name: Successful deploy | |
if: ${{ !(contains(needs.*.result, 'failure')) }} | |
run: exit 0 | |
- name: Failing deploy | |
if: ${{ contains(needs.*.result, 'failure') }} | |
run: exit 1 |