This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathci-build.yml
126 lines (118 loc) · 4 KB
/
ci-build.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
name: $(date:yyyyMMdd)$(rev:rr)
trigger:
branches:
include:
- master
paths:
include:
- arcus/*
- tests/*
- requirements.txt
pr:
paths:
include:
- arcus/*
- tests/*
- build/ci-build.yml
- requirements.txt
resources:
repositories:
- repository: templates
type: github
name: arcus-azure/azure-devops-templates
endpoint: arcus-azure
variables:
- template: ./variables/build.yml
pool:
vmImage: $(Vm.Image)
stages:
- stage: Build
jobs:
- job: DefineVersion
displayName: 'Define version number'
steps:
- template: 'pypi/determine-pr-version.yml@templates'
parameters:
manualTriggerVersion: preview
- task: UsePythonVersion@0
inputs:
versionSpec: $(Python.Version)
addToPath: true
- task: Bash@3
displayName: 'Update version number'
inputs:
targetType: 'inline'
script: 'sed -i ''s/1.0.0/$(Package.Version).$(Build.BuildNumber)/g'' arcus/ml/__init__.py'
failOnStderr: true
- task: CopyFiles@2
displayName: 'Copy build artifacts'
inputs:
contents: '**/*.py'
targetFolder: '$(Pipeline.Workspace)/build'
- task: PublishPipelineArtifact@0
displayName: 'Publish build artifacts'
inputs:
targetPath: '$(Pipeline.Workspace)/build'
artifactName: Build
- stage: UnitTests
displayName: Unit Tests
dependsOn: Build
condition: succeeded()
jobs:
- job: UnitTests
displayName: 'Run unit tests'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
inputs:
artifact: 'Build'
path: '$(Build.SourcesDirectory)'
- script: pip install -r requirements.txt
displayName: 'Install requirements'
- script: |
pip install pytest
pip install pytest-cov
pip install hypothesis
pip install lazydocs
pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html
displayName: 'Unit tests (pytest)'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/test-*.xml'
testRunTitle: 'Publish test results for Python $(Python.Version)'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'
- stage: Release
dependsOn: UnitTests
condition: succeeded()
jobs:
- job: PushToPyPi
displayName: 'Package wheel and push to PyPi'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
inputs:
artifact: 'Build'
path: '$(Build.SourcesDirectory)'
- script: python -m pip install --upgrade pip setuptools wheel lazydocs twine
displayName: 'Install tools'
- script: python setup.py sdist bdist_wheel
displayName: 'Build wheels'
- task: TwineAuthenticate@1
inputs:
pythonUploadServiceConnection: 'Arcus ML PyPi feed'
- script: python -m twine upload --skip-existing --verbose -r 'arcus-ml' --config-file $(PYPIRC_PATH) dist/*
displayName: 'Publish to PyPi dev'
condition: succeededOrFailed()
- task: CopyFiles@2
inputs:
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'dist'
publishLocation: 'Container'