Skip to content

Linux/Mac build

Linux/Mac build #1467

Workflow file for this run

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-12
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-12
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: matrix.os == 'macos-12'
run: |
brew install gsl libomp
brew info libomp
echo "CFLAGS=-I$(brew --prefix)/include -I/usr/local/opt/libomp/include" >> $GITHUB_ENV
echo "CPPFLAGS=-I$(brew --prefix)/include -I/usr/local/opt/libomp/include" >> $GITHUB_ENV
echo "LDFLAGS=-L$(brew --prefix)/lib -L/usr/local/opt/libomp/lib" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$(brew --prefix)/lib:/usr/local/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
pip install --upgrade --upgrade-strategy eager wheel
pip install --upgrade --upgrade-strategy eager 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: Install package
if: matrix.os == 'macos-12'
run: |
python -m pip install -v .
- 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 }}