# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

trigger:
  - main
  - release/*

pool:
  name: SuperBench CI
  vmImage: ubuntu-latest

container:
  image: nvcr.io/nvidia/pytorch:20.12-py3
  options: '-v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -v /usr/bin/sudo:/usr/bin/sudo -v /usr/lib/sudo/:/usr/lib/sudo/'

steps:
  - script: |
      echo "##vso[task.prependpath]$HOME/.local/bin"
    displayName: Export path
  - script: |
      python3 -m pip install --upgrade pip setuptools==65.7
      python3 -m pip install .[test,nvworker]
      make postinstall
      sudo DEBIAN_FRONTEND=noninteractive apt-get update
      sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswresample-dev
    displayName: Install dependencies
  - script: |
      python3 setup.py lint
    displayName: Run code lint
  - script: |
      SB_MICRO_PATH=$PWD make cppbuild
    displayName: Build benchmarks
  - script: |
      SB_MICRO_PATH=$PWD python3 setup.py test
    displayName: Run unit tests
    timeoutInMinutes: 60
  - script: |
      bash <(curl -s https://codecov.io/bash) -cF cuda-unit-test
    displayName: Report coverage results
    env:
      CODECOV_TOKEN: $(codecovToken)
