forked from matplotlib/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
186 lines (170 loc) · 6.85 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# Python package
# Create and test a Python package on multiple Python versions.
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and
# more:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python?view=azure-devops
---
trigger:
branches:
exclude:
- v*-doc
pr:
branches:
exclude:
- v*-doc
paths:
exclude:
- doc/**/*
- galleries/**/*
stages:
- stage: Check
jobs:
- job: Skip
pool:
vmImage: 'ubuntu-latest'
variables:
DECODE_PERCENTS: 'false'
RET: 'true'
steps:
- bash: |
git_log=`git log --max-count=1 --skip=1 --pretty=format:"%B" | tr "\n" " "`
echo "##vso[task.setvariable variable=log]$git_log"
- bash: echo "##vso[task.setvariable variable=RET]false"
condition: >-
or(contains(variables.log, '[skip azp]'),
contains(variables.log, '[azp skip]'),
contains(variables.log, '[skip ci]'),
contains(variables.log, '[ci skip]'),
contains(variables.log, '[ci doc]'))
- bash: echo "##vso[task.setvariable variable=start_main;isOutput=true]$RET"
name: result
- stage: Main
condition: and(succeeded(), eq(dependencies.Check.outputs['Skip.result.start_main'], 'true'))
dependsOn: Check
jobs:
- job: Pytest
strategy:
matrix:
Windows_py310:
vmImage: 'windows-2019' # keep one job pinned to the oldest image
python.version: '3.10'
Windows_py311:
vmImage: 'windows-latest'
python.version: '3.11'
maxParallel: 4
pool:
vmImage: '$(vmImage)'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'
displayName: 'Use Python $(python.version)'
- bash: |
choco install ninja
displayName: 'Install dependencies'
- bash: |
python -m pip install --upgrade pip
python -m pip install --upgrade -r requirements/dev/build-requirements.txt
python -m pip install -r requirements/testing/all.txt -r requirements/testing/extra.txt
displayName: 'Install dependencies with pip'
- bash: |
CONFIG='--config-settings=setup-args=--vsenv'
CONFIG="$CONFIG --config-settings=setup-args=-Dcpp_link_args=-PROFILE"
CONFIG="$CONFIG --config-settings=setup-args=-Dbuildtype=debug"
python -m pip install \
--no-build-isolation $CONFIG \
--verbose --editable .[dev]
displayName: "Install self"
- script: env
displayName: 'print env'
- script: pip list
displayName: 'print pip'
- bash: |
set -e
SESSION_ID=$(python -c "import uuid; print(uuid.uuid4(), end='')")
echo "Coverage session ID: ${SESSION_ID}"
VS=$(ls -d /c/Program\ Files*/Microsoft\ Visual\ Studio/*/Enterprise)
echo "Visual Studio: ${VS}"
DIR="$VS/Common7/IDE/Extensions/Microsoft/CodeCoverage.Console"
if [[ -d $DIR ]]; then
# This is for MSVC 2022 (on windows-latest).
TOOL="$DIR/Microsoft.CodeCoverage.Console.exe"
for f in build/cp*/src/*.pyd; do
echo $f
echo "=============================="
"$TOOL" instrument $f --session-id $SESSION_ID \
--log-level Verbose --log-file instrument.log
cat instrument.log
rm instrument.log
done
echo "Starting $TOOL in server mode"
"$TOOL" collect \
--session-id $SESSION_ID --server-mode \
--output-format cobertura --output extensions.xml \
--log-level Verbose --log-file extensions.log &
VS_VER=2022
else
DIR="$VS"/Team\ Tools/Dynamic\ Code\ Coverage\ Tools/amd64
if [[ -d $DIR ]]; then
# This is for MSVC 2019 (on windows-2019).
VSINSTR="$VS"/Team\ Tools/Performance\ Tools/vsinstr.exe
for f in build/cp*/src/*.pyd; do
"$VSINSTR" $f -Verbose -Coverage
done
TOOL="$DIR/CodeCoverage.exe"
cat > extensions.config << EOF
<CodeCoverage>
<CollectFromChildProcesses>true</CollectFromChildProcesses>
<ModulePaths>
<Include>
<ModulePath>.*\\.*\.pyd</ModulePath>
</Include>
</ModulePaths>
</CodeCoverage>
EOF
echo "Starting $TOOL in server mode"
"$TOOL" collect \
-config:extensions.config -session:$SESSION_ID \
-output:extensions.coverage -verbose &
echo "Started $TOOL"
VS_VER=2019
fi
fi
echo "##vso[task.setvariable variable=VS_COVERAGE_TOOL]$TOOL"
PYTHONFAULTHANDLER=1 pytest -rfEsXR -n 2 \
--maxfail=50 --timeout=300 --durations=25 \
--junitxml=junit/test-results.xml --cov-report=xml --cov=lib
if [[ $VS_VER == 2022 ]]; then
"$TOOL" shutdown $SESSION_ID
echo "Coverage collection log"
echo "======================="
cat extensions.log
else
"$TOOL" shutdown -session:$SESSION_ID
fi
displayName: 'pytest'
- bash: |
if [[ -f extensions.coverage ]]; then
# For MSVC 2019.
"$VS_COVERAGE_TOOL" analyze -output:extensions.xml \
-include_skipped_functions -include_skipped_modules \
extensions.coverage
rm extensions.coverage
fi
displayName: 'Filter C coverage'
condition: succeededOrFailed()
- bash: |
bash <(curl -s https://codecov.io/bash) \
-n "$PYTHON_VERSION $AGENT_OS" \
-f 'coverage.xml' -f 'extensions.xml'
displayName: 'Upload to codecov.io'
condition: succeededOrFailed()
- task: PublishTestResults@2
inputs:
testResultsFiles: '**/test-results.xml'
testRunTitle: 'Python $(python.version)'
condition: succeededOrFailed()
- publish: $(System.DefaultWorkingDirectory)/result_images
artifact: $(Agent.JobName)-result_images
condition: failed()