language: python

jobs:
  include:
    - name: "Python 3.6.0 on Xenial Linux"
      python: 3.6 # this works for Linux but is ignored on macOS or Windows
    - name: "Python 3.7.0 on Xenial Linux"
      python: 3.7 # this works for Linux but is ignored on macOS or Windows
    - name: "Python 3.8.0 on Xenial Linux"
      python: 3.8 # this works for Linux but is ignored on macOS or Windows
    - name: "Python 3.9.0 on Xenial Linux"
      python: 3.9 # this works for Linux but is ignored on macOS or Windows
    - name: "Python 3.10.0 on Xenial Linux"
      python: 3.10 # this works for Linux but is ignored on macOS or Windows
    - name: "xcode 10.2 on macOS"
      os: osx
      osx_image: xcode10.2
      language: shell # 'language: python' is an error on Travis CI macOS
    - name: "xcode 9.4 on macOS"
      os: osx
      osx_image: xcode9.4
      language: shell # 'language: python' is an error on Travis CI macOS
    - name: "xcode 11.2 on macOS"
      os: osx
      osx_image: xcode11.2
      language: shell # 'language: python' is an error on Travis CI macOS

cache:
  apt: true
  directories:
    - $HOME/.cache/pip

addons:
  apt:
    packages:
      - libhdf5-dev

before_install:
  # activate env for mac
  - if [[ "$OSTYPE" == "darwin"* ]]; then python3 -m venv env && source env/bin/activate; fi

install:
  # Upgrade distribution modules
  - "pip3 install --upgrade setuptools"
  - "pip3 install --upgrade pip"

  # Install build dependencies
  - "pip3 install wheel"
  - "pip3 install --trusted-host www.silx.org  --trusted-host www.edna-site.org -r ci/requirement_travis.txt --upgrade --find-links http://www.silx.org/pub/wheelhouse"

  # Print Python info
  - "python3 ci/info_platform.py"
  - "pip3 freeze"

  # Build
  - "python3 setup.py build"
  - "python3 setup.py bdist_wheel"
  - "ls dist"

  # Install generated wheel
  - "pip3 install --pre --find-links dist/ --trusted-host www.silx.org --trusted-host www.edna-site.org --find-links http://www.silx.org/pub/wheelhouse freesas"

script:
  # Print Python info
  - "python3 ci/info_platform.py"
  - "pip3 freeze"
  - "python3 --version"
  - "gcc --version"

  # Run the tests
  - "python3 setup.py build test"
  - "python3 run_tests.py"

  #Run end to end tests
  - "mkdir empty"
  - "cd empty"
  - "python3 ../e2etest/e2etest.py"
