-
Notifications
You must be signed in to change notification settings - Fork 81
361 lines (349 loc) · 12.9 KB
/
monty.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
name: Monty
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build_sphinx_monty:
name: build-sphinx-monty
runs-on:
group: tbp.monty
labels: tbp-linux-x64-ubuntu2204-2core
needs:
- check_dependencies_monty # Don't run if dependency check fails
- check_license_monty # Don't run if license check fails
- check_style_monty # Don't run if style check fails
- check_types_monty # Don't run if type check fails
- install_monty
- should_run_monty
steps:
- name: Restore cache
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/cache/restore@v4
with:
path: |
~/miniconda
key: ${{ needs.install_monty.outputs.conda_env_cache_key_sha }}
- name: Checkout tbp.monty
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
path: tbp.monty
- name: Build API docs
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
working-directory: tbp.monty
run: |
export PATH="$HOME/miniconda/bin:$PATH"
source activate tbp.monty
pip install -e .[generate_api_docs_tool]
cd tools/generate_api_docs
make apidoc html
- name: Store API docs artifact
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/upload-artifact@v4
with:
name: sphinx-html-${{ github.sha }}
path: tbp.monty/tools/generate_api_docs/build/html
build_wheel_monty:
name: build-wheel-monty
runs-on:
group: tbp.monty
labels: tbp-linux-x64-ubuntu2204-2core
needs:
- install_monty # Needed for the cache key
- should_run_monty
- test_monty
steps:
- name: Restore cache
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/cache/restore@v4
with:
path: |
~/miniconda
key: ${{ needs.install_monty.outputs.conda_env_cache_key_sha }}
- name: Checkout tbp.monty
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/checkout@v4
with:
lfs: true
path: tbp.monty
- name: Build wheel
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
working-directory: tbp.monty
run: |
export PATH="$HOME/miniconda/bin:$PATH"
source activate tbp.monty
pip install -e .[build]
python -m build
- name: Store wheel
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/upload-artifact@v4
with:
name: dist
path: tbp.monty/dist
check_dependencies_monty:
name: check-dependencies-monty
runs-on:
group: tbp.monty
labels: tbp-linux-x64-ubuntu2204-2core
needs:
- install_monty
- should_run_monty
steps:
- name: Restore cache
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/cache/restore@v4
with:
path: |
~/miniconda
key: ${{ needs.install_monty.outputs.conda_env_cache_key_sha }}
- name: Checkout tbp.monty
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/checkout@v4
with:
lfs: true
path: tbp.monty
- name: Check dependencies
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
working-directory: tbp.monty
run: |
export PATH="$HOME/miniconda/bin:$PATH"
source activate tbp.monty
deptry benchmarks src tests
check_license_monty:
name: check-license-monty
runs-on: ubuntu-latest
needs: should_run_monty
steps:
- name: Checkout tbp.monty
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/checkout@v4
with:
lfs: true
path: tbp.monty
- name: Check license
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
working-directory: tbp.monty
run: |
FILES=$(grep -l -r ' GNU \| MPL \| Mozilla ' * ) || true
if [ -n "$FILES" ]; then
echo "Found Copyleft Licensed files: $FILES"
exit 1
fi
check_style_monty:
name: check-style-monty
runs-on:
group: tbp.monty
labels: tbp-linux-x64-ubuntu2204-2core
needs:
- install_monty
- should_run_monty
steps:
- name: Restore cache
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/cache/restore@v4
with:
path: |
~/miniconda
key: ${{ needs.install_monty.outputs.conda_env_cache_key_sha }}
- name: Checkout tbp.monty
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/checkout@v4
with:
lfs: true
path: tbp.monty
- name: Check style
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
working-directory: tbp.monty
run: |
export PATH="$HOME/miniconda/bin:$PATH"
source activate tbp.monty
mkdir -p test_results/ruff
ruff check --verbose src tests benchmarks
check_types_monty:
name: check-types-monty
runs-on:
group: tbp.monty
labels: tbp-linux-x64-ubuntu2204-2core
needs:
- install_monty
- should_run_monty
steps:
- name: Restore cache
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/cache/restore@v4
with:
path: |
~/miniconda
key: ${{ needs.install_monty.outputs.conda_env_cache_key_sha }}
- name: Checkout tbp.monty
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/checkout@v4
with:
lfs: true
path: tbp.monty
- name: Check types
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
working-directory: tbp.monty
run: |
export PATH="$HOME/miniconda/bin:$PATH"
source activate tbp.monty
mkdir -p test_results/mypy
mypy --warn-unused-configs src tests benchmarks
install_monty:
name: install-monty
runs-on:
group: tbp.monty
labels: tbp-linux-x64-ubuntu2204-2core
needs:
- check_license_monty # Don't run if license check fails
- should_run_monty
outputs:
conda_env_cache_key_sha: ${{ steps.generate_cache_key.outputs.conda_env_cache_key_sha }}
steps:
- name: Checkout tbp.monty
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/checkout@v4
with:
lfs: true
path: tbp.monty
- name: Generate cache key
id: generate_cache_key
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
run: |
mkdir -p ~/tbp
ln -s $GITHUB_WORKSPACE/tbp.monty ~/tbp/tbp.monty
shasum -a 256 ~/tbp/tbp.monty/environment_arm64.yml | awk '{print $1}' > ~/tbp/environment_arm64.sha
shasum -a 256 ~/tbp/tbp.monty/environment.yml | awk '{print $1}' > ~/tbp/environment.sha
shasum -a 256 ~/tbp/tbp.monty/pyproject.toml | awk '{print $1}' > ~/tbp/pyproject.toml.sha
echo "monty-${RUNNER_OS}-$(cat ~/tbp/environment_arm64.sha)-$(cat ~/tbp/environment.sha)-$(cat ~/tbp/pyproject.toml.sha)" > ~/tbp/conda_env_cache_key.txt
echo "conda_env_cache_key_sha=$(cat ~/tbp/conda_env_cache_key.txt | shasum -a 256 | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Set up Python 3.8
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Restore cache
id: restore_cache
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/cache/restore@v4
with:
path: |
~/miniconda
key: ${{ steps.generate_cache_key.outputs.conda_env_cache_key_sha }}
lookup-only: true
- name: Install miniconda
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' && steps.restore_cache.outputs.cache-hit != 'true' }}
run: |
if [ ! -d ~/miniconda ]
then
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p ~/miniconda
rm ~/miniconda.sh
fi
- name: Create conda environment
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' && steps.restore_cache.outputs.cache-hit != 'true' }}
working-directory: tbp.monty
run: |
export PATH="$HOME/miniconda/bin:$PATH"
(conda env list | grep tbp.monty) && conda remove --name tbp.monty --all --yes || true
conda env create
source activate tbp.monty
pip install -e .[dev]
pip list
conda list
- name: Save cache
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' && steps.restore_cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: |
~/miniconda
key: ${{ steps.restore_cache.outputs.cache-primary-key }}
should_run_monty:
name: should-run-monty
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'thousandbrainsproject' }}
outputs:
should_run_monty: ${{ steps.should_run_monty.outputs.should_run_monty }}
steps:
- name: Checkout tbp.monty
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
path: tbp.monty
- name: Should Run Monty
id: should_run_monty
uses: ./tbp.monty/.github/actions/should_run_monty
with:
git_base_ref: ${{ github.base_ref }}
git_sha: ${{ github.sha }}
github_event_name: ${{ github.event_name }}
working_directory: tbp.monty
test_monty:
name: test-monty
runs-on:
group: tbp.monty
labels: tbp-linux-x64-ubuntu2204-8core
timeout-minutes: 120
needs:
- check_dependencies_monty # Don't run if dependency check fails
- check_style_monty # Don't run if style check fails
- check_types_monty # Don't run if type check fails
- install_monty
- should_run_monty
steps:
- name: Restore cache
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/cache/restore@v4
with:
path: |
~/miniconda
key: ${{ needs.install_monty.outputs.conda_env_cache_key_sha }}
- name: Checkout tbp.monty
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/checkout@v4
with:
lfs: true
path: tbp.monty
- name: Install xvfb and mesa
# Use X11 framebuffer and mesa opengl libraries for testing.
# Not ideal but better than no tests.
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
run: |
sudo apt update -y
sudo apt install -y --no-install-recommends xvfb libegl1-mesa-dev
- name: Run python tests
# Using 8 CPUs corresponding to the large GithHub-hosted runner available in the "tbp" runner group.
# See: https://docs.github.com/en/actions/using-github-hosted-runners/using-larger-runners/about-larger-runners#specifications-for-general-larger-runners
#
# NOTE: LD_PRELOAD is needed to provide what is discussed in https://stackoverflow.com/questions/71010343/cannot-load-swrast-and-iris-drivers-in-fedora-35/72200748#72200748
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
working-directory: tbp.monty
run: |
export PATH="$HOME/miniconda/bin:$PATH"
source activate tbp.monty
set -e
mkdir -p test_results/pytest
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
xvfb-run pytest -n 8 --cov --cov-report html --cov-report term --junitxml=test_results/pytest/results.xml --verbose
- name: Store test results
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/upload-artifact@v4
with:
name: test_results
path: tbp.monty/test_results/pytest
- name: Store coverage
if: ${{ needs.should_run_monty.outputs.should_run_monty == 'true' }}
uses: actions/upload-artifact@v4
with:
name: test_coverage
path: tbp.monty/htmlcov