|
| 1 | +name: test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + tags: |
| 8 | + - 'v*.*.*' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - master |
| 12 | + |
| 13 | +jobs: |
| 14 | + test: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + python-version: [ '3.6', '3.7', '3.8' ] |
| 19 | + postgres-version: [ '9.6', '12.1' ] |
| 20 | + services: |
| 21 | + postgres: |
| 22 | + image: fantix/postgres-ssl:${{ matrix.postgres-version }} |
| 23 | + env: |
| 24 | + POSTGRES_USER: gino |
| 25 | + ports: |
| 26 | + - 5432:5432 |
| 27 | + # needed because the postgres container does not provide a healthcheck |
| 28 | + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 |
| 29 | + steps: |
| 30 | + - name: Checkout source code |
| 31 | + uses: actions/checkout@v1 |
| 32 | + - name: Set up Python |
| 33 | + uses: actions/setup-python@v1 |
| 34 | + with: |
| 35 | + python-version: ${{ matrix.python-version }} |
| 36 | + - name: virtualenv cache |
| 37 | + uses: actions/cache@preview |
| 38 | + with: |
| 39 | + path: ~/.cache/pypoetry/virtualenvs |
| 40 | + key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles(format('{0}{1}', github.workspace, '/poetry.lock')) }} |
| 41 | + restore-keys: | |
| 42 | + ${{ runner.os }}-${{ matrix.python-version }}-poetry- |
| 43 | + - name: Install Python dependencies |
| 44 | + run: | |
| 45 | + curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python |
| 46 | + $HOME/.poetry/bin/poetry install |
| 47 | + - name: Test with pytest |
| 48 | + env: |
| 49 | + DB_HOST: localhost |
| 50 | + DB_USER: gino |
| 51 | + run: | |
| 52 | + $HOME/.poetry/bin/poetry run pytest --cov=src --cov=examples --cov-fail-under=95 --cov-report xml |
| 53 | + - name: Check code format with black |
| 54 | + if: matrix.python-version >= '3.6' |
| 55 | + run: | |
| 56 | + $HOME/.poetry/bin/poetry run black --check src |
| 57 | + - name: Submit coverage report |
| 58 | + if: matrix.python-version == '3.8' && matrix.postgres-version == '12.1' && github.ref == 'refs/heads/master' |
| 59 | + env: |
| 60 | + CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_TOKEN }} |
| 61 | + run: | |
| 62 | + pip install codacy-coverage |
| 63 | + python-codacy-coverage -r coverage.xml |
| 64 | + release: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + needs: test |
| 67 | + strategy: |
| 68 | + matrix: |
| 69 | + python-version: [ '3.8' ] |
| 70 | + steps: |
| 71 | + - name: Checkout source code |
| 72 | + if: startsWith(github.ref, 'refs/tags/') |
| 73 | + uses: actions/checkout@v1 |
| 74 | + - name: Set up Python |
| 75 | + if: startsWith(github.ref, 'refs/tags/') |
| 76 | + uses: actions/setup-python@v1 |
| 77 | + with: |
| 78 | + python-version: ${{ matrix.python-version }} |
| 79 | + - name: virtualenv cache |
| 80 | + if: startsWith(github.ref, 'refs/tags/') |
| 81 | + uses: actions/cache@preview |
| 82 | + with: |
| 83 | + path: ~/.cache/pypoetry/virtualenvs |
| 84 | + key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles(format('{0}{1}', github.workspace, '/poetry.lock')) }} |
| 85 | + restore-keys: | |
| 86 | + ${{ runner.os }}-${{ matrix.python-version }}-poetry- |
| 87 | + - name: Release to PyPI |
| 88 | + if: startsWith(github.ref, 'refs/tags/') |
| 89 | + env: |
| 90 | + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} |
| 91 | + run: | |
| 92 | + curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python |
| 93 | + $HOME/.poetry/bin/poetry install |
| 94 | + $HOME/.poetry/bin/poetry build |
| 95 | + $HOME/.poetry/bin/poetry publish --username __token__ --password ${{ secrets.PYPI_TOKEN }} |
0 commit comments