dist: jammy
language: python

matrix:
    include:
        - python: '3.8'
          env:
            - COVERAGE="true"

        - python: '3.9'
          env:
            - COVERAGE="true"
            - DILL="true"

        - python: '3.10'
          env:

        - python: '3.11'
          env:

        - python: '3.12'
          env:

        - python: '3.13-dev'
          env:
            - PYVERSION="3.13"
            - DILL="master"

        - python: 'pypy3.8-7.3.9' # is 7.3.11
          env:
            - PYPY_VERSION="3.8"

        - python: 'pypy3.9-7.3.9' # is 7.3.16
          env:
            - PYPY_VERSION="3.9"

        - python: 'pypy3.10-7.3.17'
          env:
            - PYPY_VERSION="3.10"

    allow_failures:
        - python: 'pypy3.10-7.3.17' # CI missing
    fast_finish: true

cache:
    pip: true

before_install:
    - set -e  # fail on any error
    - if [[ $COVERAGE == "true" ]]; then pip install coverage; fi
    - if [[ $DILL == "true" ]]; then pip install dill; fi
    - if [[ $DILL == "master" ]]; then pip install "https://github.com/uqfoundation/dill/archive/master.tar.gz"; fi

install:
    - python -m pip install .

script:
    - if [[ $PYVERSION != "3.13" ]]; then PYVERSION=$TRAVIS_PYTHON_VERSION ; fi
    - if [[ $PYVERSION == "pypy3.8-7.3.9" ]]; then PYVERSION=py$PYPY_VERSION ; fi
    - if [[ $PYVERSION == "pypy3.9-7.3.9" ]]; then PYVERSION=py$PYPY_VERSION ; fi
    - if [[ $PYVERSION == "pypy3.10-7.3.15" ]]; then PYVERSION=py$PYPY_VERSION ; fi
    - cd py$PYVERSION #XXX: bash script may require tests run from root
    - if [[ $COVERAGE == "true" ]]; then cp ../.coveragerc .coveragerc ; fi
    - for test in multiprocess/tests/__init__.py; do echo $test ; if [[ $COVERAGE == "true" ]]; then coverage run -a $test > /dev/null; else python $test > /dev/null; fi ; done
    - if [[ $PYVERSION == *"py3"* ]]; then for test in multiprocess/tests/test_multiprocessing_fork.py; do echo $test ; if [[ $COVERAGE == "true" ]]; then coverage run -a $test > /dev/null; else python $test > /dev/null; fi ; done ; elif [[ $PYVERSION == "3.11" || $PYVERSION == "3.12" || $PYVERSION == "3.13" ]]; then for test in multiprocess/tests/*.py multiprocess/tests/test_*/*.py; do if [[ $test != *"__"* && $test != *"mp_"* ]]; then echo $test ; if [[ $COVERAGE == "true" ]]; then coverage run -a $test > /dev/null; else python $test > /dev/null; fi ; fi ; done ; else for test in multiprocess/tests/*.py; do if [[ $test != *"__"* && $test != *"mp_"* ]]; then echo $test ; if [[ $COVERAGE == "true" ]]; then coverage run -a $test > /dev/null; else python $test > /dev/null; fi ; fi; done ; fi
    - cd ..

after_success:
    - cd py$PYVERSION
    - if [[ $COVERAGE == "true" ]]; then bash <(curl -s https://codecov.io/bash); else echo ''; fi
    - if [[ $COVERAGE == "true" ]]; then coverage report; fi
    - cd ..
