Skip to content

Commit 9d8d241

Browse files
committed
move CI to Azure Pipelines
1 parent 83c616d commit 9d8d241

File tree

5 files changed

+213
-81
lines changed

5 files changed

+213
-81
lines changed

.travis.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

appveyor.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

azure-pipelines.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: $(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.rr)
2+
3+
variables:
4+
"System.PreferGit": true
5+
PYTEST_ADDOPTS: "-vv -ra --showlocals"
6+
7+
trigger:
8+
batch: true
9+
branches:
10+
include:
11+
- master
12+
- refs/tags/*
13+
paths:
14+
exclude:
15+
- LICENSE.txt
16+
- HOWTORELEASE.rst
17+
- AUTHORS.txt
18+
- CONTRIBUTING.rst
19+
- .gitignore
20+
- .github/*
21+
22+
jobs:
23+
- template: azure-run-tox-env.yml
24+
parameters: {tox: docs, python: 3.7}
25+
- template: azure-run-tox-env.yml
26+
parameters: {tox: package_readme, python: 3.7}
27+
28+
- template: azure-run-tox-env.yml
29+
parameters: {tox: pypy, python: pypy, os: linux}
30+
- template: azure-run-tox-env.yml
31+
parameters: {tox: pypy3, python: pypy3, os: linux}
32+
33+
- template: azure-run-tox-env.yml
34+
parameters: {tox: py37, python: 3.7, os: windows}
35+
- template: azure-run-tox-env.yml
36+
parameters: {tox: py36, python: 3.6, os: windows}
37+
- template: azure-run-tox-env.yml
38+
parameters: {tox: py35, python: 3.5, os: windows}
39+
- template: azure-run-tox-env.yml
40+
parameters: {tox: py34, python: 3.4, os: windows}
41+
- template: azure-run-tox-env.yml
42+
parameters: {tox: py27, python: 2.7, os: windows}
43+
44+
- template: azure-run-tox-env.yml
45+
parameters: {tox: py37, python: 3.7, os: linux}
46+
- template: azure-run-tox-env.yml
47+
parameters: {tox: py36, python: 3.6, os: linux}
48+
- template: azure-run-tox-env.yml
49+
parameters: {tox: py35, python: 3.5, os: linux}
50+
- template: azure-run-tox-env.yml
51+
parameters: {tox: py34, python: 3.4, os: linux}
52+
- template: azure-run-tox-env.yml
53+
parameters: {tox: py27, python: 2.7, os: linux}
54+
55+
- template: azure-run-tox-env.yml
56+
parameters: {tox: py36, python: 3.6, os: macOs}
57+
- template: azure-run-tox-env.yml
58+
parameters: {tox: py27, python: 2.7, os: macOs}
59+
60+
- job: report_coverage
61+
pool: {vmImage: 'Ubuntu 16.04'}
62+
condition: eq(variables['system.pullrequest.isfork'], false)
63+
dependsOn:
64+
- windows_py37
65+
- windows_py36
66+
- windows_py35
67+
- windows_py34
68+
- windows_py27
69+
- linux_py37
70+
- linux_py36
71+
- linux_py35
72+
- linux_py34
73+
- linux_py27
74+
- linux_pypy3
75+
- linux_pypy
76+
- macOS_py36
77+
- macOS_py27
78+
steps:
79+
- task: DownloadBuildArtifacts@0
80+
displayName: download coverage files for run
81+
inputs:
82+
buildType: current
83+
downloadType: specific
84+
itemPattern: coverage-*/*
85+
downloadPath: $(Build.StagingDirectory)
86+
87+
- task: UsePythonVersion@0
88+
displayName: setup python
89+
inputs:
90+
versionSpec: 3.7
91+
92+
- script: |
93+
python -c '
94+
from pathlib import Path
95+
import shutil
96+
97+
from_folder = Path("$(Build.StagingDirectory)")
98+
destination_folder = Path("$(System.DefaultWorkingDirectory)") / ".tox"
99+
destination_folder.mkdir()
100+
for coverage_file in from_folder.glob("*/.coverage"):
101+
destination = destination_folder / f".coverage.{coverage_file.parent.name[9:]}"
102+
print(f"{coverage_file} copy to {destination}")
103+
shutil.copy(str(coverage_file), str(destination))'
104+
displayName: move coverage files into .tox
105+
106+
- script: 'python -m pip install -U tox --pre'
107+
displayName: install tox
108+
109+
- script: 'python -m tox -e coverage'
110+
displayName: create coverag report via tox
111+
112+
- task: PublishCodeCoverageResults@1
113+
displayName: publish overall coverage report to Azure
114+
inputs:
115+
codeCoverageTool: 'cobertura'
116+
summaryFileLocation: '$(System.DefaultWorkingDirectory)/.tox/coverage.xml'
117+
reportDirectory: '$(System.DefaultWorkingDirectory)/.tox/htmlcov'
118+
failIfCoverageEmpty: true

azure-run-tox-env.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
parameters:
2+
tox: ""
3+
python: ""
4+
os: "linux"
5+
6+
jobs:
7+
- job: ${{ format('{0}_{1}', parameters.os, parameters.tox) }}
8+
pool:
9+
${{ if eq(parameters.os, 'windows') }}:
10+
vmImage: "vs2017-win2016"
11+
${{ if eq(parameters.os, 'macOs') }}:
12+
vmImage: "macOS 10.13"
13+
${{ if eq(parameters.os, 'linux') }}:
14+
vmImage: "Ubuntu 16.04"
15+
16+
variables:
17+
${{ if in(parameters.python, 'pypy', 'pypy3') }}:
18+
python: ${{ parameters.python }}
19+
${{ if notIn(parameters.python, 'pypy', 'pypy3') }}:
20+
python: "python"
21+
22+
steps:
23+
# ensure the required Python versions are available
24+
- ${{ if notIn(parameters.python, 'pypy', 'pypy3') }}:
25+
- task: UsePythonVersion@0
26+
displayName: setup python
27+
inputs:
28+
versionSpec: ${{ parameters.python }}
29+
30+
- script: "$(python) -c \"import sys; print(sys.version); print(sys.executable)\""
31+
displayName: show python information
32+
33+
- script: "python -m pip install -U pip setuptools --user -v"
34+
displayName: upgrade pip and setuptools
35+
36+
- script: "python -m pip install -U tox --pre --user -v"
37+
displayName: install tox
38+
39+
- script: ${{ format('python -m tox -e {0} --notest', parameters.tox) }}
40+
displayName: install test dependencies
41+
42+
- ${{ if startsWith(parameters.tox, 'py') }}:
43+
- script: python -m tox -e coverage --notest
44+
displayName: install coverage dependencies
45+
46+
- script: ${{ format('python -m tox -e {0}', parameters.tox) }}
47+
displayName: run tests
48+
49+
- ${{ if and( startsWith(parameters.tox, 'py'), eq(variables['system.pullrequest.isfork'], false) ) }}:
50+
- task: PublishTestResults@2
51+
displayName: publish test results via junit
52+
condition: succeededOrFailed()
53+
inputs:
54+
testResultsFormat: "JUnit"
55+
testResultsFiles: ${{ format('$(System.DefaultWorkingDirectory)/.tox/.test.{0}.xml', parameters.tox) }}
56+
testRunTitle: ${{ format('{0}_{1}', parameters.os, parameters.tox) }}
57+
58+
- ${{ if startsWith(parameters.tox, 'py') }}:
59+
- script: "python -m tox -e coverage"
60+
displayName: create coverag report
61+
condition: succeededOrFailed()
62+
63+
- ${{ if and( startsWith(parameters.tox, 'py'), eq(variables['system.pullrequest.isfork'], false) ) }}:
64+
- task: CopyFiles@2
65+
displayName: move coverage files into staging area
66+
condition: succeededOrFailed()
67+
inputs:
68+
sourceFolder: $(System.DefaultWorkingDirectory)/.tox
69+
contents: |
70+
.coverage
71+
coverage.xml
72+
targetFolder: $(Build.StagingDirectory)
73+
74+
- task: PublishBuildArtifacts@1
75+
displayName: publish coverage file
76+
condition: succeededOrFailed()
77+
inputs:
78+
pathtoPublish: $(Build.ArtifactStagingDirectory)
79+
ArtifactName: ${{ format('coverage-{0}-{1}', parameters.os, parameters.tox) }}

tox.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ source = virtualenv
3535
*/virtualenv
3636
*\virtualenv
3737

38+
[testenv:coverage]
39+
description = [run locally after tests]: combine coverage data and create report;
40+
generates a diff coverage against origin/master (can be changed by setting DIFF_AGAINST env var)
41+
deps = {[testenv]deps}
42+
coverage >= 4.4.1, < 5
43+
diff_cover
44+
skip_install = True
45+
passenv = DIFF_AGAINST
46+
setenv = COVERAGE_FILE={toxworkdir}/.coverage
47+
commands = coverage erase
48+
coverage combine
49+
coverage report -m
50+
coverage xml -o {toxworkdir}/coverage.xml
51+
coverage html -d {toxworkdir}/htmlcov
52+
diff-cover --compare-branch {env:DIFF_AGAINST:origin/master} {toxworkdir}/coverage.xml
53+
3854
[testenv:cross_python2]
3955
description = test creating a python3 venv with a python2-based virtualenv
4056
basepython = python2

0 commit comments

Comments
 (0)