dist: xenial
sudo: false
language: python
python:
    - 3.9
    - 3.8
    - 3.7
    - 3.6
    - 3.5
    - 2.7

env:
  matrix:
    - BUILD_OPTS=--xplat NUNIT_PATH="~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe" RUN_TESTS=dotnet EMBED_TESTS_PATH=netcoreapp2.0_publish/ PERF_TESTS_PATH=net461/
    - BUILD_OPTS="" NUNIT_PATH="./packages/NUnit.*/tools/nunit3-console.exe" RUN_TESTS="mono $NUNIT_PATH" EMBED_TESTS_PATH="" PERF_TESTS_PATH=""

  global:
    - LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
    - SEGFAULT_SIGNALS=all
    - PYTHONUNBUFFERED=True
    - CODECOV_ENV=TRAVIS_PYTHON_VERSION

addons:
  apt:
    sources:
      - sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main
        key_url: https://packages.microsoft.com/keys/microsoft.asc
      - sourceline: deb http://download.mono-project.com/repo/ubuntu stable-xenial/snapshots/5.20 main
        key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
    packages:
      - mono-devel
      - ca-certificates-mono
      - dotnet-hostfxr-2.2
      - dotnet-runtime-2.2
      - dotnet-sdk-2.2

before_install:
  # Set-up dll path for embedded tests
  - PY_LIBDIR=$(python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))')
  - export LD_LIBRARY_PATH=$PY_LIBDIR:$LD_LIBRARY_PATH

install:
  - pip install --upgrade setuptools # TEMP - due to setuptools 36.2.0 bug
  - pip install --upgrade -r requirements.txt
  - coverage run setup.py install $BUILD_OPTS

script:
  - python -m pytest
  - $RUN_TESTS src/embed_tests/bin/$EMBED_TESTS_PATH/Python.EmbeddingTest.dll --labels=All
  # does not work on Linux, because NuGet package for 2.3 is Windows only
  # - "if [[ $TRAVIS_PYTHON_VERSION == '3.5' && $PERF_TESTS_PATH != '' ]]; then mono $NUNIT_PATH src/perf_tests/bin/$PERF_TESTS_PATH/Python.PerformanceTests.dll; fi"

after_script:
  # Waiting on mono-coverage, SharpCover or xr.Baboon
  - coverage xml -i
  - codecov --file coverage.xml --flags setup_linux

notifications:
  email: false
  slack:
    secure: "UiQdSK1/uNnHl8/gQgfLj/F5JGxtJuaT3QYtKNcw3Ddpr3FX8tfXJ/RjsCsSlRQzDm7AdBAeMzcBQmvH4iRIV2y7qVywLyru5MPiwY4ZjMN6fJK/zaaxetOct9fasIBYzHguNPDAtiBGFh2iK1H1MXTY8rkmU3WZvl18b8EsrP0="
