Skip to content

Commit

Permalink
move CI to Azure Pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat committed Oct 22, 2018
1 parent 83c616d commit 9d8d241
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 81 deletions.
55 changes: 0 additions & 55 deletions .travis.yml

This file was deleted.

26 changes: 0 additions & 26 deletions appveyor.yml

This file was deleted.

118 changes: 118 additions & 0 deletions azure-pipelines.yml
@@ -0,0 +1,118 @@
name: $(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.rr)

variables:
"System.PreferGit": true
PYTEST_ADDOPTS: "-vv -ra --showlocals"

trigger:
batch: true
branches:
include:
- master
- refs/tags/*
paths:
exclude:
- LICENSE.txt
- HOWTORELEASE.rst
- AUTHORS.txt
- CONTRIBUTING.rst
- .gitignore
- .github/*

jobs:
- template: azure-run-tox-env.yml
parameters: {tox: docs, python: 3.7}
- template: azure-run-tox-env.yml
parameters: {tox: package_readme, python: 3.7}

- template: azure-run-tox-env.yml
parameters: {tox: pypy, python: pypy, os: linux}
- template: azure-run-tox-env.yml
parameters: {tox: pypy3, python: pypy3, os: linux}

- template: azure-run-tox-env.yml
parameters: {tox: py37, python: 3.7, os: windows}
- template: azure-run-tox-env.yml
parameters: {tox: py36, python: 3.6, os: windows}
- template: azure-run-tox-env.yml
parameters: {tox: py35, python: 3.5, os: windows}
- template: azure-run-tox-env.yml
parameters: {tox: py34, python: 3.4, os: windows}
- template: azure-run-tox-env.yml
parameters: {tox: py27, python: 2.7, os: windows}

- template: azure-run-tox-env.yml
parameters: {tox: py37, python: 3.7, os: linux}
- template: azure-run-tox-env.yml
parameters: {tox: py36, python: 3.6, os: linux}
- template: azure-run-tox-env.yml
parameters: {tox: py35, python: 3.5, os: linux}
- template: azure-run-tox-env.yml
parameters: {tox: py34, python: 3.4, os: linux}
- template: azure-run-tox-env.yml
parameters: {tox: py27, python: 2.7, os: linux}

- template: azure-run-tox-env.yml
parameters: {tox: py36, python: 3.6, os: macOs}
- template: azure-run-tox-env.yml
parameters: {tox: py27, python: 2.7, os: macOs}

- job: report_coverage
pool: {vmImage: 'Ubuntu 16.04'}
condition: eq(variables['system.pullrequest.isfork'], false)
dependsOn:
- windows_py37
- windows_py36
- windows_py35
- windows_py34
- windows_py27
- linux_py37
- linux_py36
- linux_py35
- linux_py34
- linux_py27
- linux_pypy3
- linux_pypy
- macOS_py36
- macOS_py27
steps:
- task: DownloadBuildArtifacts@0
displayName: download coverage files for run
inputs:
buildType: current
downloadType: specific
itemPattern: coverage-*/*
downloadPath: $(Build.StagingDirectory)

- task: UsePythonVersion@0
displayName: setup python
inputs:
versionSpec: 3.7

- script: |
python -c '
from pathlib import Path
import shutil
from_folder = Path("$(Build.StagingDirectory)")
destination_folder = Path("$(System.DefaultWorkingDirectory)") / ".tox"
destination_folder.mkdir()
for coverage_file in from_folder.glob("*/.coverage"):
destination = destination_folder / f".coverage.{coverage_file.parent.name[9:]}"
print(f"{coverage_file} copy to {destination}")
shutil.copy(str(coverage_file), str(destination))'
displayName: move coverage files into .tox
- script: 'python -m pip install -U tox --pre'
displayName: install tox

- script: 'python -m tox -e coverage'
displayName: create coverag report via tox

- task: PublishCodeCoverageResults@1
displayName: publish overall coverage report to Azure
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/.tox/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/.tox/htmlcov'
failIfCoverageEmpty: true
79 changes: 79 additions & 0 deletions azure-run-tox-env.yml
@@ -0,0 +1,79 @@
parameters:
tox: ""
python: ""
os: "linux"

jobs:
- job: ${{ format('{0}_{1}', parameters.os, parameters.tox) }}
pool:
${{ if eq(parameters.os, 'windows') }}:
vmImage: "vs2017-win2016"
${{ if eq(parameters.os, 'macOs') }}:
vmImage: "macOS 10.13"
${{ if eq(parameters.os, 'linux') }}:
vmImage: "Ubuntu 16.04"

variables:
${{ if in(parameters.python, 'pypy', 'pypy3') }}:
python: ${{ parameters.python }}
${{ if notIn(parameters.python, 'pypy', 'pypy3') }}:
python: "python"

steps:
# ensure the required Python versions are available
- ${{ if notIn(parameters.python, 'pypy', 'pypy3') }}:
- task: UsePythonVersion@0
displayName: setup python
inputs:
versionSpec: ${{ parameters.python }}

- script: "$(python) -c \"import sys; print(sys.version); print(sys.executable)\""
displayName: show python information

- script: "python -m pip install -U pip setuptools --user -v"
displayName: upgrade pip and setuptools

- script: "python -m pip install -U tox --pre --user -v"
displayName: install tox

- script: ${{ format('python -m tox -e {0} --notest', parameters.tox) }}
displayName: install test dependencies

- ${{ if startsWith(parameters.tox, 'py') }}:
- script: python -m tox -e coverage --notest
displayName: install coverage dependencies

- script: ${{ format('python -m tox -e {0}', parameters.tox) }}
displayName: run tests

- ${{ if and( startsWith(parameters.tox, 'py'), eq(variables['system.pullrequest.isfork'], false) ) }}:
- task: PublishTestResults@2
displayName: publish test results via junit
condition: succeededOrFailed()
inputs:
testResultsFormat: "JUnit"
testResultsFiles: ${{ format('$(System.DefaultWorkingDirectory)/.tox/.test.{0}.xml', parameters.tox) }}
testRunTitle: ${{ format('{0}_{1}', parameters.os, parameters.tox) }}

- ${{ if startsWith(parameters.tox, 'py') }}:
- script: "python -m tox -e coverage"
displayName: create coverag report
condition: succeededOrFailed()

- ${{ if and( startsWith(parameters.tox, 'py'), eq(variables['system.pullrequest.isfork'], false) ) }}:
- task: CopyFiles@2
displayName: move coverage files into staging area
condition: succeededOrFailed()
inputs:
sourceFolder: $(System.DefaultWorkingDirectory)/.tox
contents: |
.coverage
coverage.xml
targetFolder: $(Build.StagingDirectory)

- task: PublishBuildArtifacts@1
displayName: publish coverage file
condition: succeededOrFailed()
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
ArtifactName: ${{ format('coverage-{0}-{1}', parameters.os, parameters.tox) }}
16 changes: 16 additions & 0 deletions tox.ini
Expand Up @@ -35,6 +35,22 @@ source = virtualenv
*/virtualenv
*\virtualenv

[testenv:coverage]
description = [run locally after tests]: combine coverage data and create report;
generates a diff coverage against origin/master (can be changed by setting DIFF_AGAINST env var)
deps = {[testenv]deps}
coverage >= 4.4.1, < 5
diff_cover
skip_install = True
passenv = DIFF_AGAINST
setenv = COVERAGE_FILE={toxworkdir}/.coverage
commands = coverage erase
coverage combine
coverage report -m
coverage xml -o {toxworkdir}/coverage.xml
coverage html -d {toxworkdir}/htmlcov
diff-cover --compare-branch {env:DIFF_AGAINST:origin/master} {toxworkdir}/coverage.xml

[testenv:cross_python2]
description = test creating a python3 venv with a python2-based virtualenv
basepython = python2
Expand Down

0 comments on commit 9d8d241

Please sign in to comment.