jobs:
- job: unit_tests
  steps:
  - bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin"
    displayName: Add conda to PATH

  - script: conda env create --quiet --file environment.yml
    displayName: Create Anaconda environment

  - script: |
      source activate adaptive
      pip install -r test-requirements.txt
    displayName: 'Install test-requirements.txt'

  - script: |
      source activate adaptive
      pytest --verbose --cov=adaptive --cov-report term --cov-report html adaptive
    displayName: 'Run the tests'

- job: linting_tests
  steps:
  - bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin"
    displayName: Add conda to PATH

  - script: |
      pip install pre_commit
      pre-commit install
      pre-commit run --all-files --show-diff-on-failure
    displayName: 'Run pre-commit'

  - script: |
      MISSING_AUTHORS=$(git shortlog -s HEAD | sed -e "s/^[0-9\t ]*//"| xargs -i sh -c 'grep -q "{}" AUTHORS.md || echo "{} missing from authors"')
      if [ ! -z "$MISSING_AUTHORS" ]; then { echo $MISSING_AUTHORS; exit 1; }; fi
    displayName: 'Authors check'
    continueOnError: true