https://github.com/rmjarvis/TreeCorr
Raw File
Tip revision: ff703f4c769506b102d98280c34ad8f53fe78189 authored by Mike Jarvis on 12 March 2024, 12:58:12 UTC
build docs
Tip revision: ff703f4
.travis.yml
branches:
    only:
        - main
        - /^releases\/.*/

language: python

python:
    - 2.7
    - 3.5
    - 3.6

compiler:
    - g++

matrix:
    # cf. https://blog.travis-ci.com/2019-08-07-extensive-python-testing-on-travis-ci
    include:
        # Add 3.7 build by hand.  This is the officially supported method for now.
        - python: 3.7
          dist: xenial
          name: "Python: 3.7"

        # Note: All the rest are technically allowed to fail.  This is mostly so the
        # Travis runs can finish faster, since they often only do 4 at a time.
        # But we should periodically check them and try to make sure they all work.

        # Add a linux build with clang
        - python: 3.6
          env:
            - COMPILER=clang
            - CC=clang
            - CXX=clang++
            - LD_LIBRARY_PATH=/usr/local/clang/lib:$LD_LIBRARY_PATH
          name: Linux clang (Python 3.6)

        # Add a few macos builds
        # Here, the python version is set by the xcode version.
        - os: osx
          osx_image: xcode9.3  # Has python 2.7.14_2
          language: shell  # language: python is an error on macos
          env:
            - TRAVIS_PYTHON_VERSION=2.7
            # Note: Use --user to supersede existing versions rather than sudo pip -U ...
            #       since existing versions of some packages (e.g. numpy) live in /System/
            #       directory where delete operations are forbidden.
            - __USER=--user
            - PATH=/Users/travis/Library/Python/2.7/bin:$PATH
          name: OSX (Python 2.7)

        - os: osx
          osx_image: xcode9.4  # Has python 3.6.5
          language: shell
          env:
            - TRAVIS_PYTHON_VERSION=3.6
          name: OSX (Python 3.6)

        - os: osx
          osx_image: xcode11  # Has python 3.7.4
          language: shell
          env:
            - TRAVIS_PYTHON_VERSION=3.7
          name: OSX (Python 3.7)

        # Check 3.8-dev, but less concerned if this fails.
        - python: 3.8-dev
          dist: xenial
          name: "Python: 3.8-dev"

        # For grins, add pypy.
        - python: pypy3
          name: PyPy
          env:
            - TRAVIS_PYPY=1

    allow_failures:
        - name: Linux clang (Python 3.6)
        - os: osx
        - python: 3.8-dev
        - python: pypy3
    fast_finish: true

before_install:
    - if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo -H apt-get -qq update; sudo -H apt-get install -y libffi-dev openmpi-bin libopenmpi-dev; fi
    - if [[ $TRAVIS_OS_NAME == "osx" ]]; then brew update; brew install libffi openmpi || true; fi

    # On OSX, need to use pip3, not pip and python3, not python
    - if [[ $TRAVIS_OS_NAME == "osx" && $TRAVIS_PYTHON_VERSION > 3.0 ]]; then export PIP=pip3; export PYTHON=python3; else export PIP=pip; export PYTHON=python; fi
    - $PIP --version
    - $PYTHON --version

install:
    # Update pip executable. (Needs sudo on some systems.)
    - sudo -H $PIP install -U pip

    # Install dependencies
    - $PIP install -U $__USER numpy  # Do this first to clarify potential conflicts
    - $PIP install -U $__USER -r requirements.txt

    # Extra packages only needed for testing:
    # fitsio is technically optional, but better to do those tests on all systems.
    - $PIP install -U $__USER codecov fitsio mpi4py
    # Pin some versions for py2.7
    - if [[ $TRAVIS_PYTHON_VERSION < 3.0 ]]; then $PIP install -U $__USER pytest==3.2 pytest-cov==2.4; fi
    - if [[ $TRAVIS_PYTHON_VERSION > 3.0 ]]; then $PIP install -U $__USER pytest pytest-cov mockmpi; fi

    # Only add optional ones for py3.7
    # They are slow to install, especially 3.8 and pypy, where some are installed from scratch.
    - if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then $PIP install -U $__USER matplotlib nbval ipykernel scipy pandas guppy3 h5py; fi
    # halotools doesn't work anymore in 3.x (because of astropy change), so do this in 2.7.
    # And also test h5py here.
    - if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then $PIP install -U $__USER h5py halotools; fi

    - $PIP list

script:
    - $PYTHON setup.py install $__USER

    - cd tests
    - pytest --cov=treecorr test*.py
    # Don't do coverage for mpi tests.  Those are included in the main tests with mock_mpi.
    # These just check that the code works when run in a real mpi session.
    - if [[ $TRAVIS_PYTHON_VERSION > 3.0 ]]; then mpiexec -n 2 $PYTHON -u mpi_test.py >& mpi2.out; fi
    - if [[ $TRAVIS_PYTHON_VERSION > 3.0 ]]; then mpiexec -n 1 $PYTHON -u mpi_test.py >& mpi1.out; fi
    - if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then pytest --nbval Tutorial.ipynb --sanitize-with sanitize.cfg --current-env; fi

after_success:
    - codecov

cache:
    ccache: true
    pip: true
    directories:
        - $HOME/Library/Caches/Homebrew

before_cache:
    - rm -rfv $HOME/.cache/pip/log
    - rm -rfv $HOME/.cache/pip/http
    - if [[ $TRAVIS_OS_NAME == "osx" ]]; then brew cleanup; fi
back to top