-
Notifications
You must be signed in to change notification settings - Fork 1
307 lines (253 loc) · 7.69 KB
/
ci_tests.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
name: Test optimade-validator GitHub Action
on:
pull_request:
push:
branches:
- master
- 'push-action/**'
env:
PYTHON_VERSION: "3.10"
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Python dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
while IFS="" read -r line || [ -n "${line}" ]; do
if [[ "${line}" =~ ^pre-commit.*$ ]]; then
pre_commit="${line}"
elif [[ "${line}" =~ ^invoke.*$ ]]; then
invoke="${line}"
fi
done < requirements.txt
pip install ${pre_commit} ${invoke}
- name: Run pre-commit
run: SKIP=pylint pre-commit run --all-files --show-diff-on-failure
pylint-safety:
runs-on: ubuntu-latest
name: pylint & safety
steps:
- uses: actions/checkout@v4
- name: Setup Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Python dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
pip install -r requirements.txt
pip install safety
- name: Run pylint
run: pylint --rcfile=pyproject.toml *.py
# ID: 70612
# Package: Jinja2
# Has been disputed by the maintainer and multiple third parties.
# For more information see: https://github.com/advisories/GHSA-f6pv-j8mr-w6rr
- name: Run safety
run: pip freeze | safety check --stdin --ignore=70612
validator_regular:
runs-on: ubuntu-latest
name: Regular server
services:
optimade:
image: ghcr.io/materials-consortia/optimade:develop
ports:
- 3213:5000
env:
OPTIMADE_BASE_URL: http://gh_actions_host:3213
steps:
- uses: actions/checkout@v4
- name: Run action (validating the unversioned path)
uses: ./
with:
port: 3213
path: /
validate unversioned path: yes
- name: Run action (without validating the unversioned path)
uses: ./
with:
port: 3213
path: /
validate unversioned path: no
validator_index:
runs-on: ubuntu-latest
name: Index server
services:
optimade_index:
image: ghcr.io/materials-consortia/optimade:develop
ports:
- 3214:5000
env:
MAIN: main_index
OPTIMADE_BASE_URL: http://gh_actions_host:3214
steps:
- uses: actions/checkout@v4
- name: Run action
uses: ./
with:
port: 3214
path: /
index: yes
all_versioned_paths:
runs-on: ubuntu-latest
name: All versioned paths for regular server
services:
optimade:
image: ghcr.io/materials-consortia/optimade:develop
ports:
- 3213:5000
env:
OPTIMADE_BASE_URL: http://gh_actions_host:3213
steps:
- uses: actions/checkout@v4
- name: Run action
uses: ./
with:
port: 3213
path: /
all versioned paths: yes
validate unversioned path: yes
- name: Run action (setting path to empty string)
uses: ./
with:
port: 3213
path: ""
all versioned paths: yes
validate unversioned path: yes
bats:
runs-on: ubuntu-latest
name: Run BATS test suite for entrypoint.sh
permissions:
packages: read
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Setup BATS and BATS libs
id: setup-bats
uses: bats-core/[email protected]
with:
support-install: true
support-path: "${{ github.workspace }}/tests/bats-support"
assert-install: true
assert-path: "${{ github.workspace }}/tests/bats-assert"
detik-install: false
file-install: false
- name: Run BATS tests
shell: bash
env:
BATS_LIB_PATH: ${{ steps.setup-bats.outputs.lib-path }}
run: bats ./tests
validator_version:
runs-on: ubuntu-latest
name: Use validator from git commit sha
services:
optimade:
image: ghcr.io/materials-consortia/optimade:develop
ports:
- 3213:5000
env:
OPTIMADE_BASE_URL: http://gh_actions_host:3213
steps:
- uses: actions/checkout@v4
- name: Run action
uses: ./
with:
port: 3213
path: /
validator version: c6551e27f64abdaa94afd401db22af9ef2afd23d
validator_version_fail:
runs-on: ubuntu-latest
name: Use validator with wrong version
services:
optimade:
image: ghcr.io/materials-consortia/optimade:develop
ports:
- 3213:5000
env:
OPTIMADE_BASE_URL: http://gh_actions_host:3213
steps:
- uses: actions/checkout@v4
- name: Run action
id: action
continue-on-error: true
uses: ./
with:
port: 3213
path: /
validator version: "0.0.0"
- name: This runs ONLY if 'Run action' doesn't fail as expected
if: steps.action.outcome != 'failure' || steps.action.conclusion != 'success'
run: |
echo "Outcome: ${{ steps.action.outcome }} (not 'failure'), Conclusion: ${{ steps.action.conclusion }} (not 'success')"
exit 1
results_output:
runs-on: ubuntu-latest
name: Retrieve and check validator results
services:
optimade:
image: ghcr.io/materials-consortia/optimade:develop
ports:
- 3213:5000
env:
OPTIMADE_BASE_URL: http://gh_actions_host:3213
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Run action to retrieve output
id: action
uses: ./
with:
port: 3213
path: /
create output: true
- name: Check "default" output
env:
RESULTS: "${{ steps.action.outputs.results }}"
run: python .github/utils/ci_helper.py default
- name: Run action with "all versioned paths" to retrieve output
id: action_all
uses: ./
with:
port: 3213
path: /
create output: true
all versioned paths: true
- name: Check "all versioned paths" output
env:
RESULTS: "${{ steps.action_all.outputs.results }}"
run: python .github/utils/ci_helper.py all_versioned_paths
- name: Run action with "validate unversioned path" to retrieve output
id: action_unversioned
uses: ./
with:
port: 3213
path: /
create output: true
validate unversioned path: true
- name: Check "validate unversioned path" output
env:
RESULTS: "${{ steps.action_unversioned.outputs.results }}"
run: python .github/utils/ci_helper.py validate_unversioned_path
- name: Run action with "as type" to retrieve output
id: action_astype
uses: ./
with:
port: 3213
path: /v1.1/structures
create output: true
as type: structures
- name: Check "as type" output
env:
RESULTS: "${{ steps.action_astype.outputs.results }}"
run: python .github/utils/ci_helper.py as_type