|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - '[0-9].[0-9]+' # matches to backport branches, e.g. 3.6 |
| 8 | + tags: [ 'v*' ] |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - master |
| 12 | + - '[0-9].[0-9]+' |
| 13 | + schedule: |
| 14 | + - cron: '0 6 * * *' # Daily 6AM UTC build |
| 15 | + |
| 16 | + |
| 17 | +jobs: |
| 18 | + |
| 19 | + lint: |
| 20 | + name: Linter |
| 21 | + runs-on: ubuntu-latest |
| 22 | + timeout-minutes: 5 |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v2 |
| 26 | + - name: Setup Python 3.8 |
| 27 | + uses: actions/setup-python@v2 |
| 28 | + with: |
| 29 | + python-version: 3.8 |
| 30 | + - name: Cache PyPI |
| 31 | + uses: actions/cache@v2 |
| 32 | + with: |
| 33 | + key: pip-lint-${{ hashFiles('requirements-dev.txt') }} |
| 34 | + path: ~/.cache/pip |
| 35 | + restore-keys: | |
| 36 | + pip-lint- |
| 37 | + - name: Install dependencies |
| 38 | + uses: py-actions/py-dependency-install@v2 |
| 39 | + with: |
| 40 | + path: requirements.txt |
| 41 | + - name: Install itself |
| 42 | + run: | |
| 43 | + python setup.py install |
| 44 | + - name: Run linter |
| 45 | + run: | |
| 46 | + make flake |
| 47 | + - name: Prepare twine checker |
| 48 | + run: | |
| 49 | + pip install -U twine wheel |
| 50 | + python setup.py sdist bdist_wheel |
| 51 | + - name: Run twine checker |
| 52 | + run: | |
| 53 | + twine check dist/* |
| 54 | +
|
| 55 | + test: |
| 56 | + name: Test |
| 57 | + needs: lint |
| 58 | + strategy: |
| 59 | + matrix: |
| 60 | + pyver: [3.6, 3.7, 3.8, 3.9] |
| 61 | + os: [ubuntu, macos, windows] |
| 62 | + include: |
| 63 | + - pyver: pypy3 |
| 64 | + os: ubuntu |
| 65 | + runs-on: ${{ matrix.os }}-latest |
| 66 | + timeout-minutes: 15 |
| 67 | + steps: |
| 68 | + - name: Checkout |
| 69 | + uses: actions/checkout@v2 |
| 70 | + - name: Setup Python ${{ matrix.pyver }} |
| 71 | + uses: actions/setup-python@v2 |
| 72 | + with: |
| 73 | + python-version: ${{ matrix.pyver }} |
| 74 | + - name: Get pip cache dir |
| 75 | + id: pip-cache |
| 76 | + run: | |
| 77 | + echo "::set-output name=dir::$(pip cache dir)" # - name: Cache |
| 78 | + - name: Cache PyPI |
| 79 | + uses: actions/cache@v2 |
| 80 | + with: |
| 81 | + key: pip-ci-${{ runner.os }}-${{ matrix.pyver }}-${{ hashFiles('requirements-dev.txt') }} |
| 82 | + path: ${{ steps.pip-cache.outputs.dir }} |
| 83 | + restore-keys: | |
| 84 | + pip-ci-${{ runner.os }}-${{ matrix.pyver }}- |
| 85 | + - name: Install dependencies |
| 86 | + uses: py-actions/py-dependency-install@v2 |
| 87 | + with: |
| 88 | + path: requirements.txt |
| 89 | + - name: Run unittests |
| 90 | + env: |
| 91 | + COLOR: 'yes' |
| 92 | + run: | |
| 93 | + pytest tests |
| 94 | + python -m coverage xml |
| 95 | + - name: Upload coverage |
| 96 | + uses: codecov/codecov-action@v1 |
| 97 | + with: |
| 98 | + file: ./coverage.xml |
| 99 | + flags: unit |
| 100 | + fail_ci_if_error: false |
| 101 | + |
| 102 | + deploy: |
| 103 | + name: Deploy |
| 104 | + runs-on: ubuntu-latest |
| 105 | + needs: test |
| 106 | + # Run only on pushing a tag |
| 107 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 108 | + steps: |
| 109 | + - name: Checkout |
| 110 | + uses: actions/checkout@v2 |
| 111 | + - name: Setup Python 3.8 |
| 112 | + uses: actions/setup-python@v2 |
| 113 | + with: |
| 114 | + python-version: 3.8 |
| 115 | + - name: Install dependencies |
| 116 | + run: |
| 117 | + python -m pip install -U pip wheel twine |
| 118 | + - name: Make dists |
| 119 | + run: |
| 120 | + python setup.py sdist bdist_wheel |
| 121 | + - name: PyPI upload |
| 122 | + env: |
| 123 | + TWINE_USERNAME: __token__ |
| 124 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 125 | + run: | |
| 126 | + twine upload dist/* |
0 commit comments