-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathazure-pipelines.yml
204 lines (184 loc) · 7.72 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
trigger:
batch: true
branches:
include: ["master", "develop", "feature*", "release*", "bug*"]
paths:
exclude: ["doc", "*.md"]
variables:
- name: DOTNET_CLI_TELEMETRY_OPTOUT
value: 1
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
value: 1
- name: solution
value: 'AsyncExifTool.sln'
- name: buildPlatform
value: 'x64'
- name: buildConfiguration
value: 'Release'
- name: COVERLET_EXCLUDE_FILTER
value: '[Samples]*%2c[TestHelper]*%2c[*.Test]*%2c[xunit.*]*'
- name: COVERLET_INCLUDE_FILTER
value: '[*]AsyncExifTool.*%2c[AsyncExifTool*]*'
- name: COVERLET_EXCLUDE_ATTRIBUTE
value: 'DebuggerNonUserCodeAttribute%2cExcludeFromCodeCoverageAttribute%2cGeneratedCodeAttribute%2cCompilerGeneratedAttribute'
jobs:
- job: Ubuntu
pool:
vmImage: ubuntu-20.04
steps:
- checkout: self
clean: true
submodules: recursive
- task: UseDotNet@2
displayName: "Use dotnet sdk 2.1.x"
inputs:
version: 2.1.x
includePreviewVersions: false
- task: UseDotNet@2
displayName: "Use dotnet sdk 3.1.x"
inputs:
version: "3.1.x"
includePreviewVersions: false
- task: UseDotNet@2
displayName: "Use dotnet sdk 5.0.x"
inputs:
version: 5.0.x
includePreviewVersions: false
- task: UseDotNet@2
displayName: "Use dotnet sdk 6.0.x"
inputs:
version: 6.0.x
includePreviewVersions: false
- script: dotnet --info
displayName: Show dotnet SDK info
- bash: 'chmod +x scripts/InstallExiftool.sh && scripts/InstallExiftool.sh'
displayName: 'install exiftool'
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: 'restore'
projects: $(solution)
feedsToUse: 'select'
nugetConfigPath: nuget.config
- script: dotnet build --configuration $(buildConfiguration) --no-restore
displayName: 'dotnet build $(buildConfiguration)'
# Run tests and recored coverage.
# Recording coverage is done using coverlet and can be enabled for each test project by adding the nuget package 'coverlet.msbuild'
# when the package is not referenced, no coverage is recorded but the tests are run normally.
# It looks like this task will suffix the arguments with '--results-directory $(Agent.TempDirectory)'
- task: DotNetCoreCLI@2
displayName: 'Test and calculate code coverage'
inputs:
command: test
projects: 'tests/AsyncExifTool.Test/AsyncExifTool.Test.csproj'
# projects: '$(solution)'
arguments: '-c $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Exclude=$(COVERLET_EXCLUDE_FILTER) /p:Include=$(COVERLET_INCLUDE_FILTER) /p:ExcludeByAttribute=$(COVERLET_EXCLUDE_ATTRIBUTE) /p:ExcludeByFile=*\*Designer.cs /p:CoverletOutput=../_CoverageResults/ /p:MergeWith="../_CoverageResults/coverage.json" /p:CoverletOutputFormat=cobertura%2cjson --no-restore --no-build --collect:"XPlat Code Coverage" --logger trx'
# Install reportgenerator as a dotnet tool
- task: DotNetCoreCLI@2
displayName: 'Install reportgenerator as dotnet tool'
inputs:
command: custom
custom: tool
arguments: 'install dotnet-reportgenerator-globaltool --tool-path $(Build.SourcesDirectory)/tools'
# Merge the coverage output files as the PublishCodeCoverageResults task can only publish one CodeCoverage file to DevOps.
# The output is a single file named: $(System.DefaultWorkingDirectory)/Cobertura.xml
- task: CmdLine@1
displayName: 'Run reportgenerator to merge coverage files'
inputs:
filename: '$(Build.SourcesDirectory)/tools/reportgenerator'
arguments: '"-reports:**/coverag*.cobertura.xml" "-targetdir:$(System.DefaultWorkingDirectory)" "-reporttypes:Cobertura"'
# Make Azure DevOps aware of the coverage results.
# When there are no test coverage results, this task will generate a warning.
# Because there is only one test project, we do not need to merge the results.
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage to devops'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/Cobertura.xml'
#summaryFileLocation: '**/coverage*.cobertura.xml'
# Publish test coverage results to the codecov account
- bash: curl -s https://codecov.io/bash > scripts/.codecov && chmod +x scripts/.codecov && scripts/.codecov -f "tests/_CoverageResults/coverage*.cobertura.xml"
displayName: 'Publish code coverage to CodeCov.io'
# Create nuget packages (nupkg, and snupkg)
- task: DotNetCoreCLI@2
displayName: 'dotnet pack'
inputs:
command: pack
configuration: '$(BuildConfiguration)'
nobuild: false
includesymbols: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
# - job: Windows
# dependsOn: Ubuntu
# pool: Hosted Windows 2019 with VS2019
# steps:
#
# - checkout: self
# clean: true
# submodules: recursive
#
# - script: dotnet --info
# displayName: Show dotnet SDK info
#
# - task: PowerShell@2
# displayName: 'install exiftool'
# inputs:
# filePath: 'scripts\InstallExiftool.ps1'
#
# - task: DotNetCoreCLI@2
# displayName: 'dotnet restore'
# inputs:
# command: 'restore'
# projects: $(solution)
# feedsToUse: 'select'
# nugetConfigPath: nuget.config
#
# - script: dotnet build --configuration $(buildConfiguration) --no-restore
# displayName: 'dotnet build $(buildConfiguration)'
#
# # Run tests and recored coverage.
# # Recording coverage is done using coverlet and can be enabled for each test project by adding the nuget package 'coverlet.msbuild'
# # when the package is not referenced, no coverage is recorded but the tests are run normally.
# # It looks like this task will suffix the arguments with '--results-directory $(Agent.TempDirectory)'
# - task: DotNetCoreCLI@2
# displayName: 'Test and calculate code coverage'
# inputs:
# command: test
# projects: 'tests\AsyncExifTool.Test\AsyncExifTool.Test.csproj'
# # projects: '$(solution)'
# arguments: '-c $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Exclude=$(COVERLET_EXCLUDE_FILTER) /p:Include=$(COVERLET_INCLUDE_FILTER) /p:ExcludeByAttribute=$(COVERLET_EXCLUDE_ATTRIBUTE) /p:ExcludeByFile=*\*Designer.cs --no-restore --no-build --collect:"XPlat Code Coverage" --logger trx'
#
# # Make Azure DevOps aware of the coverage results.
# # When there are no test coverage results, this task will generate a warning.
# # Because there is only one test project, we do not need to merge the results.
# - task: PublishCodeCoverageResults@1
# displayName: 'Publish code coverage to devops'
# inputs:
# codeCoverageTool: Cobertura
# summaryFileLocation: '**/coverage.cobertura.xml'
#
# # Publish test coverage results to the codecov account
# - bash: curl -s https://codecov.io/bash > scripts/.codecov && chmod +x scripts/.codecov && scripts/.codecov -f "tests/AsyncExifTool.Test/coverage.cobertura.xml"
# displayName: 'Publish code coverage to CodeCov.io'
#
# # Create nuget packages (nupkg, and snupkg)
# - task: DotNetCoreCLI@2
# displayName: 'dotnet pack'
# inputs:
# command: pack
# configuration: '$(BuildConfiguration)'
# nobuild: false
#
# - task: PublishBuildArtifacts@1
# displayName: 'Publish Artifact'
# inputs:
# PathtoPublish: '$(build.artifactstagingdirectory)'
#
# # # Write all environment variables to an markdown file for debug purposes (i.e. make gitversion env variables visible)
# # - powershell: scripts\WriteEnvVars.ps1
# # errorActionPreference: silentlyContinue
# # failOnStderr: true
# # displayName: 'Make environment variables visible in Build Summary.'