language: cpp
sudo: required
dist: bionic
os:
  - linux
compiler:
  - g++

addons:
    apt:
        sources:
            - ubuntu-toolchain-r-test
        packages:
            - lcov

services:
  - docker

branches:
  - master

install:
  - sudo apt update
  - sudo apt-get -yq install gcc g++ cmake
  - lscpu
  - lspci | grep VGA

before_script:
  # Run Vision Tests - CPU
  - mkdir build-openvx
  - cd build-openvx
  - cmake -D CMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage" -D GPU_SUPPORT=OFF ../
  - make -j4
  - python ../tests/vision_tests/runVisionTests.py --runvx_directory bin --num_frames 10
  - cd ../
  # Run OpenVX 1.3 Conformance - CPU
  - export OPENVX_DIR=$(pwd)/build-openvx
  - export OPENVX_INC=$(pwd)/amd_openvx/openvx
  - mkdir conformance_tests
  - cd conformance_tests
  - git clone -b openvx_1.3 https://github.com/KhronosGroup/OpenVX-cts.git
  - export VX_TEST_DATA_PATH=$(pwd)/OpenVX-cts/test_data/
  - mkdir build-cts
  - cd build-cts
  - cmake -DOPENVX_INCLUDES=$OPENVX_INC/include -DOPENVX_LIBRARIES=$OPENVX_DIR/lib/libopenvx.so\;$OPENVX_DIR/lib/libvxu.so\;pthread\;dl\;m\;rt -DOPENVX_CONFORMANCE_VISION=ON ../OpenVX-cts
  - cmake --build .
  - LD_LIBRARY_PATH=./lib ./bin/vx_test_conformance
  - cd ../../
  # Run OpenVX 1.3 Conformance - GPU
  # - TBD:
  # Dockers for Level Testing
  - docker pull kiritigowda/ubuntu-18.04:mivisionx-level-1
  - docker run -it -d --name mivisionx-1 --network host kiritigowda/ubuntu-18.04:mivisionx-level-1 bash
  - docker cp ../MIVisionX mivisionx-1:/MIVisionX
  - docker pull kiritigowda/ubuntu-18.04:mivisionx-level-2
  - docker run -it -d --name mivisionx-2 --network host kiritigowda/ubuntu-18.04:mivisionx-level-2 bash
  - docker cp ../MIVisionX mivisionx-2:/MIVisionX
  - docker pull kiritigowda/ubuntu-18.04:mivisionx-level-3
  - docker run -it -d --name mivisionx-3 --network host kiritigowda/ubuntu-18.04:mivisionx-level-3 bash
  - docker cp ../MIVisionX mivisionx-3:/MIVisionX
  - docker pull kiritigowda/ubuntu-18.04:mivisionx-level-4
  - docker run -it -d --name mivisionx-4 --network host kiritigowda/ubuntu-18.04:mivisionx-level-4 bash
  - docker cp ../MIVisionX mivisionx-4:/MIVisionX
  - docker pull kiritigowda/ubuntu-18.04:mivisionx-level-5
  - docker run -it -d --name mivisionx-5 --network host kiritigowda/ubuntu-18.04:mivisionx-level-5 bash
  - docker cp ../MIVisionX mivisionx-5:/MIVisionX

script:
  # Level 1 - [cmake gcc g++] - CPU Only OpenVX
  - docker exec mivisionx-1 cmake -H/MIVisionX -B/_build -DCMAKE_BUILD_TYPE=Release
  - docker exec mivisionx-1 cmake --build /_build --clean-first -- -j8
  # Level 2 - [ROCm OpenCL + Level 1] - CPU + OpenCL Components
  - docker exec mivisionx-2 cmake -H/MIVisionX -B/_build -DCMAKE_BUILD_TYPE=Release
  - docker exec mivisionx-2 cmake --build /_build --clean-first -- -j8
  # Level 3 - [OpenCV FFMPEG + Level 2] - CPU + OpenCL Components + OpenCV EXT + amd_media
  - docker exec mivisionx-3 cmake -H/MIVisionX -B/_build -DCMAKE_BUILD_TYPE=Release
  - docker exec mivisionx-3 cmake --build /_build --clean-first -- -j8
  # Level 4 - [MIOpenGEMM MIOpen ProtoBuf + Level 3] - CPU + OpenCL Components + OpenCV EXT + amd_media + Neural Net Components
  - docker exec mivisionx-4 cmake -H/MIVisionX -B/_build -DCMAKE_BUILD_TYPE=Release
  - docker exec mivisionx-4 cmake --build /_build --clean-first -- -j8
  # Level 5 - [AMD_RPP rocAL Deps + Level 4] - CPU + OpenCL Components + OpenCV EXT + amd_media + Neural Net Components + rocAL
  - docker exec mivisionx-5 cmake -H/MIVisionX -B/_build -DCMAKE_BUILD_TYPE=Release
  - docker exec mivisionx-5 cmake --build /_build --clean-first -- -j8

after_success:
  # code coverage tracking
  - lcov --directory . --capture --output-file coverage.info
  - lcov --remove coverage.info '/usr/*' '*/runvx/*' --output-file coverage.info
  - lcov --list coverage.info
  - bash <(curl -s https://codecov.io/bash) || echo "codecov did not collect coverage reports"

notifications:
  email:
    - mivisionx.support@amd.com
