|
1 | | -# This workflow will install Python dependencies, run tests and lint with a single version of Python |
2 | | -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions |
3 | | - |
4 | 1 | name: Test the library |
5 | 2 |
|
6 | 3 | on: |
7 | 4 | push: |
8 | | - branches: [ main ] |
| 5 | + branches: |
| 6 | + - master # for legacy repos |
| 7 | + - main |
9 | 8 | pull_request: |
10 | | - branches: [ main ] |
| 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 * *" |
11 | 17 |
|
12 | | -jobs: |
13 | | - build: |
| 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 |
14 | 26 |
|
15 | | - runs-on: ubuntu-latest |
| 27 | +jobs: |
| 28 | + test: |
16 | 29 | strategy: |
17 | 30 | matrix: |
18 | | - python-version: [ '3.10' ] |
19 | | - |
20 | | - name: Python ${{ matrix.python-version }} |
| 31 | + python: ["3.10"] # , "3.11", "3.12", "3.13", "3.14" |
| 32 | + platform: |
| 33 | + - Linux-x64 |
| 34 | + # - ubuntu-latest |
| 35 | + # - macos-latest |
| 36 | + # - windows-latest |
| 37 | + runs-on: ${{ matrix.platform }} |
| 38 | + name: Python ${{ matrix.python }}, ${{ matrix.platform }} |
21 | 39 | steps: |
22 | | - - uses: actions/checkout@v3 |
23 | | - - name: Setup Python |
24 | | - uses: actions/setup-python@v4 |
25 | | - with: |
26 | | - python-version: ${{ matrix.python-version }} |
27 | | - cache: 'pip' |
28 | | - - name: Install dependencies |
29 | | - run: | |
30 | | - python -m pip install --upgrade pip |
31 | | - pip install flake8 pytest tox |
32 | | - # - name: Lint with flake8 |
33 | | - # run: | |
34 | | - # # stop the build if there are Python syntax errors or undefined names |
35 | | - # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
36 | | - # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
37 | | - # # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
38 | | - - name: Test with tox |
39 | | - run: | |
40 | | - tox |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - uses: actions/setup-python@v5 |
| 43 | + id: setup-python |
| 44 | + with: |
| 45 | + python-version: ${{ matrix.python }} |
| 46 | + |
| 47 | + - name: Install dependencies |
| 48 | + run: | |
| 49 | + python -m pip install --upgrade pip |
| 50 | + pip install tox coverage |
| 51 | +
|
| 52 | + - name: Run tests |
| 53 | + run: >- |
| 54 | + pipx run --python '${{ steps.setup-python.outputs.python-path }}' |
| 55 | + tox |
| 56 | + -- -rFEx --durations 10 --color yes --cov --cov-branch --cov-report=xml # pytest args |
| 57 | +
|
| 58 | + - name: Check for codecov token availability |
| 59 | + id: codecov-check |
| 60 | + shell: bash |
| 61 | + run: | |
| 62 | + if [ ${{ secrets.CODECOV_TOKEN }} != '' ]; then |
| 63 | + echo "codecov=true" >> $GITHUB_OUTPUT; |
| 64 | + else |
| 65 | + echo "codecov=false" >> $GITHUB_OUTPUT; |
| 66 | + fi |
| 67 | +
|
| 68 | + - name: Upload coverage reports to Codecov with GitHub Action |
| 69 | + uses: codecov/codecov-action@v5 |
| 70 | + if: ${{ steps.codecov-check.outputs.codecov == 'true' }} |
| 71 | + env: |
| 72 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 73 | + slug: ${{ github.repository }} |
| 74 | + flags: ${{ matrix.platform }} - py${{ matrix.python }} |
0 commit comments