|
| 1 | +# Regular tests |
| 2 | +# |
| 3 | +# Use this to ensure your tests are passing on every push and PR (skipped on |
| 4 | +# pushes which only affect documentation). |
| 5 | +# |
| 6 | +# You should make sure you run jobs on at least the *oldest* and the *newest* |
| 7 | +# versions of python that your codebase is intended to support. |
| 8 | + |
| 9 | +name: tests |
| 10 | + |
| 11 | +on: |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + - dev |
| 16 | + pull_request: |
| 17 | + |
| 18 | +jobs: |
| 19 | + test: |
| 20 | + timeout-minutes: 45 |
| 21 | + defaults: |
| 22 | + run: |
| 23 | + shell: bash |
| 24 | + runs-on: ${{ matrix.os }} |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + os: [ubuntu-latest, macos-13, windows-latest] |
| 29 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] |
| 30 | + env: |
| 31 | + OS: ${{ matrix.os }} |
| 32 | + PYTHON: ${{ matrix.python-version }} |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: Set OS Environment Variables (Windows) |
| 36 | + if: runner.os == 'Windows' |
| 37 | + run: | |
| 38 | + echo 'ACTIVATE_PYTHON_VENV=.venv/scripts/activate' >> $GITHUB_ENV |
| 39 | +
|
| 40 | + - name: Set OS Environment Variables (not Windows) |
| 41 | + if: runner.os != 'Windows' |
| 42 | + run: | |
| 43 | + echo 'ACTIVATE_PYTHON_VENV=.venv/bin/activate' >> $GITHUB_ENV |
| 44 | +
|
| 45 | + - name: Check out repository |
| 46 | + uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - name: Cache $HOME/.local # Significantly speeds up Poetry Install |
| 49 | + uses: actions/cache@v4 |
| 50 | + with: |
| 51 | + path: ~/.local |
| 52 | + key: dotlocal-${{ runner.os }}-${{matrix.python-version}}-${{ hashFiles('.github/workflows/tests.yaml') }} |
| 53 | + |
| 54 | + - name: Set up python ${{ matrix.python-version }} |
| 55 | + uses: actions/setup-python@v5 |
| 56 | + with: |
| 57 | + python-version: ${{ matrix.python-version }} |
| 58 | + |
| 59 | + - name: Install poetry |
| 60 | + uses: snok/install-poetry@v1 |
| 61 | + with: |
| 62 | + virtualenvs-create: true |
| 63 | + virtualenvs-in-project: true |
| 64 | + installer-parallel: false # Currently there seems to be some race-condition in windows |
| 65 | + |
| 66 | + - name: Install library |
| 67 | + run: poetry install --no-interaction |
| 68 | + |
| 69 | + - uses: actions/cache@v4 |
| 70 | + with: |
| 71 | + path: ~/.cache/pre-commit/ |
| 72 | + key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} |
| 73 | + |
| 74 | + - name: Pre-commit run |
| 75 | + run: | |
| 76 | + source ${{ env.ACTIVATE_PYTHON_VENV }} |
| 77 | + pre-commit run --show-diff-on-failure --color=always --all-files |
| 78 | +
|
| 79 | + - name: Check tests folder existence |
| 80 | + id: check_test_files |
| 81 | + uses: andstor/file-existence-action@v3 |
| 82 | + with: |
| 83 | + files: "tests" |
| 84 | + |
| 85 | + - name: Run tests |
| 86 | + if: steps.check_test_files.outputs.files_exists == 'true' |
| 87 | + run: | |
| 88 | + source ${{ env.ACTIVATE_PYTHON_VENV }} |
| 89 | + make test |
| 90 | + coverage report |
| 91 | +
|
| 92 | + #---------------------------------------------- |
| 93 | + # make sure docs build |
| 94 | + #---------------------------------------------- |
| 95 | + - name: Build HTML docs |
| 96 | + run: | |
| 97 | + source ${{ env.ACTIVATE_PYTHON_VENV }} |
| 98 | + mkdocs build |
| 99 | +
|
| 100 | + - name: Upload coverage to Codecov |
| 101 | + if: steps.check_test_files.outputs.files_exists == 'true' |
| 102 | + uses: codecov/codecov-action@v4 |
| 103 | + with: |
| 104 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 105 | + flags: unittests |
| 106 | + env_vars: OS,PYTHON |
| 107 | + name: Python ${{ matrix.python-version }} on ${{ runner.os }} |
0 commit comments