-
Notifications
You must be signed in to change notification settings - Fork 8
192 lines (167 loc) · 7.01 KB
/
main.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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# This is a basic workflow to help you get started with Actions
name: apartment-application-service CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
SECRET_KEY: topsecret123
DATABASE_URL: postgres://postgres:postgres@localhost/apartment-application
OIKOTIE_VENDOR_ID: test
ELASTICSEARCH_VERSION: '7.9.1'
ELASTICSEARCH_HOST: localhost
ELASTICSEARCH_URL: http://localhost
APARTMENT_INDEX_NAME: test-apartment
PUBLIC_PGP_KEY: |
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGiBGDJ7egRBACtiOeDD28VV1rViZ0ondhlGdnfEDqgsuGnUPywfDb8h5B9bHxQ
cQj8NuygD9wBInx/H5eO4UkfBjQaUIaWBUSWiynyPfcicOdPOqEFiyliEmB3daqf
H74Tt9dMOaHj43rXal3URKtgiFa/foGa2H5oAXQMtLg8xOrFB/x/BiuBVwCg4dD9
eh/NKo1mSpD6BH3CGlCwdzkD/Re9dmg9lL0K1b+JCjzQ4xF5XzzfMX0dtW9zJbTj
pCjmIrv86FO1wWZq17pMvMStcu08slkMHa8XkIfslN+3CnMDKhBABBDakatKxfu+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yuFd+mZI33G7j0C9inQExBGDJ
7egQBACUuH8uM8auz8SRxOXiAn8pL4Cd44cOCMB3R6aAm6nOU43e39eLvDllgl4U
CfJXDz3nrhMzT6nkSHn3emP15QZfjaCQhKIhmgodvT4TdhuTJ1bFCY1zq+3WV4yr
nJh5IhtRGT9RH/fJ/2eQsXg3F6jbkqMPkM03PEN34E5TcGqAzwADBQP3V4ncVoSF
KUQggTitrQ+cthhr7pu7LbX4i5SbitXqeOU2bH78UgxPeNYlxphtzPhXAAUHalK4
dDPa/yFvouQfTMirv0kHgW+x54VSUntu5U8T/Qh5jm9hra78JF41J/P1Z9QN+qfL
HhFyLfgCoxFZLazDrapc+dWZ3Io04S+8ugAA+gP5E4f6C5Jhj/ocVoNf/0nZi7/4
1a4K2OCfvt7OUkRkExCIYAQYEQIAIBYhBADCerfH00QwdNYDkE4ComjeRsaUBQJg
ye3oAhsMAAoJEE4ComjeRsaUM94An3MYXkfjhakXw/wWoDeuEcpopP5eAJ9AWBHv
zKn2rOFKHBsp2mNyjBa8xw==
=OOZq
-----END PGP PRIVATE KEY BLOCK-----
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
part: [requirements, style, lint, migrations]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
cache: 'pip'
cache-dependency-path: requirements-dev.txt
- name: Install app requirements
run: pip install -r requirements.txt
if: ${{ matrix.part == 'migrations' }}
- name: Install development tools
run: pip install -r requirements-dev.txt
- name: Check requirements files
if: ${{ matrix.part == 'requirements' }}
run: ./check-requirements-files
- name: Check code style
if: ${{ matrix.part == 'style' }}
run: black --check .
- name: Linting
if: ${{ matrix.part == 'lint' }}
run: |
flake8
isort . --check-only --diff
- name: Check migrations
if: ${{ matrix.part == 'migrations' }}
env:
DATABASE_URL: "sqlite:///"
run: |
./manage.py makemigrations --no-input --dry-run
./manage.py makemigrations --no-input --check
test:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.8, 3.9]
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: apartment-application
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
uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: 'pip'
cache-dependency-path: requirements*.txt
- name: Update apt packages
run: sudo apt-get update
- name: psycopg2 prerequisites
run: sudo apt-get install libpq-dev
- name: Install poppler-utils for pdftotext # used in tests
run: sudo apt-get install poppler-utils
- name: Install dependencies
run: |
pip install -U pip
pip install codecov -r requirements.txt -r requirements-dev.txt
# https://github.com/marketplace/actions/setup-elasticsearch
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- uses: getong/[email protected]
with:
elasticsearch version: ${{env.ELASTICSEARCH_VERSION}}
host port: 9200
container port: 9200
host node port: 9300
node port: 9300
discovery type: 'single-node'
- name: Run migrations
run: |
./manage.py migrate
- name: Run tests
run: |
pytest -ra -vvv --doctest-modules --cov=.
- name: Run codecov
run: codecov