-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
219 lines (195 loc) · 8.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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
###############################################
# SiddiqSoft Azure DevOps Pipelines Template #
# For C++ Projects #
# Version 2.0 #
###############################################
trigger:
batch: 'true'
branches:
include:
- master
- main
- bufix/*
- release/*
- hotfix/*
- feature/*
paths:
exclude:
- README.md
variables:
buildConfiguration: 'Release'
stages:
################################## STAGE ####################################
# STAGE: BuildTest #
#############################################################################
- stage: BuildTest
displayName: 'Building Multiple OS, Testing and Package for Windows'
jobs:
- job: build
displayName: 'Build and Test'
workspace:
clean: all
strategy:
matrix:
Windows:
osName: Windows_NT
poolName: Default
poolImageName:
cmake.preset: Windows-Release
Linux:
osName: Linux
poolName: Default
poolImageName:
cmake.preset: Linux-Release
pool:
name: $(poolName)
vmImage: $(poolImageName)
demands:
- Agent.OS -equals $(osName)
steps:
- checkout: self
fetchDepth: 0
name: step1
- task: NuGetToolInstaller@1
displayName: 'Install Nuget'
inputs:
versionSpec: '>=6.0.0-0'
checkLatest: true
- task: gitversion/setup@3
displayName: 'Install GitVersion..'
inputs:
versionSpec: '6.0'
preferLatestVersion: true
- task: gitversion/execute@3
displayName: 'Determine Version..'
name: version_step
inputs:
useConfigFile: true
configFilePath: 'GitVersion.yml'
# Set the flags for testing, build here.
- task: CMake@1
displayName: 'CMake Configure $(cmake.preset)'
inputs:
cmakeArgs: '--preset $(cmake.preset) -DCI_BUILDID=$(GitVersion.MajorMinorPatch) -DCPM_SOURCE_CACHE=$(Agent.HomeDirectory)/.cpmcache'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: CMake@1
displayName: 'CMake Build $(cmake.preset)'
inputs:
cmakeArgs: '--build --preset $(cmake.preset) -DCI_BUILDID=$(GitVersion.MajorMinorPatch) -DCPM_SOURCE_CACHE=$(Agent.HomeDirectory)/.cpmcache'
workingDirectory: '$(System.DefaultWorkingDirectory)'
condition: succeeded()
- task: CMake@1
displayName: 'CMake Tests $(cmake.preset)'
inputs:
cmakeArgs: '-E chdir $(System.DefaultWorkingDirectory)/build/$(cmake.preset)/tests ctest $(System.DefaultWorkingDirectory)/build/$(cmake.preset)/tests --output-junit $(System.DefaultWorkingDirectory)/build/$(cmake.preset)/tests/results/test_detail.xml --output-on-failure'
condition: and(succeeded(), startsWith(variables['Agent.OS'], 'Windows'))
continueOnError: false
# Try for coverage (but only on Linux build machines)
- task: CMake@1
displayName: 'CTest Coverage $(cmake.preset) (Linux only)'
inputs:
cmakeArgs: '-E chdir $(System.DefaultWorkingDirectory)/build/$(cmake.preset) ctest $(System.DefaultWorkingDirectory)/build/$(cmake.preset)/tests --output-junit $(System.DefaultWorkingDirectory)/build/$(cmake.preset)/tests/results/test_detail.xml --output-on-failure -T Test -T Coverage'
condition: and(succeeded(), startsWith(variables['Agent.OS'], 'Linux'))
continueOnError: false
- task: CmdLine@2
displayName: 'Coverage collection (Linux builds Only)'
inputs:
script: |
echo "gcovr --delete --root ../../ --print-summary --xml-pretty --xml coverage.xml . --filter='$(System.DefaultWorkingDirectory)/include/siddiqsoft/*' --filter='$(System.DefaultWorkingDirectory)/tests/*' --gcov-executable 'llvm-cov gcov'"
gcovr --delete --root $(System.DefaultWorkingDirectory)/ --print-summary --xml-pretty --xml $(System.DefaultWorkingDirectory)/build/$(cmake.preset)/tests/results/coverage.xml $(System.DefaultWorkingDirectory)/build/$(cmake.preset) --filter='$(System.DefaultWorkingDirectory)/include/*' --filter='$(System.DefaultWorkingDirectory)/tests/*' --gcov-executable 'llvm-cov gcov'
workingDirectory: "$(System.DefaultWorkingDirectory)/build/$(cmake.preset)"
condition: and(succeeded(), startsWith(variables['Agent.OS'], 'Linux'))
- task: PublishTestResults@2
displayName: 'Publish $(buildConfiguration) Test Results test_detail.xml'
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '$(System.DefaultWorkingDirectory)/build/$(cmake.preset)/tests/results/test_detail.xml'
mergeTestResults: true
buildConfiguration: '$(buildConfiguration)'
continueOnError: false
condition: succeeded()
- task: PublishCodeCoverageResults@2
displayName: 'Publish Coverage Results (Linux builds)'
inputs:
summaryFileLocation: '$(System.DefaultWorkingDirectory)/build/$(cmake.preset)/tests/results/coverage.*'
condition: and(succeeded(), startsWith(variables['Agent.OS'], 'Linux'))
################################## STAGE ####################################
# STAGE: Pack_n_Publish #
#############################################################################
- stage: Pack_n_Publish
displayName: 'Package for GitHub (cmake) and Nuget'
dependsOn: BuildTest
jobs:
- job: packit
displayName: PackageIt
workspace:
clean: all
strategy:
matrix:
Windows:
osName: Windows_NT
poolName: Default
poolImageName:
cmake.preset: Windows-Release
Linux:
osName: Linux
poolName: Default
poolImageName:
cmake.preset: Linux-Release
pool:
name: $(poolName)
vmImage: $(poolImageName)
demands:
- Agent.OS -equals $(osName)
steps:
- task: gitversion/setup@3
displayName: 'Install GitVersion..'
inputs:
versionSpec: '6.0'
preferLatestVersion: true
- task: gitversion/execute@3
displayName: 'Determine Version..'
name: version_step
inputs:
useConfigFile: true
configFilePath: 'GitVersion.yml'
- task: NuGetToolInstaller@1
displayName: 'Install Nuget'
inputs:
versionSpec: '>=6.0.0-0'
checkLatest: true
- task: NuGetCommand@2
displayName: 'NuGet pack v$(GitVersion.MajorMinorPatch)'
inputs:
command: 'pack'
packagesToPack: 'pack/*.nuspec'
versioningScheme: 'off'
buildProperties: 'VERSION=$(GitVersion.MajorMinorPatch)'
condition: and(succeeded(), startsWith(variables['Agent.OS'], 'Windows'))
- task: NuGetCommand@2
displayName: 'NuGet push'
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;build/*.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'sqs-nuget'
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.SourceBranch'], 'refs/heads/master')), startsWith(variables['Agent.OS'], 'Windows'))
- task: GitHubRelease@1
displayName: 'Release to GitHub'
inputs:
gitHubConnection: 'github-packages-sqs'
repositoryName: '$(Build.Repository.Name)'
action: 'create'
target: '$(Build.SourceVersion)'
tagSource: 'userSpecifiedTag'
tag: '$(GitVersion.MajorMinorPatch)'
title: 'v$(GitVersion.MajorMinorPatch)'
releaseNotesSource: 'inline'
releaseNotesInline: 'Documentation https://github.com/$(Build.Repository.Name)'
isPreRelease: true
changeLogCompareToRelease: 'lastFullRelease'
changeLogType: 'commitBased'
addChangeLog: false
assetUploadMode: 'replace'
#condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.SourceBranch'], 'refs/heads/master')), startsWith(variables['Agent.OS'], 'Linux'))
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.SourceBranch'], 'refs/heads/master')), startsWith(variables['Agent.OS'], 'Windows'))