-
Notifications
You must be signed in to change notification settings - Fork 4
142 lines (116 loc) · 3.59 KB
/
pipeline.yaml
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Build, Lint, Test
on:
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize
jobs:
lint:
name: ️⚒️ & 👕
strategy:
matrix:
python-version: [3.7, 3.8]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
uses: dschep/install-poetry-action@v1.3
with:
create_virtualenvs: true
- name: Cache Poetry virtualenv
uses: actions/cache@v2
id: cache
with:
path: ~/.virtualenvs
key: poetry-${{ github.ref }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
poetry-${{ github.ref }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
- name: Set Poetry config
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: poetry install
- name: Run pre-commit
if: github.event_name == 'pull_request'
run: |
git fetch origin master:master
poetry run pre-commit run --from-ref master --to-ref HEAD
test:
name: 🧪
needs: lint
strategy:
matrix:
python-version: [3.7, 3.8]
runs-on: ubuntu-latest
services:
postgres:
image: postgres:10-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
uses: dschep/install-poetry-action@v1.3
with:
create_virtualenvs: true
- name: Cache Poetry virtualenv
uses: actions/cache@v2
id: cache
with:
path: ~/.virtualenvs
key: poetry-${{ github.ref }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
poetry-${{ github.ref }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
- name: Set Poetry config
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: poetry install
- name: Unit Test
env:
TEST_DATABASE_BASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}
run: poetry run python -m pytest --cov=psycopg2_pgevents --cov-branch tests/
- name: Submit Code Coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: py-${{ matrix.python-version }}
COVERALLS_PARALLEL: true
run: poetry run coveralls
test-finish:
name: 🚪
needs: test
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip3 install coveralls
coveralls --finish