Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Commit 1c29bdc

Browse files
committed
add jython support
1 parent cd3852e commit 1c29bdc

File tree

3 files changed

+99
-62
lines changed

3 files changed

+99
-62
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,13 @@ jobs:
7474

7575
### parameters
7676

77-
At root level has a single ``jobs`` key. Inside this you can enlist groups of targets as maps.
77+
At root level you can control with `tox_version` the tox version specifier to install, this defaults to latest in PyPi
78+
(`tox`). Beside this at the root level we have the ``jobs`` key. Inside this you can enlist groups of targets as maps.
7879
The key is the name of the group. The values configure the target:
7980

8081
- `toxenvs`: the list of `tox` environment names to run; must either:
81-
- be equal to: `py27`, `py34`, `py35`, `py36`, `py37`, `py38`
82-
- start with: `py27-`, `py34-`, `py35-`, `py36-`, `py37-`, `py38-`
82+
- be equal to: `py27`, `py34`, `py35`, `py36`, `py37`, `py38`, `jython`, `pypy`, `pypy3`
83+
- start with: `py27-`, `py34-`, `py35-`, `py36-`, `py37-`, `py38-`, `jython-`, `pypy-`, `pypy3`
8384

8485
- `image`: specify the Azure pipelines image to use (determines the OS target); if not specified
8586
we'll use the groups key name to assign one:
@@ -89,9 +90,12 @@ The key is the name of the group. The values configure the target:
8990
- otherwise `Ubuntu-16.04`
9091
- `architecture`: either `x64` or `x86`) with default `x64` (only affects windows)
9192
- `coverage`: if set after running the test suite tox will run this tox target to generate a coverage report.
93+
- `before` steps to be run before invoking the tox environment (useful to provision additional dependencies).
9294

93-
Note: for now, `python3.8` is only available on linux -- it is installed from
95+
Note, for now:
96+
- `python3.8` is only available on linux -- it is installed from
9497
[deadsnakes](https://github.com/deadsnakes).
98+
- `jython` is available from under Linux and MacOs.
9599

96100
## `merge-coverage.yml`
97101

@@ -113,7 +117,8 @@ to the Azure Pipelines coverage report.
113117

114118
### parameters
115119
- `coverage` - tox target that generates the unified coverage report (default `coverage`)
116-
- `dependsOn` - environments this job depends on
120+
- `dependsOn` - environments this job depends on
121+
- `tox_version` - the tox version specifier to use, defaults to latest
117122

118123
## `publish-pypi.yml`
119124

merge-coverage.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
parameters:
22
dependsOn: []
33
coverage: 'coverage'
4+
tox_version: 'tox'
45

56
jobs:
67
- job: report_coverage
@@ -39,7 +40,7 @@ jobs:
3940
shutil.copy(str(coverage_file), str(destination))'
4041
displayName: move coverage files into .tox
4142
42-
- script: "python -m pip install -U --user --force-reinstall tox"
43+
- script: ${{ format('python -m pip install -U --user --force-reinstall {0}', parameters.tox_version) }}
4344
displayName: install tox
4445

4546
- script: 'python -m tox -e py -vv --sdistonly'

run-tox-env.yml

Lines changed: 87 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,118 @@
11
parameters:
22
jobs: []
3+
tox_version: 'tox'
4+
before: []
5+
env: []
36

47
jobs:
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

Comments
 (0)