|
| 1 | +name: tests |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +permissions: |
| 6 | + contents: read |
| 7 | + |
| 8 | +env: |
| 9 | + # Environment variables to support color support (jaraco/skeleton#66): |
| 10 | + # Request colored output from CLI tools supporting it. Different tools |
| 11 | + # interpret the value differently. For some, just being set is sufficient. |
| 12 | + # For others, it must be a non-zero integer. For yet others, being set |
| 13 | + # to a non-empty value is sufficient. For tox, it must be one of |
| 14 | + # <blank>, 0, 1, false, no, off, on, true, yes. The only enabling value |
| 15 | + # in common is "1". |
| 16 | + FORCE_COLOR: 1 |
| 17 | + # MyPy's color enforcement (must be a non-zero number) |
| 18 | + MYPY_FORCE_COLOR: -42 |
| 19 | + # Recognized by the `py` package, dependency of `pytest` (must be "1") |
| 20 | + PY_COLORS: 1 |
| 21 | + # Make tox-wrapped tools see color requests |
| 22 | + TOX_TESTENV_PASSENV: >- |
| 23 | + FORCE_COLOR |
| 24 | + MYPY_FORCE_COLOR |
| 25 | + NO_COLOR |
| 26 | + PY_COLORS |
| 27 | + PYTEST_THEME |
| 28 | + PYTEST_THEME_MODE |
| 29 | +
|
| 30 | + # Suppress noisy pip warnings |
| 31 | + PIP_DISABLE_PIP_VERSION_CHECK: 'true' |
| 32 | + PIP_NO_PYTHON_VERSION_WARNING: 'true' |
| 33 | + PIP_NO_WARN_SCRIPT_LOCATION: 'true' |
| 34 | + |
| 35 | + # Disable the spinner, noise in GHA; TODO(webknjaz): Fix this upstream |
| 36 | + # Must be "1". |
| 37 | + TOX_PARALLEL_NO_SPINNER: 1 |
| 38 | + |
| 39 | + |
| 40 | +jobs: |
| 41 | + test: |
| 42 | + strategy: |
| 43 | + matrix: |
| 44 | + python: |
| 45 | + - "3.8" |
| 46 | + - "3.11" |
| 47 | + - "3.12" |
| 48 | + platform: |
| 49 | + - ubuntu-latest |
| 50 | + - macos-latest |
| 51 | + - windows-latest |
| 52 | + include: |
| 53 | + - python: "3.9" |
| 54 | + platform: ubuntu-latest |
| 55 | + - python: "3.10" |
| 56 | + platform: ubuntu-latest |
| 57 | + - python: pypy3.9 |
| 58 | + platform: ubuntu-latest |
| 59 | + runs-on: ${{ matrix.platform }} |
| 60 | + continue-on-error: ${{ matrix.python == '3.12' }} |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v3 |
| 63 | + - name: Setup Python |
| 64 | + uses: actions/setup-python@v4 |
| 65 | + with: |
| 66 | + python-version: ${{ matrix.python }} |
| 67 | + allow-prereleases: true |
| 68 | + - name: Install tox |
| 69 | + run: | |
| 70 | + python -m pip install tox |
| 71 | + - name: Run tests |
| 72 | + run: tox |
| 73 | + |
| 74 | + docs: |
| 75 | + runs-on: ubuntu-latest |
| 76 | + env: |
| 77 | + TOXENV: docs |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v3 |
| 80 | + - name: Setup Python |
| 81 | + uses: actions/setup-python@v4 |
| 82 | + - name: Install tox |
| 83 | + run: | |
| 84 | + python -m pip install tox |
| 85 | + - name: Run tests |
| 86 | + run: tox |
| 87 | + |
| 88 | + check: # This job does nothing and is only used for the branch protection |
| 89 | + if: always() |
| 90 | + |
| 91 | + needs: |
| 92 | + - test |
| 93 | + - docs |
| 94 | + |
| 95 | + runs-on: ubuntu-latest |
| 96 | + |
| 97 | + steps: |
| 98 | + - name: Decide whether the needed jobs succeeded or failed |
| 99 | + uses: re-actors/alls-green@release/v1 |
| 100 | + with: |
| 101 | + jobs: ${{ toJSON(needs) }} |
| 102 | + |
| 103 | + release: |
| 104 | + permissions: |
| 105 | + contents: write |
| 106 | + needs: |
| 107 | + - check |
| 108 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 109 | + runs-on: ubuntu-latest |
| 110 | + |
| 111 | + steps: |
| 112 | + - uses: actions/checkout@v3 |
| 113 | + - name: Setup Python |
| 114 | + uses: actions/setup-python@v4 |
| 115 | + with: |
| 116 | + python-version: 3.x |
| 117 | + - name: Install tox |
| 118 | + run: | |
| 119 | + python -m pip install tox |
| 120 | + - name: Release |
| 121 | + run: tox -e release |
| 122 | + env: |
| 123 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 124 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments