11parameters :
22 jobs : []
3+ tox_version : ' tox'
4+ before : []
5+ env : []
36
47jobs :
58- ${{ each job in parameters.jobs }} :
6- - job : ${{ job.key }}
9+ - job : ${{ coalesce( job.value.name, job. key) }}
710 strategy :
811 matrix :
9- ${{ each env in job.value.toxenvs }} :
10- ${{ env }} :
11- TOXENV : ${{ env }}
12- ${{ if job.value.py }} :
13- py : ${{ job.value.py }}
14- ${{ if not(job.value.py) }} :
15- ${{ if or(eq(env, 'py27'), startsWith(env, 'py27-')) }} :
16- py : ' 2.7'
17- PYTHONWARNINGS : ' ignore:::pip._internal.cli.base_command'
18- ${{ if or(eq(env, 'py34'), startsWith(env, 'py34-')) }} :
19- py : ' 3.4'
20- PYTHONWARNINGS : ' ignore:::pip._internal.cli.base_command'
21- ${{ if or(eq(env, 'py35'), startsWith(env, 'py35-')) }} :
22- py : ' 3.5'
23- ${{ if or(eq(env, 'py36'), startsWith(env, 'py36-')) }} :
24- py : ' 3.6'
25- ${{ if or(eq(env, 'py37'), startsWith(env, 'py37-')) }} :
26- py : ' 3.7'
27- ${{ if or(eq(env, 'pypy'), startsWith(env, 'pypy-')) }} :
28- py : ' pypy2'
29- PYTHONWARNINGS : ' ignore:::pip._internal.cli.base_command'
30- ${{ if or(eq(env, 'pypy3'), startsWith(env, 'pypy3-')) }} :
31- py : ' pypy3'
32- ${{ if or(eq(env, 'py38'), startsWith(env, 'py38-')) }} :
33- py : ' 3.7'
34- ispy38 : true
12+ ${{ if job.value.image }} :
13+ ${{ each image in job.value.image }} :
14+ ${{ image }} :
15+ ${{ if eq(image, 'linux') }} :
16+ image : ' Ubuntu-16.04'
17+ ${{ if eq(image, 'windows') }} :
18+ image : ' windows-2019'
19+ ${{ if eq(image, 'macOs') }} :
20+ image : ' macOS-10.14'
21+ ${{ if notIn(image, 'macOs', 'linux', 'windows') }} :
22+ image : ${{ coalesce(image, 'Ubuntu-16.04') }}
23+ ${{ if not(job.value.image) }} :
24+ linux :
25+ image : ' Ubuntu-16.04'
3526 pool :
36- ${{ if job.value.image }} :
37- vmImage : ${{ job.value.image }}
38- ${{ if not(job.value.image) }} :
39- ${{ if eq(job.key, 'linux') }} :
40- vmImage : ' Ubuntu-16.04'
41- ${{ if eq(job.key, 'windows') }} :
42- vmImage : ' windows-2019'
43- ${{ if eq(job.key, 'macOs') }} :
44- vmImage : ' macOS-10.14'
45- ${{ if notIn(job.key, 'macOs', 'linux', 'windows') }} :
46- vmImage : ' Ubuntu-16.04'
27+ vmImage : $[ variables['image'] ]
4728
4829 variables :
4930 TMPDIR : $(Build.BinariesDirectory)
5031 PIP_NO_WARN_SCRIPT_LOCATION : ' 0'
5132 PIP_DISABLE_PIP_VERSION_CHECK : ' 1'
33+ TOXENV : ${{ job.key }}
34+ PYTHONWARNINGS : ' ignore:::pip._internal.cli.base_command'
5235
5336 steps :
37+ # checkout with submodules please
38+ - checkout : self
39+ displayName : checkout source code (with submodules)
40+ submodules : true
41+
42+ # load tox
5443 - task : UsePythonVersion@0
44+ displayName : get python for tox
5545 inputs :
56- versionSpec : $(py)
57- architecture : ${{ coalesce(job.value.architecture, 'x64') }}
46+ versionSpec : ' 3.7'
47+ addToPath : false
48+ name : toxPython
49+
50+ - ${{ if parameters.tox_version }} :
51+ - script : ${{ format('$(toxPython.pythonLocation)/python -m pip install -U --user --force-reinstall {0}', parameters.tox_version) }}
52+ displayName : ${{ format('install {0} from PyPi', parameters.tox_version) }}
53+ - ${{ if not(parameters.tox_version) }} :
54+ - script : $(toxPython.pythonLocation)/python -m pip install -U --user --force-reinstall .
55+ displayName : install tox inline
5856
59- - script : |
60- sudo add-apt-repository ppa:deadsnakes
61- sudo apt-get update
62- sudo apt-get install -y --no-install-recommends python3.8-dev python3.8-distutils
63- condition: variables.ispy38
64- displayName: install python 3.8
57+ - script : $(toxPython.pythonLocation)/python -m tox --version
58+ displayName : show tox version
6559
60+ # acquire target test Python
61+ - ${{ if or(eq(job.key, 'py37'), startsWith(job.key, 'py37-'), eq(job.key, 'py36'), startsWith(job.key, 'py36-'), eq(job.key, 'py35'), startsWith(job.key, 'py35-'), eq(job.key, 'py34'), startsWith(job.key, 'py34-'), eq(job.key, 'py27'), startsWith(job.key, 'p27-'), eq(job.key, 'pypy'), startsWith(job.key, 'pypy-'), eq(job.key, 'pypy3'), startsWith(job.key, 'pypy3-'), eq(job.value.py, '2.7'), eq(job.value.py, '3.4'), eq(job.value.py, '3.5'), eq(job.value.py, '3.6'), eq(job.value.py, '3.7'), eq(job.value.py, 'pypy2'), eq(job.value.py, 'pypy3')) }} :
62+ - task : UsePythonVersion@0
63+ displayName : ${{ format('provision target test python {0}', job.key) }}
64+ inputs :
65+ ${{ if job.value.py }} :
66+ versionSpec : ${{ job.value.py }}
67+ ${{ if not(job.value.py) }} :
68+ ${{ if or(eq(job.key, 'py27'), startsWith(job.key, 'py27-')) }} :
69+ versionSpec : ' 2.7'
70+ ${{ if or(eq(job.key, 'py34'), startsWith(job.key, 'py34-')) }} :
71+ versionSpec : ' 3.4'
72+ ${{ if or(eq(job.key, 'py35'), startsWith(job.key, 'py35-')) }} :
73+ versionSpec : ' 3.5'
74+ ${{ if or(eq(job.key, 'py36'), startsWith(job.key, 'py36-')) }} :
75+ versionSpec : ' 3.6'
76+ ${{ if or(eq(job.key, 'py37'), startsWith(job.key, 'py37-')) }} :
77+ versionSpec : ' 3.7'
78+ ${{ if or(eq(job.key, 'pypy'), startsWith(job.key, 'pypy-')) }} :
79+ versionSpec : ' pypy2'
80+ ${{ if or(eq(job.key, 'pypy3'), startsWith(job.key, 'pypy3-')) }} :
81+ versionSpec : ' pypy3'
82+ architecture : ${{ coalesce(job.value.architecture, 'x64') }}
83+ - ${{ if or(eq(job.key, 'py38'), startsWith(job.key, 'py38-')) }} :
84+ - script : |
85+ sudo add-apt-repository ppa:deadsnakes
86+ sudo apt-get update
87+ sudo apt-get install -y --no-install-recommends python3.8-dev python3.8-distutils
88+ displayName: 'provision python 3.8'
89+ - ${{ if or(eq(job.key, 'jython'), startsWith(job.key, 'jython-')) }} :
90+ - script : wget http://search.maven.org/remotecontent?filepath=org/python/jython-installer/2.7.1/jython-installer-2.7.1.jar -O $(Agent.ToolsDirectory)/jython.jar
91+ displayName : download jython
92+ - script : java -jar $(Agent.ToolsDirectory)/jython.jar -sd $(Agent.ToolsDirectory)/jython -e demo src doc
93+ displayName : install jython
94+ - script : echo "##vso[task.setvariable variable=PATH]$(Agent.ToolsDirectory)/jython/bin:$(PATH)"
95+ displayName : add to PATH jython
96+ - script : ' jython -c "import sys; print(sys.version_info); print(sys.platform)'
97+ displayName : show jython information
6698 - script : ' python -c "import sys; print(sys.version); print(sys.executable);"'
6799 displayName : show python information
68100
69- - script : " python -m pip install -U --user --force-reinstall tox"
70- displayName : install tox
101+ # allow user to plugin further improvements
102+ - ${{ if job.value.before }} :
103+ - ${{ job.value.before }}
71104
72- - script : ' python -m tox --notest -vv --skip-missing-interpreters false'
105+ # run tests
106+ - script : ' $(toxPython.pythonLocation)/python -m tox --notest -vv --skip-missing-interpreters false'
73107 displayName : generate tox test environment
74-
75- - script : ' python -m tox'
108+ - script : ' $(toxPython.pythonLocation)/python -m tox'
76109 displayName : run tox test environment
77110
111+ # upload junit result if present
78112 - bash : ' printf "##vso[task.setVariable variable=junit]" && ([ -f junit.$(TOXENV).xml ] && printf yes || printf no) && echo ""'
79113 condition : always()
80114 displayName : check if junit file present
81115 workingDirectory : ' $(System.DefaultWorkingDirectory)/.tox'
82-
83116 - task : PublishTestResults@2
84117 displayName : publish test results via junit
85118 condition : eq(variables.junit, 'yes')
@@ -88,15 +121,14 @@ jobs:
88121 testResultsFiles : ' .tox/junit.$(TOXENV).xml'
89122 testRunTitle : ' junit-$(Agent.OS)-$(Agent.OSArchitecture)-$(TOXENV)'
90123
124+ # upload coverage artifacts if present
91125 - ${{ if job.value.coverage }} :
92- - script : ${{ format('python -m tox -e {0}', job.value.coverage) }}
126+ - script : ${{ format('$(toxPython.pythonLocation)/ python -m tox -e {0}', job.value.coverage) }}
93127 displayName : create coverag report
94-
95128 - bash : ' printf "##vso[task.setVariable variable=coverage]" && ([ -f coverage.xml -o -f .coverage ] && printf yes || printf no) && echo ""'
96129 displayName : check if coverage file present
97130 condition : always()
98131 workingDirectory : ' $(System.DefaultWorkingDirectory)/.tox'
99-
100132 - task : CopyFiles@2
101133 displayName : move coverage files into staging area
102134 condition : eq(variables.coverage, 'yes')
@@ -106,7 +138,6 @@ jobs:
106138 .coverage
107139 coverage.xml
108140 targetFolder : $(Build.StagingDirectory)
109-
110141 - task : PublishBuildArtifacts@1
111142 displayName : publish coverage file
112143 condition : eq(variables.coverage, 'yes')
0 commit comments