|
| 1 | +--- |
| 2 | +name: CI |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + pull_request: |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + tests: |
| 11 | + name: Run tox on ${{ matrix.python-version }} |
| 12 | + runs-on: ubuntu-latest |
| 13 | + env: |
| 14 | + USING_COVERAGE: '3.7,3.8,3.9,3.10,3.11' |
| 15 | + |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + - uses: actions/setup-python@v4 |
| 23 | + with: |
| 24 | + python-version: ${{ matrix.python-version }} |
| 25 | + - name: Install dependencies |
| 26 | + run: | |
| 27 | + python -VV |
| 28 | + python -m site |
| 29 | + python -m pip install --upgrade pip setuptools wheel |
| 30 | + python -m pip install --upgrade coverage[toml] tox tox-gh-actions |
| 31 | +
|
| 32 | + - name: Run tox targets for ${{ matrix.python-version }} |
| 33 | + run: python -m tox |
| 34 | + |
| 35 | + - name: Upload coverage data |
| 36 | + uses: actions/upload-artifact@v3 |
| 37 | + with: |
| 38 | + name: coverage-data |
| 39 | + path: .coverage.* |
| 40 | + if-no-files-found: ignore |
| 41 | + |
| 42 | + coverage: |
| 43 | + name: Combine & check coverage. |
| 44 | + runs-on: ubuntu-latest |
| 45 | + needs: tests |
| 46 | + |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v3 |
| 49 | + |
| 50 | + - uses: actions/setup-python@v4 |
| 51 | + with: |
| 52 | + python-version: ${{env.PYTHON_LATEST}} |
| 53 | + |
| 54 | + - run: python -m pip install --upgrade coverage[toml] |
| 55 | + |
| 56 | + - uses: actions/download-artifact@v3 |
| 57 | + with: |
| 58 | + name: coverage-data |
| 59 | + |
| 60 | + - name: Combine coverage & fail if it's <100%. |
| 61 | + run: | |
| 62 | + python -m coverage combine |
| 63 | + python -m coverage html --skip-covered --skip-empty |
| 64 | + # Report and write to summary. |
| 65 | + python -m coverage report | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY |
| 66 | +
|
| 67 | + - name: Upload HTML report if check failed. |
| 68 | + uses: actions/upload-artifact@v3 |
| 69 | + with: |
| 70 | + name: html-report |
| 71 | + path: htmlcov |
| 72 | + if: ${{ failure() }} |
| 73 | + |
| 74 | + - name: Upload coverage to Codecov |
| 75 | + uses: codecov/codecov-action@v2 |
| 76 | + with: |
| 77 | + fail_ci_if_error: true |
| 78 | + |
| 79 | + docs: |
| 80 | + name: Build docs & run doctests |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v3 |
| 84 | + - uses: actions/setup-python@v4 |
| 85 | + with: |
| 86 | + # Keep in sync with tox.ini/docs & readthedocs.yml |
| 87 | + python-version: "3.8" |
| 88 | + - run: python -m pip install --upgrade wheel tox |
| 89 | + |
| 90 | + - run: python -m tox -e docs |
0 commit comments