trigger: none

schedules:
- cron: 0 18 * * *
  branches:
    include: [ master ]
  always: true

resources:
  repositories:
    - repository: azpfilter
      type: github
      name: microsoft/azure-pipeline-filter
      endpoint: github-filter-connection

variables:
  filter.modified.globs: 'examples/tuners/**,nni/algorithms/hpo/**,pipelines/full-test-hpo.yml,'
  filter.prbody.heading: '#### Test Options'
  filter.prbody.optionIndex: 1

stages:
- stage: filter
  jobs:
  - job: check
    pool:
      vmImage: ubuntu-latest
    steps:
    - template: templates/stage-filter.yml

- stage: test
  # dependencies.$(StageName).outputs['$(JobName).$(TaskName).$(VariableName)']
  condition: and(succeeded(), ne(dependencies.filter.outputs['check.execution.skipsubsequent'], 'true'))
  jobs:
  - job: linux
    pool: nni-it-1es-11
    timeoutInMinutes: 60

    steps:
    - template: templates/check-gpu-status.yml

    - template: templates/install-dependencies.yml
      parameters:
        platform: ubuntu-latest-gpu
        python_env: venv

    - template: templates/install-nni.yml

    - template: templates/install-customized-tuner.yml

    - script: |
        set -e
        (cd test && python -m pytest ut)
        export PATH=$PATH:$PWD/toolchain/yarn/bin
        export CI=true
        (cd ts/nni_manager && yarn test)
      displayName: SDK unit test

    # TODO: this should be replaced with a dedicated HPO algo test suite

    - script: |
        cd test
        python training_service/nnitest/run_tests.py --config training_service/config/integration_tests.yml --ts local
      displayName: Integration test

  # TODO: should add a test on platforms other than linux
