|
| 1 | +name: Test, Collect Coverage and Release if tagged |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +jobs: |
| 6 | + test: |
| 7 | + name: Test and collect coverage data |
| 8 | + runs-on: ubuntu-latest |
| 9 | + strategy: |
| 10 | + fail-fast: false |
| 11 | + max-parallel: 3 |
| 12 | + matrix: |
| 13 | + python-version: [ 3.6, 3.7, 3.8 ] |
| 14 | + |
| 15 | + env: |
| 16 | + PYTHON: ${{ matrix.python-version }} |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v2 |
| 19 | + |
| 20 | + - name: Setup Python ${{ matrix.python-version }} |
| 21 | + uses: actions/setup-python@v2 |
| 22 | + with: |
| 23 | + python-version: ${{ matrix.python-version }} |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: | |
| 27 | + python -m pip install --upgrade pip |
| 28 | + pip install -r tests/requirements.txt |
| 29 | +
|
| 30 | + - name: Run unit tests |
| 31 | + run: | |
| 32 | + python -m unittest tests.unit.TerminalUI |
| 33 | +
|
| 34 | + - name: Collect coverage |
| 35 | + run: | |
| 36 | + coverage run --append -m unittest tests.unit.TerminalUI |
| 37 | +
|
| 38 | + - name: Report coverage |
| 39 | + run: | |
| 40 | + coverage report |
| 41 | + coverage xml |
| 42 | +
|
| 43 | + - name: Publish coverage at CodeCov |
| 44 | + uses: codecov/codecov-action@v1 |
| 45 | + with: |
| 46 | + file: ./coverage.xml |
| 47 | + flags: unittests |
| 48 | + env_vars: PYTHON |
| 49 | + |
| 50 | + - name: Publish coverage at Codacy |
| 51 | + uses: codacy/codacy-coverage-reporter-action@master |
| 52 | + with: |
| 53 | + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} |
| 54 | + coverage-reports: ./coverage.xml |
| 55 | + |
| 56 | + release: |
| 57 | + name: Build packages and publish to PyPI if tagged |
| 58 | + needs: [ test ] |
| 59 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 60 | + runs-on: ubuntu-latest |
| 61 | + env: |
| 62 | + PYTHON: "3.8" |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v2 |
| 65 | + |
| 66 | + - name: Setup Python ${{ env.PYTHON }} |
| 67 | + uses: actions/setup-python@v2 |
| 68 | + with: |
| 69 | + python-version: ${{ env.PYTHON }} |
| 70 | + |
| 71 | + - name: Install dependencies for packaging and release |
| 72 | + run: | |
| 73 | + python -m pip install --upgrade pip |
| 74 | + pip install wheel twine |
| 75 | +
|
| 76 | + - name: Build Python package (source distribution) |
| 77 | + run: | |
| 78 | + python setup.py sdist |
| 79 | +
|
| 80 | + - name: Build Python package (binary distribution - wheel) |
| 81 | + run: | |
| 82 | + python setup.py bdist_wheel |
| 83 | +
|
| 84 | + - name: Release Python package to PyPI |
| 85 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 86 | + env: |
| 87 | + TWINE_USERNAME: __token__ |
| 88 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 89 | + run: | |
| 90 | + twine upload dist/* |
0 commit comments