-
Notifications
You must be signed in to change notification settings - Fork 44
352 lines (291 loc) · 10.6 KB
/
ci.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
name: CI tests
on:
pull_request:
push:
branches:
- master
- 'push-action/**'
env:
PYTEST_ADDOPTS: "--color=yes"
# Cancel running workflows when additional changes are pushed
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-a-fallback-value
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
requirements*.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel
pip install -e .
pip install -r requirements.txt
pip install -r requirements-server.txt
pip install -r requirements-dev.txt
- name: Run pre-commit
run: |
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
openapi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
requirements*.txt
- name: Install tools
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel
pip install -e .
pip install -r requirements.txt
pip install -r requirements-server.txt
pip install -r requirements-dev.txt
- name: Pass generated OpenAPI schemas through validator.swagger.io
run: |
invoke swagger-validator openapi/openapi.json
invoke swagger-validator openapi/index_openapi.json
- name: Check OpenAPI Schemas have not changed
run: invoke check-openapi-diff
docker-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build the container image
run: docker build -f Dockerfile --build-arg CONFIG_FILE=.docker/docker_config.json --tag optimade .
- name: Start Docker image - server
run: |
docker run --rm -d -p 3213:5000 --name optimade optimade
.github/utils/wait_for_it.sh localhost:3213 -t 120
sleep 15
- name: Test server, including OPTIONAL base URLs
uses: Materials-Consortia/optimade-validator-action@v2
with:
port: 3213
path: /
all versioned paths: yes
validator version: ${{ github.sha }} # This ensures the head of a PR or latest push commit is tested
- name: Start Docker image - index server
run: |
docker run --rm -d -p 3214:5000 --name optimade-index -e MAIN=main_index optimade
.github/utils/wait_for_it.sh localhost:3214 -t 120
sleep 15
- name: Test index server, including OPTIONAL base URLs
uses: Materials-Consortia/optimade-validator-action@v2
with:
port: 3214
path: /
all versioned paths: yes
index: yes
validator version: ${{ github.sha }} # This ensures the head of a PR or latest push commit is tested
pytest:
runs-on: ubuntu-latest
env:
OPTIMADE_CONFIG_FILE: ${{ github.workspace }}/optimade_config.json
strategy:
fail-fast: false
max-parallel: 4
matrix:
python-version: ['3.9', '3.10', '3.11']
services:
mongo:
image: mongo:6
ports:
- 27017:27017
postgres:
image: postgres:10
env:
POSTGRES_DB: test_aiida
POSTGRES_PASSWORD: test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
elasticsearch:
image: elasticsearch:7.17.7
ports:
- 9200:9200
- 9300:9300
env:
discovery.type: single-node
xpack.security.enabled: 'false'
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
requirements*.txt
- name: Install latest compatible versions of immediate dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel
pip install -e .
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install -r requirements-http-client.txt
- name: Run non-server tests
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml tests/ --ignore tests/server
- name: Install latest server dependencies
run: pip install -r requirements-server.txt
- name: Run server tests (using `mongomock`)
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
env:
OPTIMADE_DATABASE_BACKEND: 'mongomock'
- name: Run server tests with no API validation (using `mongomock`)
run:
pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
env:
OPTIMADE_DATABASE_BACKEND: 'mongomock'
OPTIMADE_VALIDATE_API_RESPONSE: false
- name: Run server tests (using a real MongoDB)
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
env:
OPTIMADE_DATABASE_BACKEND: 'mongodb'
- name: Run server tests (using Elasticsearch)
run: |
.github/utils/wait_for_it.sh localhost:9200 -t 120
.github/utils/wait_for_it.sh localhost:9300 -t 120
pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
env:
OPTIMADE_DATABASE_BACKEND: 'elastic'
- name: Install adapter conversion dependencies
run: pip install -r requirements-client.txt
- name: Setup environment for AiiDA
env:
AIIDA_TEST_BACKEND: core.psql_dos
run: |
.github/aiida/setup_aiida.sh
- name: Run previously skipped tests for adapter conversion
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/adapters/
- name: Run tests for validator only to assess coverage (mongomock)
if: matrix.python-version == 3.10
run: pytest -rs --cov=./optimade/ --cov-report=xml:validator_cov.xml --cov-append tests/server/test_server_validation.py
env:
OPTIMADE_DATABASE_BACKEND: 'mongomock'
- name: Run tests for validator only to assess coverage (Elasticsearch)
if: matrix.python-version == 3.10
run: pytest -rs --cov=./optimade/ --cov-report=xml:validator_cov.xml --cov-append tests/server/test_server_validation.py
env:
OPTIMADE_DATABASE_BACKEND: 'elastic'
OPTIMADE_INSERT_TEST_DATA: false # Must be specified as previous steps will have already inserted the test data
- name: Run tests for validator only to assess coverage (MongoDB)
if: matrix.python-version == 3.10
run: pytest -rs --cov=./optimade/ --cov-report=xml:validator_cov.xml --cov-append tests/server/test_server_validation.py
env:
OPTIMADE_DATABASE_BACKEND: 'mongodb'
OPTIMADE_INSERT_TEST_DATA: false # Must be specified as previous steps will have already inserted the test data
- name: Run the OPTIMADE Client CLI
if: matrix.python-version == 3.10
run: |
coverage run --append --source optimade optimade/client/cli.py \
--filter 'nsites = 1' \
--output-file test_get_async.json \
https://optimade.fly.dev
test test_get_async.json
coverage run --append --source optimade optimade/client/cli.py \
--filter 'nsites = 1' \
--count \
--output-file test_count.json \
https://optimade.fly.dev
test test_count.json
coverage run --append --source optimade optimade/client/cli.py \
--no-async \
--filter 'nsites = 1' \
--count \
--output-file test_count_no_async.json \
https://optimade.fly.dev
test test_count_no_async.json
diff test_count_no_async.json test_count.json
coverage xml
- name: Upload coverage to Codecov
if: matrix.python-version == '3.10' && github.repository == 'Materials-Consortia/optimade-python-tools'
uses: codecov/codecov-action@v3
with:
name: project
file: ./coverage.xml
flags: project
- name: Upload validator coverage to Codecov
if: matrix.python-version == '3.10' && github.repository == 'Materials-Consortia/optimade-python-tools'
uses: codecov/codecov-action@v3
with:
name: validator
file: ./validator_cov.xml
flags: validator
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
requirements*.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel
pip install -e .
pip install -r requirements.txt
pip install -r requirements-server.txt
pip install -r requirements-dev.txt
pip install -r requirements-http-client.txt
pip install -r requirements-docs.txt
# NOTE: While we're now using `mike`, this is still useful
# to test the integrity of the documentation build.
- name: Build
run: |
invoke create-api-reference-docs --pre-clean
mkdocs build --strict
test_build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
requirements*.txt
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools requests
- name: Install package
run: |
pip install -r requirements.txt -r requirements-dev.txt -r requirements-client.txt -r requirements-http-client.txt -r requirements-docs.txt
pip install -e .[all]
- name: Build source distribution
run: python -m build