-
Notifications
You must be signed in to change notification settings - Fork 51
/
azure-pipelines.yml
148 lines (128 loc) · 4.9 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
# Trigger a build when there is a push to the main branch or a tag starts with release-
trigger:
branches:
include:
- main
tags:
include:
- release-*
# Trigger a build when there is a pull request to the main branch
# Ignore PRs that are just updating the docs
pr:
branches:
include:
- main
exclude:
- doc/*
- README.rst
variables:
triggeredByPullRequest: $[eq(variables['Build.Reason'], 'PullRequest')]
stages:
- stage: RunAllTests
displayName: Run test suite
jobs:
- job: run_platform_tests
strategy:
matrix:
# mac_py39:
# imageName: 'macOS-latest'
# python.version: '3.9'
# linux_py39:
# imageName: 'ubuntu-latest'
# python.version: '3.9'
# windows_py39:
# imageName: 'windows-latest'
# python.version: '3.9'
# mac_py310:
# imageName: 'macOS-latest'
# python.version: '3.10'
linux_py310:
imageName: 'ubuntu-latest'
python.version: '3.10'
# windows_py310:
# imageName: 'windows-latest'
# python.version: '3.10'
# mac_py311:
# imageName: 'macOS-latest'
# python.version: '3.11'
# linux_py311:
# imageName: 'ubuntu-latest'
# python.version: '3.11'
# windows_py311:
# imageName: 'windows-latest'
# python.version: '3.11'
pool:
vmImage: $(imageName)
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'
- script: |
python -m pip install --upgrade pip
displayName: 'Install dependencies'
- script: |
pip install -e .
pip install dask[dataframe]
pip install pytest pytest-azurepipelines
pip install pytest-cov
pip install coveralls
displayName: 'Install package'
- script: |
pytest datamapplot/tests --show-capture=no -v --disable-warnings --junitxml=junit/test-results.xml --cov=datamapplot/ --cov-report=xml --cov-report=html
displayName: 'Run tests'
# There are currently no tests so we don't actually need to publish results
# - bash: |
# coveralls
# displayName: 'Publish to coveralls'
# condition: and(succeeded(), eq(variables.triggeredByPullRequest, false)) # Don't run this for PRs because they can't access pipeline secrets
# env:
# COVERALLS_REPO_TOKEN: $(COVERALLS_TOKEN)
# - task: PublishTestResults@2
# inputs:
# testResultsFiles: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
# testRunTitle: '$(Agent.OS) - $(Build.BuildNumber)[$(Agent.JobName)] - Python $(python.version)'
# condition: succeededOrFailed()
- stage: BuildPublishArtifact
dependsOn: RunAllTests
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/release-'), eq(variables.triggeredByPullRequest, false))
jobs:
- job: BuildArtifacts
displayName: Build source dists and wheels
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.10'
displayName: 'Use Python 3.10'
- script: |
python -m pip install --upgrade pip
pip install wheel
displayName: 'Install dependencies'
- script: |
pip install -e .
displayName: 'Install package locally'
- script: |
python setup.py sdist bdist_wheel
displayName: 'Build package'
- bash: |
export PACKAGE_VERSION="$(python setup.py --version)"
echo "Package Version: ${PACKAGE_VERSION}"
echo "##vso[task.setvariable variable=packageVersionFormatted;]release-${PACKAGE_VERSION}"
displayName: 'Get package version'
- script: |
echo "Version in git tag $(Build.SourceBranchName) does not match version derived from setup.py $(packageVersionFormatted)"
exit 1
displayName: Raise error if version doesnt match tag
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], variables['packageVersionFormatted']))
- task: DownloadSecureFile@1
name: PYPIRC_CONFIG
displayName: 'Download pypirc'
inputs:
secureFile: 'pypirc'
- script: |
pip install twine
twine upload --repository pypi --config-file $(PYPIRC_CONFIG.secureFilePath) dist/*
displayName: 'Upload to PyPI'
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], variables['packageVersionFormatted']))