-
Notifications
You must be signed in to change notification settings - Fork 6
204 lines (175 loc) · 6.42 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
name: Continuous integration
on:
push:
pull_request:
jobs:
getVersionNumber:
name: Get version number
if: "startsWith(github.ref, 'refs/tags/') && !contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'allcontributors'"
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get-version-number.outputs.version }}
steps:
- id: get-version-number
name: Get version number
env:
TAG: ${{ github.ref }}
run: |
version="${TAG/refs\/tags\//}"
echo "version=$version" >> $GITHUB_OUTPUT
build:
name: Lint, test, and compile docs (python ${{ matrix.python-version }})
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'allcontributors'"
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [ "3.10", "3.11" ]
fail-fast: false
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Java # for pyNeuroML
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '15'
- name: Install Perl # for BioNetGen
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends perl
- name: Install XPP
run: |
sudo apt-get install -y --no-install-recommends wget make gcc libx11-dev libc6-dev xppaut
- name: Install Singularity # to validate that the Docker image can be converted into a Singularity image
uses: eWaterCycle/setup-singularity@v5
with:
singularity-version: 3.7.1
# install package
- name: Set up the environment
uses: ./.github/actions/setup-poetry-env
with:
python-version: ${{ matrix.python-version }}
- name: Lint the package
run: poetry run python -m flake8
- name: Run the tests
uses: GabrielBB/xvfb-action@v1
env:
MPLBACKEND: PDF
# BIOSIMULATORS_API_ENDPOINT: https://api.biosimulators.dev/ # uncomment to execute tests with the dev deployment
with:
run: poetry run python -m pytest tests/ --cov=./biosimulators_utils --cov-report=xml
- name: Upload the coverage report to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
file: ./coverage.xml
# compile documentation
- name: Install the requirements for compiling the documentation
run: poetry install --with docs
- name: Compile the documentation
run: |
poetry run sphinx-apidoc . setup.py --output-dir docs-src/source --force --module-first --no-toc
mkdir -p docs-src/_static
poetry run sphinx-build docs-src docs
release:
name: Release a new version
needs: [getVersionNumber, build]
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: dev
- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "biosimulatorsdaemon"
git config pull.rebase false
- name: Set up the environment
uses: ./.github/actions/setup-poetry-env
with:
python-version: ${{ matrix.python-version }}
# update Identifiers.org namespaces
- name: Update Identifiers.org namespaces
run: poetry run python -c "from biosimulators_utils.utils.identifiers_org import get_identifiers_org_namespaces; get_identifiers_org_namespaces(reload=True);"
- name: Test the updated Identifiers.org namespaces
uses: GabrielBB/xvfb-action@v1
env:
MPLBACKEND: PDF
with:
run: poetry run python -m pytest tests/utils/test_identifiers_org_utils.py
- id: commit-identifiers-namespaces
name: Commit the Identifiers.org namespaces
run: |
git stash
git pull
set +e
git stash pop
git add biosimulators_utils/utils/identifiers_org.json
git commit -m "chore: Updated Identifiers.org namespaces [skip ci]"
if [[ $? = 0 ]]; then
changed=1
else
changed=0
fi
echo "changed=$changed" >> $GITHUB_OUTPUT
# compile and push documentation
- name: Install the requirements for compiling the documentation
run: poetry install --with docs
- name: Compile the documentation
run: |
poetry run sphinx-apidoc . setup.py --output-dir docs-src/source --force --module-first --no-toc
mkdir -p docs-src/_static
poetry run sphinx-build docs-src docs
- id: commit-docs
name: Commit the compiled documentation
run: |
git stash
git pull
set +e
git stash pop
git add docs
git commit -m "chore: Updated compiled documentation [skip ci]"
if [[ $? = 0 ]]; then
changed=1
else
changed=0
fi
echo "changed=$changed" >> $GITHUB_OUTPUT
- name: Push the compiled documentation
if: steps.commit-identifiers-namespaces.outputs.changed == '1' || steps.commit-docs.outputs.changed == '1'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: dev
- name: print the release version
run: echo "release=${{ needs.getVersionNumber.outputs.version }}"
# Create GitHub release
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.getVersionNumber.outputs.version }}
release_name: Release ${{ needs.getVersionNumber.outputs.version }}
# Create PyPI release
- name: Create packages to upload to PyPI
run: |
poetry build
- name: Upload packages to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: |
poetry publish --no-interaction --username __token__ --password $POETRY_PYPI_TOKEN_PYPI
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: false