|
| 1 | +name: check |
| 2 | +on: |
| 3 | + push: |
| 4 | + pull_request: |
| 5 | + schedule: |
| 6 | + - cron: "0 8 * * *" |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: check-${{ github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + test: |
| 14 | + name: test with CPython ${{ matrix.py }} |
| 15 | + runs-on: ubuntu-20.04 |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + py: |
| 20 | + - "3.10" |
| 21 | + - "3.9" |
| 22 | + - "3.8" |
| 23 | + - "3.7" |
| 24 | + steps: |
| 25 | + - name: Setup python for tox |
| 26 | + uses: actions/setup-python@v2 |
| 27 | + with: |
| 28 | + python-version: "3.10" |
| 29 | + - name: Install tox |
| 30 | + run: python -m pip install tox |
| 31 | + - uses: actions/checkout@v2 |
| 32 | + with: |
| 33 | + fetch-depth: 0 |
| 34 | + - name: Setup python for test ${{ matrix.py }} |
| 35 | + uses: actions/setup-python@v2 |
| 36 | + with: |
| 37 | + python-version: ${{ matrix.py }} |
| 38 | + - name: Pick environment to run |
| 39 | + run: | |
| 40 | + import os |
| 41 | + import sys |
| 42 | + from pathlib import Path |
| 43 | + env = "TOXENV=py{}{}\n".format(*sys.version_info[0:2]) |
| 44 | + print("Picked:\n{}for{}".format(env, sys.version)) |
| 45 | + with Path(os.environ["GITHUB_ENV"]).open("a") as file_handler: |
| 46 | + file_handler.write(env) |
| 47 | + shell: python |
| 48 | + - name: Setup test suite |
| 49 | + run: tox -vv --notest |
| 50 | + - name: Run test suite |
| 51 | + run: tox --skip-pkg-install |
| 52 | + env: |
| 53 | + PYTEST_ADDOPTS: "-vv --durations=20" |
| 54 | + CI_RUN: "yes" |
| 55 | + DIFF_AGAINST: HEAD |
| 56 | + - name: Rename coverage report file |
| 57 | + run: |
| 58 | + import os; import sys; os.rename(f".tox/.coverage.{os.environ['TOXENV']}", |
| 59 | + f".tox/.coverage.{os.environ['TOXENV']}-{sys.platform}") |
| 60 | + shell: python |
| 61 | + - name: Upload coverage data |
| 62 | + uses: actions/upload-artifact@v2 |
| 63 | + with: |
| 64 | + name: coverage-data |
| 65 | + path: ".tox/.coverage.*" |
| 66 | + |
| 67 | + coverage: |
| 68 | + name: Combine coverage |
| 69 | + runs-on: ubuntu-20.04 |
| 70 | + needs: test |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v2 |
| 73 | + with: |
| 74 | + fetch-depth: 0 |
| 75 | + - uses: actions/setup-python@v2 |
| 76 | + with: |
| 77 | + python-version: "3.10" |
| 78 | + - name: Install tox |
| 79 | + run: python -m pip install tox |
| 80 | + - name: Setup coverage tool |
| 81 | + run: tox -e coverage --notest |
| 82 | + - name: Install package builder |
| 83 | + run: python -m pip install build |
| 84 | + - name: Build package |
| 85 | + run: pyproject-build --wheel . |
| 86 | + - name: Download coverage data |
| 87 | + uses: actions/download-artifact@v2 |
| 88 | + with: |
| 89 | + name: coverage-data |
| 90 | + path: .tox |
| 91 | + - name: Combine and report coverage |
| 92 | + run: tox -e coverage |
| 93 | + - name: Upload HTML report |
| 94 | + uses: actions/upload-artifact@v2 |
| 95 | + with: |
| 96 | + name: html-report |
| 97 | + path: .tox/htmlcov |
| 98 | + |
| 99 | + check: |
| 100 | + name: tox env ${{ matrix.tox_env }} |
| 101 | + runs-on: ubuntu-20.04 |
| 102 | + strategy: |
| 103 | + fail-fast: false |
| 104 | + matrix: |
| 105 | + tox_env: |
| 106 | + - dev |
| 107 | + - readme |
| 108 | + steps: |
| 109 | + - uses: actions/checkout@v2 |
| 110 | + with: |
| 111 | + fetch-depth: 0 |
| 112 | + - name: Setup Python "3.10" |
| 113 | + uses: actions/setup-python@v2 |
| 114 | + with: |
| 115 | + python-version: "3.10" |
| 116 | + - name: Install tox |
| 117 | + run: python -m pip install tox |
| 118 | + - name: Setup test suite |
| 119 | + run: tox -vv --notest -e ${{ matrix.tox_env }} |
| 120 | + - name: Run test suite |
| 121 | + run: tox --skip-pkg-install -e ${{ matrix.tox_env }} |
| 122 | + |
| 123 | + publish: |
| 124 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 125 | + needs: [check, coverage] |
| 126 | + runs-on: ubuntu-20.04 |
| 127 | + steps: |
| 128 | + - name: Setup python to build package |
| 129 | + uses: actions/setup-python@v2 |
| 130 | + with: |
| 131 | + python-version: "3.10" |
| 132 | + - name: Install build |
| 133 | + run: python -m pip install build |
| 134 | + - uses: actions/checkout@v2 |
| 135 | + with: |
| 136 | + fetch-depth: 0 |
| 137 | + - name: Build sdist and wheel |
| 138 | + run: python -m build -s -w . -o dist |
| 139 | + - name: Publish to PyPi |
| 140 | + uses: pypa/gh-action-pypi-publish@master |
| 141 | + with: |
| 142 | + skip_existing: true |
| 143 | + user: __token__ |
| 144 | + password: ${{ secrets.pypi_password }} |
0 commit comments