|
1 | | -name: Run tests |
| 1 | +name: Test the library |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: [main] |
| 5 | + branches: |
| 6 | + - master # for legacy repos |
| 7 | + - main |
6 | 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 |
7 | 26 |
|
8 | 27 | jobs: |
9 | | - build: |
10 | | - runs-on: ubuntu-latest |
| 28 | + test: |
11 | 29 | strategy: |
12 | 30 | matrix: |
13 | | - python-version: ["3.9", "3.10", "3.11", "3.12"] |
14 | | - |
15 | | - name: Python ${{ matrix.python-version }} |
| 31 | + python: ["3.9", "3.10", "3.11", "3.12"] |
| 32 | + platform: |
| 33 | + - ubuntu-latest |
| 34 | + - macos-latest |
| 35 | + # - windows-latest |
| 36 | + runs-on: ${{ matrix.platform }} |
| 37 | + name: Python ${{ matrix.python }}, ${{ matrix.platform }} |
16 | 38 | steps: |
17 | 39 | - uses: actions/checkout@v4 |
18 | 40 |
|
19 | | - - name: Setup Python |
20 | | - uses: actions/setup-python@v5 |
| 41 | + - uses: actions/setup-python@v5 |
| 42 | + id: setup-python |
21 | 43 | with: |
22 | | - python-version: ${{ matrix.python-version }} |
23 | | - cache: "pip" |
| 44 | + python-version: ${{ matrix.python }} |
24 | 45 |
|
25 | 46 | - name: Install dependencies |
26 | 47 | run: | |
27 | 48 | python -m pip install --upgrade pip |
28 | | - pip install tox |
| 49 | + pip install tox coverage |
29 | 50 |
|
30 | | - - name: Test with tox |
31 | | - run: | |
| 51 | + - name: Run tests |
| 52 | + run: >- |
| 53 | + pipx run --python '${{ steps.setup-python.outputs.python-path }}' |
32 | 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