-
Notifications
You must be signed in to change notification settings - Fork 0
379 lines (330 loc) · 12.5 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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
name: Test and release
on:
push:
jobs:
test:
name: Run unit tests on the ontology
if: "!contains(github.event.head_commit.message, '[Skip CI]')"
runs-on: ubuntu-latest
steps:
# Check out the repository
- name: Checkout repo
uses: actions/checkout@master
with:
fetch-depth: 1
# Install the requirements for the tests
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Setup pip cache
uses: actions/cache@v2
with:
path: /opt/hostedtoolcache/Python
key: ${{ runner.os }}-pip-${{ hashFiles('libkisao/python/requirements.txt') }}-${{ hashFiles('libkisao/python/tests/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pip and setuptools
run: |
python -m pip install --upgrade pip==23.0.0
python -m pip install --upgrade pip==23.0.0
- name: Install the Python KiSAO package
working-directory: libkisao/python
run: |
cp ../../kisao.owl kisao/
python -m pip install .[all]
# Lint the package
- name: Install flake8
run: python -m pip install flake8
- name: Lint the package
working-directory: libkisao/python
run: python -m flake8
# Run the tests
- name: Install the requirements for the tests
working-directory: libkisao/python
run: |
python -m pip install pytest pytest-cov
python -m pip install -r tests/requirements.txt
- name: Run the tests
working-directory: libkisao/python
run: python -m pytest tests/ --cov
# Compile documentation
- name: Install the requirements for compiling the documentation
working-directory: libkisao/python
run: python -m pip install -r docs-src/requirements.txt
- name: Compile the documentation
working-directory: libkisao/python
run: |
sphinx-apidoc . setup.py --output-dir docs-src/source --force --module-first --no-toc
mkdir -p docs-src/_static
sphinx-build docs-src docs
- name: Compile a report of the substitutability among algorithms
working-directory: libkisao/python
shell: python
run: |
import kisao.utils
import os
report = kisao.utils.get_algorithm_substitution_matrix()
report.to_csv(os.path.join('docs', 'algorithm-substitutability.csv'))
- name: Upload the coverage report to Codecov
if: false
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
file: ./libkisao/python/coverage.xml
getMainBranchHeadRevision:
name: Get the head revision of the main branch
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
outputs:
mainBranchHeadRevision: ${{ steps.get-main-branch.outputs.mainBranchHeadRevision }}
steps:
- name: Clone repository
run: |
git clone https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} .
- id: get-main-branch
name: Determine main branch
run: |
mainBranch=$(git symbolic-ref refs/remotes/origin/HEAD | cut -d '/' -f 4)
mainBranchHeadRevision=$(git rev-parse refs/remotes/origin/${mainBranch})
echo "mainBranchHeadRevision=$mainBranchHeadRevision" >> $GITHUB_OUTPUT
determineIfReleaseNeeded:
name: Determine if the package should be released
needs:
- getMainBranchHeadRevision
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
outputs:
release: ${{ steps.determine-if-release-needed.outputs.release }}
steps:
# Check out the repository
- name: Checkout repo
uses: actions/checkout@master
with:
fetch-depth: 1
- id: determine-if-release-needed
name: Determine if a release should be made
run: |
release="0"
if [[ "${{ github.ref }}" =~ ^refs/tags/ ]]; then
echo "First check passed"
tag_hash=$(git rev-parse "${{ github.ref }}")
echo "tag_hash: $tag_hash"
if [ "$tag_hash" == "${{ needs.getMainBranchHeadRevision.outputs.mainBranchHeadRevision }}" ]; then
echo "Second check passed"
release="1"
fi
fi
echo "release=$release" >> $GITHUB_OUTPUT
echo "release=$release"
commitCompiledDocumentation:
name: Commit and push compiled documentation to GitHub
needs:
- test
- determineIfReleaseNeeded
if: startsWith(github.ref, 'refs/tags/') && needs.determineIfReleaseNeeded.outputs.release == '1'
runs-on: ubuntu-latest
steps:
# Check out the repository
- name: Checkout repo
uses: actions/checkout@master
with:
fetch-depth: 1
# ref: dev
# token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
# Install the requirements for the tests
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Setup pip cache
uses: actions/cache@v2
with:
path: /opt/hostedtoolcache/Python
key: ${{ runner.os }}-pip-${{ hashFiles('libkisao/python/requirements.txt') }}-${{ hashFiles('libkisao/python/tests/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pip and setuptools
run: |
python -m pip install --upgrade pip==23.0.0
python -m pip install --upgrade pip==23.0.0
- name: Install the Python KiSAO package
working-directory: libkisao/python
run: |
cp ../../kisao.owl kisao/
python -m pip install .[all]
- name: Install the requirements for compiling the documentation
working-directory: libkisao/python
run: python -m pip install -r docs-src/requirements.txt
- name: Compile the documentation
working-directory: libkisao/python
run: |
sphinx-apidoc . setup.py --output-dir docs-src/source --force --module-first --no-toc
mkdir -p docs-src/_static
sphinx-build docs-src docs
- name: Compile a report of the substitutability among algorithms
working-directory: libkisao/python
shell: python
run: |
import kisao.utils
import os
report = kisao.utils.get_algorithm_substitution_matrix()
report.to_csv(os.path.join('docs', 'algorithm-substitutability.csv'))
# If new tag, commit and push documentation
- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "SED-ML bot"
git config pull.rebase false
- id: commit-docs
name: Commit the compiled documentation
working-directory: libkisao/python
run: |
git stash
git pull
set +e
git stash pop
git add docs
git commit -m "Updated compiled documentation [Skip CI]"
git checkout .
git clean -f -d
if [[ $? = 0 ]]; then
docsChanged=1
else
docsChanged=0
fi
echo "docsChanged=$docsChanged" >> $GITHUB_OUTPUT
- name: Push the compiled documentation
if: startsWith(github.ref, 'refs/tags/') && steps.commit-docs.outputs.docsChanged == '1'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
branch: ${{ steps.get-main-branch.outputs.mainBranch }}
createGitHubRelease:
name: Create GitHub release
needs:
- test
- determineIfReleaseNeeded
if: startsWith(github.ref, 'refs/tags/') && needs.determineIfReleaseNeeded.outputs.release == '1'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@master
with:
fetch-depth: 1
# ref: dev
# token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
- name: Merge dev branch into deploy branch
uses: devmasx/[email protected]
with:
type: now
target_branch: deploy
github_token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
- id: get-version
name: Get version number
env:
TAG: ${{ github.ref }}
run: |
version="${TAG/refs\/tags\//}"
echo "version=$version" >> $GITHUB_OUTPUT
- name: Create GitHub release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.ADMIN_GITHUB_TOKEN }}"
draft: false
prerelease: false
automatic_release_tag: ${{ steps.get-version.outputs.version }}
releaseToBioPortal:
name: Release version to BioPortal
needs:
- test
- determineIfReleaseNeeded
if: startsWith(github.ref, 'refs/tags/') && needs.determineIfReleaseNeeded.outputs.release == '1'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@master
- name: Install jq
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends jq moreutils
- name: Prepare BioPortal submission
env:
TAG: ${{ github.ref }}
run: |
version="${TAG/refs\/tags\//}"
released=$(date --iso-8601=second)
cp .github/workflows/BioPortal-submission.json .github/workflows/BioPortal-submission-version.json
jq \
".pullLocation = \"https://raw.githubusercontent.com/SED-ML/KiSAO/${version}/kisao.owl\"" \
.github/workflows/BioPortal-submission-version.json | sponge .github/workflows/BioPortal-submission-version.json
jq \
".version = \"${version}\"" \
.github/workflows/BioPortal-submission-version.json | sponge .github/workflows/BioPortal-submission-version.json
jq \
".released = \"${released}\"" \
.github/workflows/BioPortal-submission-version.json | sponge .github/workflows/BioPortal-submission-version.json
- name: Submit to BioPortal
run: |
curl -X POST \
-H "Authorization: apikey token=${{ secrets.BIOPORTAL_API_KEY }}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @.github/workflows/BioPortal-submission-version.json \
http://data.bioontology.org/ontologies/KISAO/submissions
echo
releaseToPyPI:
name: Release version to PyPI
needs:
- test
- determineIfReleaseNeeded
if: startsWith(github.ref, 'refs/tags/') && needs.determineIfReleaseNeeded.outputs.release == '1'
runs-on: ubuntu-latest
steps:
# Check out the repository
- name: Checkout repo
uses: actions/checkout@master
with:
fetch-depth: 1
# Install the requirements for the tests
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Setup pip cache
uses: actions/cache@v2
with:
path: /opt/hostedtoolcache/Python
key: ${{ runner.os }}-pip-${{ hashFiles('libkisao/python/requirements.txt') }}-${{ hashFiles('libkisao/python/tests/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pip
run: |
python -m pip install --upgrade pip==23.0.0
python -m pip install --upgrade pip==23.0.0
# Create PyPI release
- name: Create PyPI release
working-directory: libkisao/python
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
# Install pandoc
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends wget
wget "https://github.com/jgm/pandoc/releases/download/3.1.3/pandoc-3.1.3-1-amd64.deb" -O /tmp/pandoc.deb
sudo dpkg -i /tmp/pandoc.deb
rm /tmp/pandoc.deb
# Copy OWL file and LICENSE so it can be bundled into the Python package
cp ../../kisao.owl kisao/
cp ../../LICENSE .
# Convert README to .rst format
pandoc --from=gfm --output=README.rst --to=rst README.md
# Install twine
python -m pip install wheel twine
# Create packages to upload to PyPI
python setup.py sdist
python setup.py bdist_wheel
# Upload packages to PyPI
twine upload dist/*