|
| 1 | +name: Pytest |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [ main ] |
| 7 | + |
| 8 | + |
| 9 | +jobs: |
| 10 | + pytest: |
| 11 | + |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 16 | + python-version: ["3.9", "3.10", "3.11", "pypy3.9", "pypy3.10"] |
| 17 | + exclude: |
| 18 | + - os: macos-latest |
| 19 | + python-version: "3.9" |
| 20 | + - os: windows-latest |
| 21 | + python-version: "3.9" |
| 22 | + |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + - name: Set up Python |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: '3.x' |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + python -m pip install hatch |
| 32 | + hatch env create dev |
| 33 | + - name: Test with pytest |
| 34 | + run: | |
| 35 | + # Need relative files for the action to report, but it messes up mutmut |
| 36 | + echo "[run]" >> .coveragerc |
| 37 | + echo "relative_files = true" >> .coveragerc |
| 38 | + cat .coveragerc |
| 39 | +
|
| 40 | + hatch run dev:pytest |
| 41 | + env: |
| 42 | + COVERAGE_FILE: ".coverage.${{ matrix.os }}.${{ matrix.python-version }}" |
| 43 | + - name: Store coverage file |
| 44 | + uses: actions/upload-artifact@v4 |
| 45 | + with: |
| 46 | + name: coverage-${{ matrix.os }}-${{ matrix.python-version }} |
| 47 | + path: .coverage.${{ matrix.os }}.${{ matrix.python-version }} |
| 48 | + |
| 49 | + coverage: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + needs: pytest |
| 52 | + permissions: |
| 53 | + pull-requests: write |
| 54 | + contents: write |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v4 |
| 57 | + |
| 58 | + - uses: actions/download-artifact@v4 |
| 59 | + id: download |
| 60 | + with: |
| 61 | + pattern: coverage-* |
| 62 | + merge-multiple: true |
| 63 | + - name: Re-add relative so the action is happy |
| 64 | + run: | |
| 65 | + echo "[run]" >> .coveragerc |
| 66 | + echo "relative_files = true" >> .coveragerc |
| 67 | + - name: Python Coverage Comment |
| 68 | + uses: py-cov-action/[email protected] |
| 69 | + with: |
| 70 | + GITHUB_TOKEN: ${{ github.token }} |
| 71 | + MERGE_COVERAGE_FILES: true |
0 commit comments