forked from py-why/EconML
-
Notifications
You must be signed in to change notification settings - Fork 2
/
azure-pipelines.yml
148 lines (133 loc) · 5.05 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
# 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/azure/devops/pipelines/languages/python
trigger:
- master
variables:
runAllTests: 'true'
jobs:
- job: 'EvalChanges'
displayName: 'Analyze changed files to determine which job to run'
steps:
# We want to enforce the following rules for PRs:
# * if all modifications are to README.md
# no testing is needed
# * if there are modifications to docs/* or to any code
# then docs need to be built to verify consistency
# * if there are modifications to notebooks/* or to any code
# then notebooks need to be run to verify consistency
# * for any code changes (or changes to metadata files)
# linting and testing should be run
# For a PR build, HEAD will be the merge commit, and we want to diff against the base branch,
# which will be the first parent: HEAD^
# (For non-PR changes, we will always perform all CI tasks)
- powershell: |
if ($env:BUILD_REASON -eq 'PullRequest') {
$editedFiles = git diff HEAD^ --name-only
$editedFiles # echo edited files to enable easier debugging
$codeChanges = $false
$docChanges = $false
$nbChanges = $false
$changeType = "none"
foreach ($file in $editedFiles) {
switch -Wildcard ($file) {
"README.md" { Continue }
"doc/*" { $docChanges = $true; Continue }
"notebooks/*" { $nbChanges = $true; Continue }
default { $codeChanges = $true; Continue }
}
}
}
Write-Host "##vso[task.setvariable variable=buildDocs;isOutput=true]$(($env:BUILD_REASON -ne 'PullRequest') -or ($docChanges -or $codeChanges))"
Write-Host "##vso[task.setvariable variable=buildNbs;isOutput=true]$(($env:BUILD_REASON -ne 'PullRequest') -or ($nbChanges -or $codeChanges))"
Write-Host "##vso[task.setvariable variable=testCode;isOutput=true]$(($env:BUILD_REASON -ne 'PullRequest') -or $codeChanges)"
name: output
displayName: 'Determine type of code change'
- job: 'Docs'
displayName: 'Build documentation'
dependsOn: 'EvalChanges'
condition: eq(dependencies.EvalChanges.outputs['output.buildDocs'], 'True')
variables:
python.version: '3.6'
steps:
- template: azure-pipelines-steps.yml
parameters:
body:
- script: 'python setup.py build_sphinx -W'
displayName: 'Build documentation'
- job: 'Notebooks'
dependsOn: 'EvalChanges'
condition: eq(dependencies.EvalChanges.outputs['output.buildNbs'], 'True')
variables:
python.version: '3.6'
steps:
- template: azure-pipelines-steps.yml
parameters:
body:
# Set mark to test only notebooks
- powershell: |
Write-Host '##vso[task.setvariable variable=PYTEST_ADDOPTS]-m "notebook"'
displayName: 'Define marker for notebook tests'
- script: 'python setup.py pytest'
displayName: 'Unit tests'
- task: PublishTestResults@2
displayName: 'Publish Test Results **/test-results.xml'
inputs:
testResultsFiles: '**/test-results.xml'
testRunTitle: 'Notebooks'
condition: succeededOrFailed()
- job: 'Tests'
dependsOn: 'EvalChanges'
condition: eq(dependencies.EvalChanges.outputs['output.testCode'], 'True')
strategy:
matrix:
Linux, Python 3.5:
imageName: 'ubuntu-16.04'
python.version: '3.5'
macOS, Python 3.5:
imageName: 'macOS-10.13'
python.version: '3.5'
Windows, Python 3.5:
imageName: 'vs2017-win2016'
python.version: '3.5'
Linux, Python 3.6:
imageName: 'ubuntu-16.04'
python.version: '3.6'
macOS, Python 3.6:
imageName: 'macOS-10.13'
python.version: '3.6'
Windows, Python 3.6:
imageName: 'vs2017-win2016'
python.version: '3.6'
Linux, Python 3.7:
imageName: 'ubuntu-16.04'
python.version: '3.7'
macOS, Python 3.7:
imageName: 'macOS-10.13'
python.version: '3.7'
Windows, Python 3.7:
imageName: 'vs2017-win2016'
python.version: '3.7'
pool:
vmImage: $(imageName)
displayName: 'Run tests '
steps:
- template: azure-pipelines-steps.yml
parameters:
body:
- script: 'pip install pycodestyle && pycodestyle econml'
failOnStderr: true
displayName: Linting
# Set mark to exclude notebook tests
- powershell: |
Write-Host '##vso[task.setvariable variable=PYTEST_ADDOPTS]-m "not notebook"'
displayName: 'Define marker to skip notebook tests'
- script: 'python setup.py pytest'
displayName: 'Unit tests'
- task: PublishTestResults@2
displayName: 'Publish Test Results **/test-results.xml'
inputs:
testResultsFiles: '**/test-results.xml'
testRunTitle: 'Python $(python.version), image $(imageName)'
condition: succeededOrFailed()