-
Notifications
You must be signed in to change notification settings - Fork 8
/
azure-pipelines.yml
212 lines (207 loc) · 6.82 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
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
# just to be sure not too many parallel runs of pipeline
batch: true
branches:
include:
- master
- feature/*
paths:
include:
- '*' # same as '/' for the repository root
exclude:
# exclude some directories that dont need any pipeline run
- 'docs/*'
- '.github/*'
- '.vscode/*'
- 'LICENSE'
- '*.md'
- 'build/*'
variables:
# setting isMaster variable if branch is master
isMaster: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
# setting vars for custom semver versioning names
major: 1
minor: 3
stages:
- stage: VersionNumbering
displayName: Set Version Numbers
jobs:
# job for branch versionings if not branch
- job: Build_Branch_Version_Number
displayName: Build Branch Version Number
condition: ne(variables['Build.SourceBranch'], 'refs/heads/master')
pool:
vmImage: 'windows-latest'
variables:
# revision build numbering
brpatch: $[counter(variables['build.sourcebranchname'], 0)]
prpatch: $[counter(variables['system.pullrequest.pullrequestid'], 0)]
prnumber: $(System.PullRequest.PullRequestNumber)
steps:
# disabling checkout
- checkout: none
# to major.minor-branch.build if not a pr
- task: PowerShell@2
condition: ne(variables['Build.Reason'], 'PullRequest')
name: SetBranchBuildName
displayName: Set Branch Build Name
inputs:
targetType: 'Inline'
script: Write-Host "##vso[build.updatebuildnumber]$(major).$(minor)-$(Build.SourceBranchName).$(brpatch)"
# to major.minor-prid.build if a pr
- task: PowerShell@2
condition: eq(variables['Build.Reason'], 'PullRequest')
name: SetPRBuildName
displayName: Set PR Build Name
inputs:
targetType: 'Inline'
script: Write-Host "##vso[build.updatebuildnumber]$(major).$(minor)-pr$(prnumber).$(prpatch)"
- job: Build_Master_Version_Number
displayName: Build Master Version Number
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
pool:
vmImage: 'windows-latest'
variables:
build: $[counter(variables['minor'], 0)]
steps:
# disabling checkout
- checkout: none
# to major.minor.build if not a pr
- powershell: Write-Host "##vso[build.updatebuildnumber]$(major).$(minor).$(build)"
name: SetMasterBuildName
displayName: Set Master Build Name
- stage: CompileAndUnitTests
displayName: 'Compile and Unit Tests'
jobs:
- job: Compile
displayName: 'Compile'
pool:
vmImage: 'windows-latest'
steps:
- task: PowerShell@2
displayName: 'Build Bootstrap and Init'
inputs:
targetType: 'Inline'
script: |
git config --global user.email 13959569+blindzero@users.noreply.github.com
git config --global user.name Matthias Fleschuetz
./build.ps1 -Bootstrap
./build.ps1 Init
- task: PowerShell@2
displayName: 'Build Compile'
inputs:
targetType: Inline
script: ./build.ps1 Compile
- task: PublishPipelineArtifact@1
displayName: 'Publish compile artifact'
inputs:
targetPath: 'BuildOutput\Connect-MS365'
artifactName: 'Connect-MS365_compile'
- job: TestUnit_Win
displayName: 'Windows Unit Tests'
dependsOn: Compile
pool:
vmImage: 'windows-latest'
steps:
- task: PowerShell@2
displayName: 'Build Bootstrap and Init'
inputs:
targetType: 'Inline'
script: |
git config --global user.email 13959569+blindzero@users.noreply.github.com
git config --global user.name "Matthias Fleschuetz"
./build.ps1 -Bootstrap
./build.ps1 Init
- task: DownloadPipelineArtifact@2
displayName: 'Download compile artifacts'
inputs:
artifact: 'Connect-MS365_compile'
path: 'BuildOutput\Connect-MS365'
- task: PowerShell@2
displayName: 'Test Unit'
enabled: true
inputs:
targetType: Inline
script: |
Import-Module -Name Pester -MinimumVersion 5.0.1 -Force
./build.ps1 TestUnit
- task: PublishTestResults@2
displayName: 'Publish Unit Test Results'
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: '**/testResultsUnit.xml'
mergeTestResults: true
testRunTitle: 'Unit Tests'
- stage: BuildAndIntegrationTests
displayName: 'Build and Integration Tests'
condition: and(succeeded(), eq(variables.isMaster, true))
jobs:
- job: Build
displayName: 'Build'
pool:
vmImage: 'windows-latest'
steps:
- task: VersionPowerShellModule@2
displayName: 'Set Version in module manifest'
inputs:
Path: '$(Build.SourcesDirectory)/Connect-MS365.psd1'
VersionNumber: '$(Build.BuildNumber)'
InjectVersion: true
OutputVersion: 'OutputedVersion'
- task: PowerShell@2
displayName: 'Build Bootstrap and Init'
inputs:
targetType: 'Inline'
script: |
git config --global user.email 13959569+blindzero@users.noreply.github.com
git config --global user.name Matthias Fleschuetz
./build.ps1 -Bootstrap
./build.ps1 Init
- task: PowerShell@2
displayName: 'Build'
inputs:
filePath: './build.ps1'
arguments: 'Build'
- task: PublishBuildArtifacts@1
displayName: 'Publish build artifact'
inputs:
pathToPublish: 'BuildOutput\Connect-MS365'
artifactName: 'Connect-MS365'
- job: TestIntegration_Win
displayName: 'Windows Integration Tests'
dependsOn: Build
pool:
vmImage: 'windows-latest'
steps:
- task: PowerShell@2
displayName: 'Build Bootstrap and Init'
inputs:
targetType: 'Inline'
script: |
git config --global user.email 13959569+blindzero@users.noreply.github.com
git config --global user.name Matthias Fleschuetz
./build.ps1 -Bootstrap
./build.ps1 Init
- task: DownloadBuildArtifacts@0
displayName: 'Download build artifacts'
inputs:
artifactName: 'Connect-MS365'
downloadPath: 'BuildOutput'
- task: PowerShell@2
displayName: 'Test Integration'
inputs:
targetType: Inline
script: |
Import-Module -Name Pester -MinimumVersion 5.0.1 -Force -Verbose
./build.ps1 TestIntegration
- task: PublishTestResults@2
displayName: 'Publish Integration Test Results'
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: '**/testResultsIntegration.xml'
mergeTestResults: true
testRunTitle: 'Integration Tests'