# Python package
# Create and test a Python package on multiple Python versions.
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/python

trigger:
- master

jobs:

- job: 'Test_conda'
  pool:
    vmImage: 'ubuntu-latest'
  strategy:
    matrix:
      Python27:
        python.version: '27'
      Python35:
        python.version: '35'
      Python36:
        python.version: '36'
      Python37:
        python.version: '37'

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

  - script: conda env create --quiet --file ci/requirements-py$(python.version).yml
    displayName: Create Anaconda environment

  - script: |
      source activate test_env
      pip install pytest pytest-azurepipelines
    displayName: 'pip dependencies'

  - script: |
      source activate test_env
      conda list
    displayName: 'List installed dependencies'
  - script: |
      source activate test_env
      pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html
    displayName: 'pytest'
  - script: |
      source activate test_env
      flake8 pvlib
    displayName: 'flake8'
  - task: PublishTestResults@2
    inputs:
      testResultsFiles: '**/test-results.xml'
      testRunTitle: 'Python $(python.version)'

  - task: PublishCodeCoverageResults@1
    inputs:
      codeCoverageTool: Cobertura
      summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
      reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'

  - script: |
      bash <(curl https://codecov.io/bash) -t bbc2bdbe-5e67-4fef-9cb7-f52fe0b703a8 -f coverage.xml -F adder -F subtractor -F conda
    displayName: 'codecov'


- job: 'Publish'
  dependsOn: 'Test_conda'
  pool:
    vmImage: 'ubuntu-latest'

  steps:
  - task: UsePythonVersion@0
    inputs:
      versionSpec: '3.x'
      architecture: 'x64'

  - script: python setup.py sdist
    displayName: 'Build sdist'
Set up CI with Azure Pipelines
Set up CI with Azure Pipelines

[skip ci]