|
| 1 | +name: PyTest |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + pull_request: |
| 9 | + paths: |
| 10 | + - ".github/workflows/test.yml" |
| 11 | + - "src/**" |
| 12 | + - "tests/**" |
| 13 | + - "pyproject.toml" |
| 14 | + - "requirements.txt" |
| 15 | + |
| 16 | +jobs: |
| 17 | + test-against-python-matrix: |
| 18 | + # Only test all the supported versions when a pull request is made or the workflow is called |
| 19 | + if: ${{github.event_name == 'workflow_call'}} || ${{github.event_name == 'pull_request'}} |
| 20 | + runs-on: ubuntu-latest |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + python-version: ["3.10", "3.11", "3.12", "3.13"] |
| 24 | + fail-fast: true |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - uses: actions/setup-python@v5 |
| 28 | + with: |
| 29 | + python-version: ${{ matrix.python-version }} |
| 30 | + cache: "pip" # caching pip dependencies |
| 31 | + - name: Install requirements |
| 32 | + run: | |
| 33 | + python -m pip install -e .[dev] |
| 34 | + - name: Run tests |
| 35 | + run: | |
| 36 | + python -m pytest |
| 37 | +
|
| 38 | + test-against-latest-os: |
| 39 | + # Always run against the latest version on both Windows, Linux, MacOS |
| 40 | + if: github.event.pull_request.user.login != 'dependabot[bot]' |
| 41 | + strategy: |
| 42 | + matrix: |
| 43 | + os: [windows-latest, macos-latest] |
| 44 | + fail-fast: true |
| 45 | + runs-on: ${{ matrix.os }} |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + - uses: actions/setup-python@v5 |
| 49 | + with: |
| 50 | + python-version: "3.12" |
| 51 | + cache: "pip" # caching pip dependencies |
| 52 | + - name: Install requirements |
| 53 | + run: | |
| 54 | + python -m pip install -e .[dev] |
| 55 | + - name: Run tests |
| 56 | + run: | |
| 57 | + python -m pytest |
| 58 | + - name: coverage |
| 59 | + uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: code-coverage-report-${{ matrix.os }} |
| 62 | + path: .coverage |
| 63 | + overwrite: true |
0 commit comments