sudo: required

language:
  - none

services:
  - docker

notifications:
  email:
    on_pull_requests: false
    on_success: change
    on_failure: change
    recipients:
      - stevenmacenski@gmail.com
      - mohammad.haghighipanah@intel.com
      - michael.jeronimo@intel.com
      - carlos.a.orduno@intel.com
      - carl.r.delsey@intel.com
      - matthew.k.hansen@intel.com

before_install:
  - if [ "${TRAVIS_REPO_SLUG}" != "ros-planning/navigation2" ];
      then echo "Travis CI is supported only in ros-planning/navigation2" && exit 1;
      fi

matrix:
  include:
    - env: CMAKE_BUILD_TYPE=Release COVERAGE_ENABLED=False
      after_success:
        - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
            echo "Successfully built! Deploying container..."
            docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD ;
            docker tag navigation2:latest stevemacenski/navigation2:latest
            docker push stevemacenski/navigation2:latest ;
            fi

    # - env: CMAKE_BUILD_TYPE=Debug COVERAGE_ENABLED=True
    #   after_success:
    #     - ci_env=`bash <(curl -s https://codecov.io/env)`
    #     - docker exec --interactive --tty $ci_env nav2_bash /ros_entrypoint.sh
    #         src/navigation2/tools/code_coverage_report.bash codecovio

script:
  - docker build --tag navigation2:latest
      --build-arg PULLREQ=$TRAVIS_PULL_REQUEST
      --build-arg CMAKE_BUILD_TYPE
      --build-arg COVERAGE_ENABLED
      ./
  - docker run --rm --detach --name nav2_bash navigation2:latest
      sleep infinity
  - docker exec --interactive --tty nav2_bash /ros_entrypoint.sh
      src/navigation2/tools/run_test_suite.bash