-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
145 lines (123 loc) · 4.19 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
trigger:
- master
variables:
# Primary virtual environment used for poetry.
# Also made available to .azure-pipelines/scripts/python.py to resolve to the correct
# Python.
venv: .poetry
app_venv: .venv
jobs:
- job: Pipeline
strategy:
matrix:
linux:
python.version: '3.7'
imageName: 'ubuntu-16.04'
windows:
python.version: '3.7'
imageName: 'vs2017-win2016'
maxParallel: 4
pool:
vmImage: $(imageName)
steps:
# Arbitrary cache key properties.
- bash: |
echo '
python_version=$(python.version)
os=$(Agent.OS)
' > buildinfo.txt
displayName: 'Create CI properties file'
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'
- task: 1ESLighthouseEng.PipelineArtifactCaching.RestoreCacheV1.RestoreCache@1
displayName: 'PyPI Cache Restore'
inputs:
keyfile: 'poetry.lock, buildinfo.txt'
targetfolder: '$(app_venv), $(venv)'
vstsFeed: '$(CacheArtifactFeedId)'
# venv is idempotent - no issues if cache has been restored
- script: python -m venv $(venv)
displayName: Make Poetry venv
- task: PythonScript@0
displayName: Setup Poetry 1
inputs:
scriptPath: .azure-pipelines/scripts/python.py
arguments: -m pip install --upgrade pip
- task: PythonScript@0
displayName: Setup Poetry 2
inputs:
scriptPath: .azure-pipelines/scripts/python.py
arguments: -m pip install --upgrade poetry
- task: PythonScript@0
displayName: Configure Poetry 1
inputs:
scriptPath: .azure-pipelines/scripts/python.py
arguments: -m poetry config settings.virtualenvs.in-project true
- task: PythonScript@0
displayName: Configure Poetry 2
inputs:
scriptPath: .azure-pipelines/scripts/python.py
arguments: -m poetry config settings.virtualenvs.path $(app_venv)
# Letting Python install the virtual environment works around an issue
# seen where ensurepip fails when poetry executes the installation.
- script: python -m venv $(app_venv)
displayName: Make app venv
- task: PythonScript@0
displayName: Install/update dependencies
inputs:
scriptPath: .azure-pipelines/scripts/python.py
arguments: -m poetry install
# If dependency resolution succeeded, cache.
- task: 1ESLighthouseEng.PipelineArtifactCaching.SaveCacheV1.SaveCache@1
displayName: 'PyPI Cache Save'
inputs:
keyfile: 'poetry.lock, buildinfo.txt'
targetfolder: '$(app_venv), $(venv)'
vstsFeed: '$(CacheArtifactFeedId)'
- script: |
sudo apt update
sudo apt install -y gdb
# Allow process tracing for same uid.
# TODO: prctl(PR_SET_PTRACER, <pid>)
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
displayName: Install debugging tools
condition: eq(variables['Agent.OS'], 'Linux')
- task: PythonScript@0
displayName: Run tests
inputs:
scriptPath: .azure-pipelines/scripts/python.py
arguments: -m poetry run python -m pytest -ra --junitxml=junit/test-results.xml tests
- task: PublishTestResults@2
inputs:
testResultsFiles: '**/test-results.xml'
testRunTitle: 'Python $(python.version) $(Agent.OS)'
condition: succeededOrFailed()
displayName: Publish test results
# In lieu of getting logs as attachments on the test summary, we
# publish as artifacts.
- task: PublishPipelineArtifact@0
inputs:
artifactName: 'test_logs_$(python.version)_$(Agent.OS)'
targetPath: logs/
condition: succeededOrFailed()
displayName: Publish logs
- task: PythonScript@0
displayName: Linting
inputs:
scriptPath: .azure-pipelines/scripts/python.py
arguments: -m poetry run black --check --diff quicken tests
# Avoid hanging on Windows, we only need one platform anyway. See
# buildId 169.
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
- task: PythonScript@0
displayName: Build
inputs:
scriptPath: .azure-pipelines/scripts/python.py
arguments: -m poetry build
- task: PublishPipelineArtifact@0
inputs:
artifactName: 'artifacts_$(python.version)_$(Agent.OS)'
targetPath: dist/
displayName: Publish artifacts