Skip to content

Commit 083bd04

Browse files
committed
Add azure pipeline config files and templates
* Create configure.bat so we can use our skeleton for Windows projects Signed-off-by: Jono Yang <jyang@nexb.com>
1 parent ad02f4e commit 083bd04

6 files changed

Lines changed: 316 additions & 2 deletions

File tree

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This is a skeleton Travis CI config file that provides a starting point for adding CI
22
# to a Python project. Since we primarily develop in python3, this skeleton config file
3-
# will be specific to that language.
3+
# will be specific to that language.
44
#
55
# See https://config.travis-ci.com/ for a full list of configuration options.
66

@@ -18,4 +18,4 @@ python:
1818
install: ./configure
1919

2020
# Scripts to run at script stage
21-
script: bin/pytest
21+
script: tmp/bin/pytest

azure-pipelines.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
################################################################################
3+
# We use Azure to run the full tests suites on Python 3.6
4+
# on Windows (32 and 64), macOS and Linux (64 various distro)
5+
################################################################################
6+
7+
jobs:
8+
9+
################################################################################
10+
# These jobs are using VMs and Azure-provided Python 3.6
11+
################################################################################
12+
13+
- template: etc/ci/azure-linux.yml
14+
parameters:
15+
job_name: vm_ubuntu16_py36
16+
image_name: ubuntu-16.04
17+
python_versions: ['3.6']
18+
test_suites:
19+
all: bin/py.test -n 2 -vvs --reruns=3
20+
21+
- template: etc/ci/azure-mac.yml
22+
parameters:
23+
job_name: macos1015_py36
24+
image_name: macos-10.15
25+
python_versions: ['3.6']
26+
test_suites:
27+
all: bin/py.test -n 2 -vvs --reruns=3
28+
29+
- template: etc/ci/azure-win.yml
30+
parameters:
31+
job_name: Win2016_32_py36
32+
image_name: vs2017-win2016
33+
python_versions: ['3.6']
34+
python_architecture: x86
35+
test_suites:
36+
all: Scripts\py.test -vvs --reruns=3
37+
38+
- template: etc/ci/azure-win.yml
39+
parameters:
40+
job_name: Win2016_64_py36
41+
image_name: vs2017-win2016
42+
python_versions: ['3.6']
43+
python_architecture: x64
44+
test_suites:
45+
misc: Scripts\py.test -vvs --reruns=3

configure.bat

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
@echo OFF
2+
@setlocal
3+
@rem Copyright (c) nexB Inc. http://www.nexb.com/ - All rights reserved.
4+
5+
@rem ################################
6+
@rem # A configuration script for Windows
7+
@rem #
8+
@rem # The options and (optional) arguments are:
9+
@rem # --clean : this is exclusive of anything else and cleans the environment
10+
@rem # from built and installed files
11+
@rem #
12+
@rem # --python < path to python.exe> : this must be the first argument and set
13+
@rem # the path to the Python executable to use. If < path to python.exe> is
14+
@rem # set to "path", then the executable will be the python.exe available
15+
@rem # in the PATH.
16+
@rem #
17+
@rem # <some conf path> : this must be the last argument and sets the path to a
18+
@rem # configuration directory to use.
19+
@rem ################################
20+
21+
@rem ################################
22+
@rem # Defaults. Change these variables to customize this script locally
23+
@rem ################################
24+
@rem # you can define one or more thirdparty dirs, each where the varibale name
25+
@rem # is prefixed with TPP_DIR
26+
set "TPP_DIR=thirdparty"
27+
28+
@rem # default configurations for dev
29+
set "CONF_DEFAULT=etc/conf/dev"
30+
31+
@rem # default thirdparty dist for dev
32+
if ""%CONF_DEFAULT%""==""etc/conf/dev"" (
33+
set "TPP_DIR_DEV=thirdparty/dev"
34+
)
35+
36+
@rem # default supported version for Python 3
37+
set SUPPORTED_PYTHON3=3.6
38+
39+
@rem #################################
40+
41+
@rem python --version
42+
@rem python -c "import sys;print(sys.executable)"
43+
44+
45+
@rem Current directory where this .bat files lives
46+
set CFG_ROOT_DIR=%~dp0
47+
48+
@rem path where a configured Python should live in the current virtualenv if installed
49+
set CONFIGURED_PYTHON=%CFG_ROOT_DIR%Scripts\python.exe
50+
51+
set PYTHON_EXECUTABLE=
52+
53+
@rem parse command line options and arguments
54+
:collectopts
55+
if "%1" EQU "--help" (goto cli_help)
56+
if "%1" EQU "--clean" (call rmdir /s /q "%CFG_ROOT_DIR%tmp") && call exit /b
57+
if "%1" EQU "--python" (set PROVIDED_PYTHON=%~2) && shift && shift && goto collectopts
58+
59+
@rem We are not cleaning: Either we have a provided configure config path or we use a default.
60+
if ""%1""=="""" (
61+
set CFG_CMD_LINE_ARGS=%CONF_DEFAULT%
62+
) else (
63+
set CFG_CMD_LINE_ARGS=%1
64+
)
65+
66+
@rem If we have a pre-configured Python in our virtualenv, reuse this as-is and run
67+
if exist ""%CONFIGURED_PYTHON%"" (
68+
set PYTHON_EXECUTABLE=%CONFIGURED_PYTHON%
69+
goto run
70+
)
71+
72+
@rem If we have a command arg for Python use this as-is
73+
if ""%PROVIDED_PYTHON%""==""path"" (
74+
@rem use a bare python available in the PATH
75+
set PYTHON_EXECUTABLE=python
76+
goto run
77+
)
78+
if exist ""%PROVIDED_PYTHON%"" (
79+
set PYTHON_EXECUTABLE=%PROVIDED_PYTHON%
80+
goto run
81+
)
82+
83+
84+
@rem otherwise we search for a suitable Python interpreter
85+
:find_python
86+
87+
@rem First check the existence of the "py" launcher (available in Python 3)
88+
@rem if we have it, check if we have a py -3 installed with the good version or a py 2.7
89+
@rem if not, check if we have an old py 2.7
90+
@rem exist if all fails
91+
92+
where py >nul 2>nul
93+
if %ERRORLEVEL% == 0 (
94+
@rem we have a py launcher, check for the availability of our required Python 3 version
95+
py -3.6 --version >nul 2>nul
96+
if %ERRORLEVEL% == 0 (
97+
set PYTHON_EXECUTABLE=py -3.6
98+
) else (
99+
@rem we have no required python 3, let's try python 2:
100+
py -2 --version >nul 2>nul
101+
if %ERRORLEVEL% == 0 (
102+
set PYTHON_EXECUTABLE=py -2
103+
) else (
104+
@rem we have py and no python 3 and 2, exit
105+
echo * Unable to find an installation of Python.
106+
exit /b 1
107+
)
108+
)
109+
) else (
110+
@rem we have no py launcher, check for a default Python 2 installation
111+
if not exist ""%DEFAULT_PYTHON2%"" (
112+
echo * Unable to find an installation of Python.
113+
exit /b 1
114+
) else (
115+
set PYTHON_EXECUTABLE=%DEFAULT_PYTHON2%
116+
)
117+
)
118+
119+
:run
120+
121+
@rem without this things may not always work on Windows 10, but this makes things slower
122+
set PYTHONDONTWRITEBYTECODE=1
123+
124+
call mkdir "%CFG_ROOT_DIR%tmp"
125+
call curl -o "%CFG_ROOT_DIR%tmp\virtualenv.pyz" https://bootstrap.pypa.io/virtualenv.pyz
126+
call %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%tmp\virtualenv.pyz" "%CFG_ROOT_DIR%tmp"
127+
call "%CFG_ROOT_DIR%tmp\Scripts\activate"
128+
call "%CFG_ROOT_DIR%tmp\Scripts\pip" install --upgrade pip virtualenv setuptools wheel
129+
130+
131+
@rem Return a proper return code on failure
132+
if %ERRORLEVEL% neq 0 (
133+
exit /b %ERRORLEVEL%
134+
)
135+
endlocal
136+
goto activate
137+
138+
139+
:cli_help
140+
echo A configuration script for Windows
141+
echo usage: configure [options] [path/to/config/directory]
142+
echo.
143+
echo The options and arguments are:
144+
echo [path/to/config/directory] : this optionally sets the path to a
145+
echo configuration directory to use. Defaults to etc/conf/dev if not set
146+
echo.
147+
echo --clean : this is exclusive of anything else and cleans the environment
148+
echo from built and installed files
149+
echo.
150+
echo --python path/to/python.exe : this is set to the path of an alternative
151+
echo Python executable to use. If path/to/python.exe is set to "path",
152+
echo then the executable will be the python.exe available in the PATH.
153+
echo.
154+
155+
156+
:activate
157+
@rem Activate the virtualenv
158+
if exist "%CFG_ROOT_DIR%Scripts\activate" (
159+
"%CFG_ROOT_DIR%Scripts\activate"
160+
)

etc/ci/azure-linux.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
parameters:
2+
job_name: ''
3+
image_name: 'ubuntu-16.04'
4+
python_versions: []
5+
test_suites: {}
6+
python_architecture: x64
7+
8+
jobs:
9+
- job: ${{ parameters.job_name }}
10+
11+
pool:
12+
vmImage: ${{ parameters.image_name }}
13+
14+
strategy:
15+
matrix:
16+
${{ each pyver in parameters.python_versions }}:
17+
${{ each tsuite in parameters.test_suites }}:
18+
${{ format('py{0} {1}', pyver, tsuite.key) }}:
19+
python_version: ${{ pyver }}
20+
test_suite_label: ${{ tsuite.key }}
21+
test_suite: ${{ tsuite.value }}
22+
23+
steps:
24+
- checkout: self
25+
fetchDepth: 10
26+
27+
- task: UsePythonVersion@0
28+
inputs:
29+
versionSpec: '$(python_version)'
30+
architecture: '${{ parameters.python_architecture }}'
31+
displayName: 'Install Python $(python_version)'
32+
33+
- script: ./configure
34+
displayName: 'Run Configure'
35+
36+
- script: $(test_suite)
37+
displayName: 'Run $(test_suite_label) tests with py$(python_version) on ${{ parameters.job_name }}'

etc/ci/azure-mac.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
parameters:
2+
job_name: ''
3+
image_name: ''
4+
python_versions: []
5+
test_suites: {}
6+
python_architecture: x64
7+
8+
jobs:
9+
- job: ${{ parameters.job_name }}
10+
11+
pool:
12+
vmImage: ${{ parameters.image_name }}
13+
14+
strategy:
15+
matrix:
16+
${{ each pyver in parameters.python_versions }}:
17+
${{ each tsuite in parameters.test_suites }}:
18+
${{ format('py{0} {1}', pyver, tsuite.key) }}:
19+
python_version: ${{ pyver }}
20+
test_suite_label: ${{ tsuite.key }}
21+
test_suite: ${{ tsuite.value }}
22+
steps:
23+
- checkout: self
24+
fetchDepth: 10
25+
26+
- task: UsePythonVersion@0
27+
inputs:
28+
versionSpec: '$(python_version)'
29+
architecture: '${{ parameters.python_architecture }}'
30+
displayName: 'Install Python $(python_version)'
31+
32+
- script: ./configure
33+
displayName: 'Run Configure'
34+
35+
- script: $(test_suite)
36+
displayName: 'Run $(test_suite_label) tests with py$(python_version) on ${{ parameters.job_name }}'

etc/ci/azure-win.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
parameters:
2+
job_name: ''
3+
image_name: ''
4+
python_versions: []
5+
test_suites: {}
6+
python_architecture: x86
7+
8+
jobs:
9+
- job: ${{ parameters.job_name }}
10+
11+
pool:
12+
vmImage: ${{ parameters.image_name }}
13+
14+
strategy:
15+
matrix:
16+
${{ each pyver in parameters.python_versions }}:
17+
${{ each tsuite in parameters.test_suites }}:
18+
${{ format('py{0} {1}', pyver, tsuite.key) }}:
19+
python_version: ${{ pyver }}
20+
test_suite_label: ${{ tsuite.key }}
21+
test_suite: ${{ tsuite.value }}
22+
steps:
23+
- checkout: self
24+
fetchDepth: 10
25+
26+
- task: UsePythonVersion@0
27+
inputs:
28+
versionSpec: '$(python_version)'
29+
architecture: '${{ parameters.python_architecture }}'
30+
displayName: 'Install Python $(python_version)'
31+
32+
- script: configure --python path
33+
displayName: 'Run Configure'
34+
35+
- script: $(test_suite)
36+
displayName: 'Run $(test_suite_label) tests with py$(python_version) on ${{ parameters.job_name }}'

0 commit comments

Comments
 (0)