|
| 1 | +name: Test the library |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master # for legacy repos |
| 7 | + - main |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - master # for legacy repos |
| 11 | + - main |
| 12 | + workflow_dispatch: # Allow manually triggering the workflow |
| 13 | + schedule: |
| 14 | + # Run roughly every 15 days at 00:00 UTC |
| 15 | + # (useful to check if updates on dependencies break the package) |
| 16 | + - cron: "0 0 1,16 * *" |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: >- |
| 23 | + ${{ github.workflow }}-${{ github.ref_type }}- |
| 24 | + ${{ github.event.pull_request.number || github.sha }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + test: |
| 29 | + strategy: |
| 30 | + matrix: |
| 31 | + python: ["3.10", "3.11", "3.12", "3.13", "3.14"] |
| 32 | + platform: |
| 33 | + - ubuntu-latest |
| 34 | + - macos-latest |
| 35 | + - windows-latest |
| 36 | + runs-on: ${{ matrix.platform }} |
| 37 | + name: Python ${{ matrix.python }}, ${{ matrix.platform }} |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - uses: actions/setup-python@v5 |
| 42 | + id: setup-python |
| 43 | + with: |
| 44 | + python-version: ${{ matrix.python }} |
| 45 | + |
| 46 | + - name: Install dependencies |
| 47 | + run: | |
| 48 | + python -m pip install --upgrade pip |
| 49 | + pip install tox coverage |
| 50 | +
|
| 51 | + - name: Run tests |
| 52 | + run: >- |
| 53 | + pipx run --python '${{ steps.setup-python.outputs.python-path }}' |
| 54 | + tox |
| 55 | + -- -rFEx --durations 10 --color yes --cov --cov-branch --cov-report=xml # pytest args |
| 56 | +
|
| 57 | + - name: Check for codecov token availability |
| 58 | + id: codecov-check |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + if [ ${{ secrets.CODECOV_TOKEN }} != '' ]; then |
| 62 | + echo "codecov=true" >> $GITHUB_OUTPUT; |
| 63 | + else |
| 64 | + echo "codecov=false" >> $GITHUB_OUTPUT; |
| 65 | + fi |
| 66 | +
|
| 67 | + - name: Upload coverage reports to Codecov with GitHub Action |
| 68 | + uses: codecov/codecov-action@v5 |
| 69 | + if: ${{ steps.codecov-check.outputs.codecov == 'true' }} |
| 70 | + env: |
| 71 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 72 | + slug: ${{ github.repository }} |
| 73 | + flags: ${{ matrix.platform }} - py${{ matrix.python }} |
0 commit comments