trigger: none

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

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

variables:
  filter.modified.globs: 'examples/model_compress/**,nni/algorithms/compression/**,nni/compression/**,pipelines/full-test-compression.yml,test/algo/compression/**'
  filter.prbody.heading: '#### Test Options'
  filter.prbody.optionIndex: 3

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

    - script: |
        python -m pip install "pytorch-lightning<1.7"
      displayName: Pin PytorchLightning version

    - template: templates/install-nni.yml

    - template: templates/download-test-data.yml

    - script: |
        cd test/algo
        python -m pytest compression
      displayName: Compression unit test

    - script: |
        cd test
        source scripts/model_compression.sh
      displayName: Model compression test
