|
| 1 | +name: Pytest |
| 2 | +on: |
| 3 | + push: |
| 4 | + pull_request: |
| 5 | + workflow_dispatch: |
| 6 | + schedule: |
| 7 | + - cron: '0 0 * * *' |
| 8 | +concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | +jobs: |
| 12 | + tests: |
| 13 | + name: pytest - ${{ matrix.os }} - py${{ matrix.python-version }} |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + os: [ ubuntu-latest, windows-latest ] |
| 19 | + python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] |
| 20 | + env: |
| 21 | + PYTHONUTF8: "1" |
| 22 | + PYTHONPATH: ${{ github.workspace }}/service |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Set up Python |
| 28 | + uses: actions/setup-python@v5 |
| 29 | + with: |
| 30 | + python-version: ${{ matrix.python-version }} |
| 31 | + cache: "pip" |
| 32 | + |
| 33 | + - name: Install deps (Ubuntu) |
| 34 | + if: matrix.os == 'ubuntu-latest' |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + set -eux |
| 38 | + python -m pip install -U pip |
| 39 | + pip install -r service/requirements.test.txt |
| 40 | + if [ -f service/pyproject.toml ] || [ -f service/setup.cfg ] || [ -f service/setup.py ]; then |
| 41 | + pip install -e service |
| 42 | + fi |
| 43 | + - name: Install deps (Windows) |
| 44 | + if: matrix.os == 'windows-latest' |
| 45 | + shell: pwsh |
| 46 | + run: | |
| 47 | + $ErrorActionPreference = "Stop" |
| 48 | + python -m pip install -U pip |
| 49 | + pip install -r service/requirements.test.txt |
| 50 | + $hasPythonProject = (Test-Path -Path 'service/pyproject.toml') -or |
| 51 | + (Test-Path -Path 'service/setup.cfg') -or |
| 52 | + (Test-Path -Path 'service/setup.py') |
| 53 | + if ($hasPythonProject) { |
| 54 | + python -m pip install -e service |
| 55 | + } else { |
| 56 | + Write-Host 'service packaging files not found; skipping' |
| 57 | + } |
| 58 | + - name: Show versions |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + python --version |
| 62 | + pip --version |
| 63 | + pytest --version |
| 64 | + python -c "import sys,platform,os;print(platform.platform());print(sys.version);print('PYTHONPATH=',os.environ.get('PYTHONPATH'))" |
| 65 | + - name: Run tests with coverage |
| 66 | + shell: bash |
| 67 | + run: | |
| 68 | + python -m coverage run -m pytest -q |
| 69 | + python -m coverage xml -o coverage.xml |
| 70 | + - name: Upload coverage.xml |
| 71 | + uses: actions/upload-artifact@v4 |
| 72 | + with: |
| 73 | + name: coverage-${{ matrix.os }}-py${{ matrix.python-version }} |
| 74 | + path: coverage.xml |
| 75 | + if-no-files-found: error |
| 76 | + |
0 commit comments