# Use new container infrastructure to enable caching
sudo: required
dist: trusty

# language is go
language: go
go:
  - "1.13"
go_import_path: gocv.io/x/gocv

addons:
  apt:
    packages:
    - libgmp-dev
    - build-essential
    - cmake
    - git
    - libgtk2.0-dev
    - pkg-config
    - libavcodec-dev
    - libavformat-dev
    - libswscale-dev
    - libtbb2
    - libtbb-dev
    - libjpeg-dev
    - libpng-dev
    - libtiff-dev
    - libjasper-dev
    - libdc1394-22-dev
    - xvfb

before_install:
  - ./travis_build_opencv.sh
  - export PKG_CONFIG_PATH=$(pkg-config --variable pc_path pkg-config):$HOME/usr/lib/pkgconfig
  - export INCLUDE_PATH=$HOME/usr/include:${INCLUDE_PATH}
  - export LD_LIBRARY_PATH=$HOME/usr/lib:${LD_LIBRARY_PATH}
  - sudo ln /dev/null /dev/raw1394
  - export DISPLAY=:99.0
  - sh -e /etc/init.d/xvfb start

before_cache:
  - rm -f $HOME/fresh-cache

script:
  - export GOCV_CAFFE_TEST_FILES="${HOME}/testdata"
  - export GOCV_TENSORFLOW_TEST_FILES="${HOME}/testdata"
  - export OPENCV_ENABLE_NONFREE=ON
  - echo "Ensuring code is well formatted"; ! gofmt -s -d . | read
  - go test -v -coverprofile=coverage.txt -covermode=atomic -tags matprofile .
  - go test -tags matprofile ./contrib -coverprofile=contrib.txt -covermode=atomic; cat contrib.txt >> coverage.txt; rm contrib.txt;

after_success:
  - bash <(curl -s https://codecov.io/bash)

# Caching so the next build will be fast as possible.
cache:
  timeout: 1000
  directories:
    - $HOME/usr
    - $HOME/testdata
