-
Notifications
You must be signed in to change notification settings - Fork 1
334 lines (332 loc) · 9.12 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
name: CI
on:
push:
jobs:
build-wheel:
name: "🏗️ Python wheel"
strategy:
matrix:
os:
- ubuntu-latest
python:
- "3.8"
- "3.9"
runs-on: ${{ matrix.os }}
steps:
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "🧰 Install Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: |
python -m pip install --upgrade pip build twine
- name: "🏗️ Build Python wheel"
run: python -m build
- name: "🧪 Check package bundles"
run: twine check dist/*
- name: "ℹ️ List Python wheels"
if: matrix.python == '3.9' && matrix.os == 'ubuntu-latest'
run: ls -R
working-directory: dist
- name: "📤 Upload Python wheel"
uses: actions/upload-artifact@v3
if: matrix.python == '3.9' && matrix.os == 'ubuntu-latest'
with:
name: wheel
path: dist
build-image:
name: "🏗️ Docker image"
needs:
- build-wheel
runs-on: ubuntu-latest
steps:
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "🧰 Set up QEMU"
uses: docker/setup-qemu-action@v2
- name: "🧰 Set up Docker Buildx"
uses: docker/setup-buildx-action@v2
- name: "🚀 Build image"
uses: docker/build-push-action@v4
with:
context: .
push: false
code-format:
name: "🔍 Python code format"
needs:
- build-wheel
strategy:
matrix:
os:
- ubuntu-latest
python:
- "3.8"
- "3.9"
runs-on: ${{ matrix.os }}
steps:
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "🧰 Install Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
- name: "🔍 Check Python code format"
run: flake8 ir_axioms/ tests/
lint:
name: "🔍 Python Lint"
needs:
- build-wheel
strategy:
matrix:
os:
- ubuntu-latest
python:
- "3.8"
- "3.9"
runs-on: ${{ matrix.os }}
steps:
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "🧰 Install Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
- name: "🔍 Lint Python code"
run: pylint -E ir_axioms tests.unit --ignore-paths="^ir_axioms.backend|^ir_axioms.cli"
lint-backend:
name: "🔍 Python Lint backend"
needs:
- build-wheel
strategy:
matrix:
os:
- ubuntu-latest
python:
- "3.8"
- "3.9"
backend:
- pyserini
- pyterrier
runs-on: ${{ matrix.os }}
steps:
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "🧰 Install Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
pip install .[${{ matrix.backend }}]
- name: "🧰 Install Java"
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
- name: "🔍 Lint Python code"
run: pylint -E ir_axioms.backend.${{ matrix.backend }} tests.integration.${{ matrix.backend }} ${{ matrix.backend == 'pyterrier' && 'ir_axioms.cli' || '' }}
unit-tests:
name: "🧪 Python unit tests"
needs:
- build-wheel
strategy:
matrix:
os:
- ubuntu-latest
python:
- "3.8"
- "3.9"
runs-on: ${{ matrix.os }}
steps:
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "🧰 Install Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
- name: "🧪 Test Python code"
run: pytest --cov=./ --cov-report=xml ir_axioms/ tests/unit/ --ignore=ir_axioms/backend/ --ignore=ir_axioms/cli.py
- name: "📤 Upload coverage to Codecov"
uses: codecov/codecov-action@v3
if: matrix.python == '3.9' && matrix.os == 'ubuntu-latest'
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
integration-tests:
name: "🧪 Python integration tests"
needs:
- build-wheel
strategy:
matrix:
os:
- ubuntu-latest
python:
- "3.8"
- "3.9"
backend:
- pyserini
- pyterrier
runs-on: ${{ matrix.os }}
steps:
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "🧰 Install Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: "🧰 Install dependencies"
run: |
python -m pip install --upgrade pip
pip install .
pip install .[test]
pip install .[${{ matrix.backend }}]
- name: "🧰 Install Java"
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
- name: "🧪 Test Python code"
run: pytest --cov=./ --cov-report=xml tests/integration/${{ matrix.backend }}/ ${{ matrix.backend == 'pyterrier' && 'ir_axioms/cli.py' || '' }}
- name: "📤 Upload coverage to Codecov"
uses: codecov/codecov-action@v3
if: matrix.python == '3.9' && matrix.os == 'ubuntu-latest'
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
publish-package:
name: "🚀 Publish Python wheels"
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs:
- build-wheel
- build-image
- code-format
- lint
- lint-backend
- unit-tests
- integration-tests
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "📥 Download Python wheels"
uses: actions/download-artifact@v3
with:
name: wheel
path: dist
- name: "ℹ️ List Python wheels"
run: ls -R
working-directory: dist
- name: "🚀 Publish Python wheels"
uses: pypa/gh-action-pypi-publish@release/v1
push-image:
name: "🚀 Publish Docker image"
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
permissions:
packages: write
needs:
- build-wheel
- build-image
- code-format
- lint
- lint-backend
- unit-tests
- integration-tests
runs-on: ubuntu-latest
steps:
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "🧰 Set up QEMU"
uses: docker/setup-qemu-action@v2
- name: "🧰 Set up Docker Buildx"
uses: docker/setup-buildx-action@v2
- name: "🔑 Login to Docker Hub"
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "🔑 Login to GitHub Packages"
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "ℹ️ Extract image metadata"
id: meta
uses: docker/metadata-action@v4
with:
images: |
webis/ir_axioms
ghcr.io/${{ github.repository }}
- name: "🚀 Build and push image"
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
github-release:
name: "🚀 Create GitHub release"
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs:
- build-wheel
- build-image
- code-format
- lint
- lint-backend
- unit-tests
- integration-tests
runs-on: ubuntu-latest
steps:
- name: "📥 Check-out"
uses: actions/checkout@v3
- name: "📥 Download Python wheels"
uses: actions/download-artifact@v3
with:
name: wheel
path: dist
- name: "ℹ️ List Python wheels"
run: ls -R
working-directory: dist
- name: "🚀 Create GitHub release"
uses: softprops/action-gh-release@v1
with:
name: Release ${{ github.ref_name }}
files: dist/*
fail_on_unmatched_files: true
draft: false
prerelease: false
generate_release_notes: true