env:
  global:
    - CHANGE_MINIKUBE_NONE_USER=true
    - MINIKUBE_WANTUPDATENOTIFICATION=false
    - MINIKUBE_WANTREPORTERRORPROMPT=false
    - MINIKUBE_HOME=$HOME
    - CHANGE_MINIKUBE_NONE_USER=true
    - KUBECONFIG=$HOME/.kube/config
    - LOCAL_IP=$(ifconfig | grep inet | head -1 | awk '{print $2}' | cut -d':' -f2)

    - IMAGE_TAG="noobaa-${TRAVIS_COMMIT}"
    - TESTER_TAG="noobaa-tester-${TRAVIS_COMMIT}"

    - NO_CACHE="NO_CACHE=true"
    - SUPPRESS_LOGS="SUPPRESS_LOGS=true"
    - DEPLOY_MINIKUBE_REDIRECT="/dev/null"

    - PR_TITLE=$(curl https://github.com/${TRAVIS_REPO_SLUG}/pull/${TRAVIS_PULL_REQUEST} 2> /dev/null | grep "title" | head -1)

matrix:
  include:
    - language: generic

      name: "Unit Tests"

      services:
        - docker

      before_install:
        # When the PR headline contains the string "dbg" it will run in dbg mode:
        # Will not call to "SUPPRESS_LOGS=true"
        - if [[ "${PR_TITLE}" =~ "dbg" ]] ; then export export SUPPRESS_LOGS=" " ; fi
      script:
        - make tester ${NO_CACHE} ${SUPPRESS_LOGS} || exit 1
        - make test ${SUPPRESS_LOGS}

    - language: generic

      name: "Frontend Library Build Test"

      script:
        - make verify-fe-lib

    - language: node_js
      node_js:
        - "14"

      name: "Build & Sanity Integration Tests"

      sudo: required

      dist: xenial #seems like running trusty fails minukube deployment

      before_install:
        # When the PR headline contains the string "dbg" it will run in dbg mode:
        # Will not call to "SUPPRESS_LOGS=true, and will not redirect the output of deploy_minikube.sh"
        - if [[ "${PR_TITLE}" =~ "dbg" ]] ; then export export SUPPRESS_LOGS=" " ; export DEPLOY_MINIKUBE_REDIRECT="/dev/stdout" ; fi

      install:
        - "./.travis/deploy_minikube.sh 1 >& ${DEPLOY_MINIKUBE_REDIRECT}"

      script:
        - make tester NOOBAA_TAG=${IMAGE_TAG} TESTER_TAG=${TESTER_TAG} ${NO_CACHE} ${SUPPRESS_LOGS} || exit 1
        - "cd ./src/test/framework/ && ./run_test_job.sh --name ${TRAVIS_COMMIT} --image ${IMAGE_TAG} --tester_image ${TESTER_TAG} --job_yaml ../../../.travis/travis_test_job.yaml --wait"
