-
Notifications
You must be signed in to change notification settings - Fork 101
336 lines (334 loc) · 14.9 KB
/
build.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
name: Linux/Mac build
on:
push:
paths:
- '**'
- '!*'
- '*.py'
- '!doc/**'
- '!.github/**'
- '.github/workflows/build.yml'
pull_request:
paths-ignore:
- 'doc/**'
schedule:
- cron: '0 20 * * 2'
jobs:
build:
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_actionAngle.py
REQUIRES_PYNBODY: false
REQUIRES_ASTROPY: false
REQUIRES_ASTROQUERY: false
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_sphericaldf.py
REQUIRES_PYNBODY: false
REQUIRES_ASTROPY: false
REQUIRES_ASTROQUERY: false
REQUIRES_NUMBA: false
REQUIRES_JAX: true
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_actionAngleTorus.py tests/test_conversion.py tests/test_galpypaper.py tests/test_import.py tests/test_interp_potential.py tests/test_kuzminkutuzov.py tests/test_util.py
REQUIRES_PYNBODY: false
REQUIRES_ASTROPY: false
REQUIRES_ASTROQUERY: false
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_SpiralArmsPotential.py tests/test_potential.py tests/test_scf.py tests/test_snapshotpotential.py
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: false
REQUIRES_ASTROQUERY: false
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_quantity.py tests/test_coords.py
REQUIRES_PYNBODY: false
# needs to be separate for different config
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: false
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_orbit.py -k test_energy_jacobi_conservation
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: true
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_orbit.py tests/test_orbits.py -k 'not test_energy_jacobi_conservation'
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: true
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_evolveddiskdf.py
REQUIRES_PYNBODY: false
REQUIRES_ASTROPY: false
REQUIRES_ASTROQUERY: false
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_jeans.py tests/test_dynamfric.py
REQUIRES_PYNBODY: false
REQUIRES_ASTROPY: false
REQUIRES_ASTROQUERY: false
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_qdf.py tests/test_pv2qdf.py tests/test_streamgapdf_impulse.py tests/test_noninertial.py
REQUIRES_PYNBODY: false
REQUIRES_ASTROPY: false
REQUIRES_ASTROQUERY: false
REQUIRES_NUMBA: true
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_streamgapdf.py
REQUIRES_PYNBODY: false
REQUIRES_ASTROPY: false
REQUIRES_ASTROQUERY: false
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_diskdf.py
REQUIRES_PYNBODY: false
REQUIRES_ASTROPY: false
REQUIRES_ASTROQUERY: false
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.12"
TEST_FILES: tests/test_streamdf.py tests/test_streamspraydf.py
REQUIRES_PYNBODY: false
REQUIRES_ASTROPY: false
REQUIRES_ASTROQUERY: false
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.11"
TEST_FILES: tests/test_orbit.py -k test_energy_jacobi_conservation
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: true
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.11"
TEST_FILES: tests/test_orbit.py tests/test_orbits.py -k 'not test_energy_jacobi_conservation'
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: true
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.10"
TEST_FILES: tests/test_orbit.py -k test_energy_jacobi_conservation
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: true
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: "3.10"
TEST_FILES: tests/test_orbit.py tests/test_orbits.py -k 'not test_energy_jacobi_conservation'
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: true
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: 3.9
TEST_FILES: tests/test_orbit.py -k test_energy_jacobi_conservation
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: true
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: 3.9
TEST_FILES: tests/test_orbit.py tests/test_orbits.py -k 'not test_energy_jacobi_conservation'
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: true
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: 3.8
TEST_FILES: tests/test_orbit.py -k test_energy_jacobi_conservation
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: true
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: ubuntu-latest
python-version: 3.8
TEST_FILES: tests/test_orbit.py tests/test_orbits.py -k 'not test_energy_jacobi_conservation'
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: true
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: macos-14
python-version: "3.12"
TEST_FILES: tests/test_orbit.py -k test_energy_jacobi_conservation
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: true
REQUIRES_NUMBA: false
REQUIRES_JAX: false
- os: macos-14
python-version: "3.12"
TEST_FILES: tests/test_orbit.py tests/test_orbits.py -k 'not test_energy_jacobi_conservation'
REQUIRES_PYNBODY: true
REQUIRES_ASTROPY: true
REQUIRES_ASTROQUERY: true
REQUIRES_NUMBA: false
REQUIRES_JAX: false
env:
PYTHON_COVREPORTS_VERSION: "3.12"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install lcov
if: matrix.os == 'ubuntu-latest'
run: |
wget https://github.com/linux-test-project/lcov/releases/download/v1.15/lcov-1.15.tar.gz
tar xf lcov-1.15.tar.gz
sudo make -C lcov-1.15/ install
- name: Install the GSL
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install libgsl-dev
- name: Install the GSL and OpenMP
if: ${{ startsWith( matrix.os , 'macos' ) }}
run: |
brew install gsl libomp
brew info libomp
echo "CFLAGS=-I$(brew --prefix)/include -I$(brew --prefix)/opt/libomp/include" >> $GITHUB_ENV
echo "CPPFLAGS=-I$(brew --prefix)/include -I$(brew --prefix)/opt/libomp/include" >> $GITHUB_ENV
echo "LDFLAGS=-L$(brew --prefix)/lib -L$(brew --prefix)/opt/libomp/lib" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$(brew --prefix)/lib:$(brew --prefix)/opt/libomp/lib" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('.github/workflows/build.yml') }}-${{ matrix.REQUIRES_PYNBODY }}-${{ matrix.REQUIRES_ASTROPY }}-${{ matrix.REQUIRES_ASTROQUERY }}-${{ matrix.REQUIRES_NUMBA }}-${{ matrix.REQUIRES_JAX }}
- name: Install Python dependencies
run: |
pip install --upgrade --upgrade-strategy eager numpy scipy matplotlib numexpr setuptools cython pytest tqdm
- name: Install pynbody
if: ${{ matrix.REQUIRES_PYNBODY }}
run: |
pip install --upgrade --upgrade-strategy eager h5py pandas pytz posix_ipc
pip install --upgrade --upgrade-strategy eager wheel
pip install --upgrade --upgrade-strategy eager --pre --no-deps pynbody
- name: Install astropy
if: ${{ matrix.REQUIRES_ASTROPY }}
run: pip install astropy pyerfa
- name: Install astroquery
if: ${{ matrix.REQUIRES_ASTROQUERY }}
run: pip install astroquery
- name: Install numba
if: ${{ matrix.REQUIRES_NUMBA }}
run: |
pip install numba
# numba may force install an older version of setuptools,
# but it isn't actually a *runtime* requirement numba/numba#8366
pip install --upgrade --force-reinstall setuptools
- name: Install JAX
if: ${{ matrix.REQUIRES_JAX }}
run: pip install jax jaxlib
- name: Install torus code
env:
TEST_FILES: ${{ matrix.TEST_FILES }}
run: |
if [[ $TEST_FILES != 'tests/test_evolveddiskdf.py' ]]; then
git clone https://github.com/jobovy/Torus.git galpy/actionAngle/actionAngleTorus_c_ext/torus
cd galpy/actionAngle/actionAngleTorus_c_ext/torus
git checkout galpy
cd -
fi
- name: Install package
if: matrix.os == 'ubuntu-latest'
run: |
python setup.py build_ext --no-openmp --coverage --single_ext --inplace
python setup.py develop --single_ext
- name: Setup env for Mac wheel build/install
if: ${{ startsWith( matrix.os , 'macos' ) }}
run: |
echo "CIBW_BUILD=cp$(sed 's/\.//g' <<< ${{ matrix.python-version }})-*" >> $GITHUB_ENV
- name: Build wheel for Mac install
if: ${{ startsWith( matrix.os , 'macos' ) }}
env:
CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=10.13"
run: |
python -m pip install cibuildwheel
python -m cibuildwheel --output-dir wheelhouse
- name: Install package (Mac)
if: ${{ startsWith( matrix.os , 'macos' ) }}
run: |
python -m pip install -v `ls ./wheelhouse/*.whl`
- name: Special config
env:
TEST_FILES: ${{ matrix.TEST_FILES }}
run: |
if [[ $TEST_FILES == 'tests/test_evolveddiskdf.py' ]]; then echo -e '[normalization]' > $HOME/.galpyrc && echo -e 'ro = 8.' >> $HOME/.galpyrc && echo -e 'vo = 220.' >> $HOME/.galpyrc; fi
if [[ $TEST_FILES == 'tests/test_diskdf.py' ]]; then echo -e '[normalization]' > $HOME/.galpyrc && echo -e 'ro = 8.' >> $HOME/.galpyrc && echo -e '[astropy]' >> $HOME/.galpyrc && echo -e 'astropy-units = False' >> $HOME/.galpyrc && echo -e '[plot]' >> $HOME/.galpyrc && echo -e 'seaborn-bovy-defaults = True' >> $HOME/.galpyrc && echo -e '[warnings]' >> $HOME/.galpyrc && echo -e 'verbose = True' >> $HOME/.galpyrc; fi
- name: Print debug info
env:
REQUIRES_ASTROPY : ${{ matrix.REQUIRES_ASTROPY }}
REQUIRES_ASTROQUERY : ${{ matrix.REQUIRES_ASTROQUERY }}
REQUIRES_PYNBODY : ${{ matrix.REQUIRES_PYNBODY }}
run: |
python -c "import numpy; print('numpy: {}'.format(numpy.__version__))"
python -c "import scipy; print('scipy: {}'.format(scipy.__version__))"
python -c "import matplotlib; print('matplotlib: {}'.format(matplotlib.__version__))"
if $REQUIRES_ASTROPY; then python -c "import astropy; print('astropy: {}'.format(astropy.__version__))"; fi
if $REQUIRES_ASTROQUERY; then python -c "import astroquery; print('astroquery: {}'.format(astroquery.__version__))"; fi
if $REQUIRES_PYNBODY; then python -c "import pynbody; print('pynbody: {}'.format(pynbody.__version__))"; fi
- name: Test with pytest
env:
TEST_FILES: ${{ matrix.TEST_FILES }}
REQUIRES_ASTROPY : ${{ matrix.REQUIRES_ASTROPY }}
run: |
pip install coverage
pip install pytest-cov
# Turn astropy deprecation warnings into errors as well if astropy
if $REQUIRES_ASTROPY; then export PYTEST_ADDOPTS="-W error::astropy.utils.exceptions.AstropyDeprecationWarning"; else export PYTEST_ADDOPTS=""; fi
export TQDM_DEPRECATION="-W ignore:\"datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version.\":DeprecationWarning -W ignore:\"datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC\":DeprecationWarning"
# eval necessary for -k 'not ...' in TEST_FILES
eval "pytest -W error::DeprecationWarning -W error::FutureWarning $PYTEST_ADDOPTS $TQDM_DEPRECATION -v $TEST_FILES --cov galpy --cov-config .coveragerc --disable-pytest-warnings --durations=0 --cov-report=term --cov-report=xml"
- name: Generate code coverage
if: ${{ matrix.python-version == env.PYTHON_COVREPORTS_VERSION && matrix.os == 'ubuntu-latest' }}
run: |
lcov --capture --base-directory . --directory build/temp.linux-x86_64-`python -c "import sys; print(sys.implementation.cache_tag)"`/galpy/ --no-external --output-file coverage_full.info
lcov --remove coverage_full.info 'galpy/actionAngle/actionAngleTorus_c_ext/torus/*' -o coverage.info
- name: Upload coverage reports to codecov
if: ${{ matrix.python-version == env.PYTHON_COVREPORTS_VERSION && matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}