-
Notifications
You must be signed in to change notification settings - Fork 2
323 lines (272 loc) · 9.64 KB
/
python_harness.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
name: Python build harness
on:
- push
env:
FLIT_ROOT_INSTALL: 1
PYPI_API_USER: __token__
VENV_DIR: /venv
VENV_BIN: /venv/bin
CALL_TARGET: /venv/bin/build-harness
IMAGE_PATH: "foodxtech/foodx-devops-tools-pipeline:${{ github.sha }}"
jobs:
build-docker-image:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: |
docker build \
-t ${{ env.IMAGE_PATH }} \
docker/pipeline
docker push ${{ env.IMAGE_PATH }}
formatting-check:
env:
TARGET: formatting --check
needs:
- build-docker-image
container:
image: "foodxtech/foodx-devops-tools-pipeline:${{ github.sha }}"
runs-on: ubuntu-20.04
steps:
# work around github bug https://github.com/actions/checkout/issues/760
# this git config must occur BEFORE the checkout action
- run: |
git config --global --add safe.directory /__w/foodx_devops_tools/foodx_devops_tools
- uses: actions/checkout@v2
- run: |
${{ env.CALL_TARGET }} \
--log-enable-console \
--log-level debug \
${TARGET}
flake8-check:
env:
TARGET: static-analysis --analysis flake8
needs:
- build-docker-image
container:
image: "foodxtech/foodx-devops-tools-pipeline:${{ github.sha }}"
runs-on: ubuntu-20.04
steps:
# work around github bug https://github.com/actions/checkout/issues/760
# this git config must occur BEFORE the checkout action
- run: |
git config --global --add safe.directory /__w/foodx_devops_tools/foodx_devops_tools
- uses: actions/checkout@v2
- run: |
echo "system Python version: "$(python3 --version)
echo "venv Python version: "$(${{ env.VENV_BIN }}/python3 --version)
${{ env.CALL_TARGET }} \
--log-enable-console \
--log-level debug \
${TARGET}
mypy-check:
env:
TARGET: static-analysis --analysis mypy
needs:
- build-docker-image
container:
image: "foodxtech/foodx-devops-tools-pipeline:${{ github.sha }}"
runs-on: ubuntu-20.04
steps:
# work around github bug https://github.com/actions/checkout/issues/760
# this git config must occur BEFORE the checkout action
- run: |
git config --global --add safe.directory /__w/foodx_devops_tools/foodx_devops_tools
- uses: actions/checkout@v2
- run: |
${{ env.CALL_TARGET }} \
--log-enable-console \
--log-level debug \
${TARGET}
pydocstyle-check:
env:
TARGET: static-analysis --analysis pydocstyle
needs:
- build-docker-image
container:
image: "foodxtech/foodx-devops-tools-pipeline:${{ github.sha }}"
runs-on: ubuntu-20.04
steps:
# work around github bug https://github.com/actions/checkout/issues/760
# this git config must occur BEFORE the checkout action
- run: |
git config --global --add safe.directory /__w/foodx_devops_tools/foodx_devops_tools
- uses: actions/checkout@v2
- run: |
${{ env.CALL_TARGET }} \
--log-enable-console \
--log-level debug \
${TARGET}
unit-tests:
env:
# have to avoid the new manual directory in CI pipeline
TARGET: unit-test --test-dir tests/ci
needs:
- build-docker-image
container:
image: "foodxtech/foodx-devops-tools-pipeline:${{ github.sha }}"
runs-on: ubuntu-20.04
steps:
# work around github bug https://github.com/actions/checkout/issues/760
# this git config must occur BEFORE the checkout action
- run: |
git config --global --add safe.directory /__w/foodx_devops_tools/foodx_devops_tools
- uses: actions/checkout@v2
- run: |
${{ env.CALL_TARGET }} \
--log-enable-console \
--log-level debug \
${TARGET}
- uses: actions/upload-artifact@v2
if: failure()
with:
name: unittests-log
path: build_harness.log
unit-tests-coverage-report:
env:
# Don't forget to update the coverage threshold in .pre-commit-config.yaml
# have to avoid the new manual directory in CI pipeline
TARGET: unit-test --test-dir tests/ci --coverage-html
needs:
- build-docker-image
container:
image: "foodxtech/foodx-devops-tools-pipeline:${{ github.sha }}"
runs-on: ubuntu-20.04
steps:
# work around github bug https://github.com/actions/checkout/issues/760
# this git config must occur BEFORE the checkout action
- run: |
git config --global --add safe.directory /__w/foodx_devops_tools/foodx_devops_tools
- uses: actions/checkout@v2
- run: ${{ env.CALL_TARGET }} ${TARGET}
- uses: actions/upload-artifact@v2
with:
name: coverage-report-artifacts-${{ matrix.python-version }}
path: dist/coverage_report
unit-tests-coverage-check:
env:
# Don't forget to update the coverage threshold in .pre-commit-config.yaml
# Setting CI threshold to 80% because GHA calculates a different coverage result than locally (92%);
# the problem seems to be with several files, including foodx_devops_tools/pull/puffignore.py (32% coverage in
# GHA, 100% coverage locally).
# have to avoid the new manual directory in CI pipeline
TARGET: unit-test --test-dir tests/ci --check 80
needs:
- build-docker-image
container:
image: "foodxtech/foodx-devops-tools-pipeline:${{ github.sha }}"
runs-on: ubuntu-20.04
steps:
# work around github bug https://github.com/actions/checkout/issues/760
# this git config must occur BEFORE the checkout action
- run: |
git config --global --add safe.directory /__w/foodx_devops_tools/foodx_devops_tools
- uses: actions/checkout@v2
- run: ${{ env.CALL_TARGET }} ${TARGET}
build-packages:
needs:
- build-docker-image
container:
image: "foodxtech/foodx-devops-tools-pipeline:${{ github.sha }}"
runs-on: ubuntu-20.04
steps:
# work around github bug https://github.com/actions/checkout/issues/760
# this git config must occur BEFORE the checkout action
- run: |
git config --global --add safe.directory /__w/foodx_devops_tools/foodx_devops_tools
- uses: actions/checkout@v2
with:
# need all tags and branch info for release-flow utility.
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
fetch-depth: 0
- name: Build package
run: |
git config user.name github-actions
git config user.email github-actions@github.com
export THIS_VERSION=$(${{ env.VENV_BIN }}/release-flow --default-branch main)
echo ${THIS_VERSION}
${{ env.CALL_TARGET }} \
--log-enable-console \
--log-level debug \
package \
--release-id ${THIS_VERSION}
- uses: actions/upload-artifact@v2
if: failure()
with:
name: build-log
path: build_harness.log
- uses: actions/upload-artifact@v2
with:
name: distribution-package-artifacts
path: dist
install-check:
needs:
- build-packages
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: distribution-package-artifacts
path: dist
- run: |
python3 -m venv venv
ls dist
venv/bin/pip install dist/*.whl
publish-packages:
concurrency: publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
needs:
- build-packages
- build-docker-image
# don't "need" anything from install-check, but definitely don't want to publish if it fails
- install-check
container:
image: "foodxtech/foodx-devops-tools-pipeline:${{ github.sha }}"
runs-on: ubuntu-20.04
steps:
# work around github bug https://github.com/actions/checkout/issues/760
# this git config must occur BEFORE the checkout action
- run: |
git config --global --add safe.directory /__w/foodx_devops_tools/foodx_devops_tools
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/download-artifact@v2
with:
name: distribution-package-artifacts
path: dist
- if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
name: Publish package
# something seems to be broken with `build-harness publish` so use twine directly instead, for now
run: |
git --version
${{ env.VENV_BIN }}/twine upload \
--disable-progress-bar \
--non-interactive \
--password ${PYPI_TOKEN} \
--username ${{ env.PYPI_API_USER }} \
--verbose \
dist/*
- if: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }}
name: Publish package dryrun
run: |
git --version
echo ${PYPI_TOKEN} |
${CALL_TARGET} \
--log-enable-console \
--log-level debug \
publish \
--user ${{ env.PYPI_API_USER }} \
--password-file - \
--publish dryrun
- if: failure()
uses: actions/upload-artifact@v2
with:
name: publish-log
path: build_harness.log