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