forked from SteeltoeOSS/Steeltoe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
158 lines (156 loc) · 5.78 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
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
branches:
include:
- master
- 2.x
paths:
exclude:
- README.md
- project-docs/*
- roadmaps/*
variables:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: 1
PackageVersion: $[format('3.0.0-{0}', variables['Build.BuildId'])]
jobs:
- job: Linux_Build_and_Test
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 2.2.300
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
inputs:
command: restore
projects: 'src/Steeltoe.All.sln'
- task: DotNetCoreCLI@2
inputs:
command: build
projects: 'src/Steeltoe.All.sln'
arguments: '--no-restore -c $(buildConfiguration) -v n /p:TreatWarningsAsErrors=True'
- task: DotNetCoreCLI@2
inputs:
command: test
projects: '**/*.Test/*.csproj'
arguments: '-c $(buildConfiguration) --filter "Category!=SkipOnLinux&Category!=FlakyOnHostedAgents"'
- job: MacOS_Build_and_Test
pool:
vmImage: 'macOS-10.14'
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 2.2.300
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
inputs:
command: restore
projects: 'src/Steeltoe.All.sln'
- task: DotNetCoreCLI@2
inputs:
command: build
projects: 'src/Steeltoe.All.sln'
arguments: '--no-restore -c $(buildConfiguration) -v n /p:TreatWarningsAsErrors=True'
- task: DotNetCoreCLI@2
inputs:
command: test
projects: '**/*.Test/*.csproj'
arguments: '-c $(buildConfiguration) --filter "Category!=SkipOnMacOS&Category!=FlakyOnHostedAgents"'
- job: Windows_Build_Test_and_Package
pool:
vmImage: 'windows-2019'
steps:
- pwsh: |
if ($env:PackageVersionOverride){
$env:PackageVersion = $env:PackageVersionOverride
}
Write-Host "##vso[build.updatebuildnumber]$env:PackageVersion"
Write-Host "##vso[task.setvariable variable=PackageVersion;]$env:PackageVersion"
env:
PackageVersion: $(PackageVersion)
PackageVersionOverride: $(PackageVersionOverride)
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 2.2.300
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: 'src/Steeltoe.All.sln'
- task: SonarSource.sonarcloud.14d9cde6-c1da-4d55-aa01-2965cd301255.SonarCloudPrepare@1
displayName: 'Prepare analysis on SonarCloud'
inputs:
SonarCloud: SonarCloud
organization: 'steeltoeoss'
projectKey: 'SteeltoeOSS_steeltoe'
extraProperties: |
sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/**/coverage.opencover.xml
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/*.trx
- task: DotNetCoreCLI@2
inputs:
command: 'pack'
feedsToUse: 'select'
arguments: '--no-restore -c $(buildConfiguration) /p:TreatWarningsAsErrors=True'
packagesToPack: 'src/Steeltoe.All.sln'
versioningScheme: 'byEnvVar'
versionEnvVar: PackageVersion
- task: DotNetCoreCLI@2
inputs:
command: test
projects: 'src/Steeltoe.All.sln'
arguments: '-c $(buildConfiguration) /p:TreatWarningsAsErrors=True /p:CopyLocalLockFileAssemblies=true --filter "Category!=Integration&Category!=FlakyOnHostedAgents" /p:CollectCoverage=true /p:CoverletOutputFormat="opencover" /p:Include="[Steeltoe.*]*" /p:Exclude="[*.Test]*"'
# Generate the report using ReportGenerator (https://github.com/danielpalme/ReportGenerator)
# First install the tool on the machine, then run it
- pwsh: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator "-reports:**\coverage.opencover.xml" "-targetdir:$(Build.SourcesDirectory)\CodeCoverage" -reporttypes:Cobertura
displayName: Create Code coverage report
condition: always()
# Publish the code coverage result (summary and web site)
# The summary allows to view the coverage percentage in the summary tab
# The web site allows to view which lines are covered directly in Azure Pipeline
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)\CodeCoverage\Cobertura.xml'
reportDirectory: '$(Build.SourcesDirectory)\CodeCoverage'
condition: always()
- pwsh: |
choco install codecov
codecov -f "$(Build.SourcesDirectory)\CodeCoverage\Cobertura.xml" -t $env:CodeCovToken
env:
CodeCovToken: $(CodeCovToken)
condition: always()
- task: SonarSource.sonarcloud.ce096e50-6155-4de8-8800-4221aaeed4a1.SonarCloudAnalyze@1
displayName: 'Run Code Analysis'
condition: always()
- task: SonarSource.sonarcloud.38b27399-a642-40af-bb7d-9971f69712e8.SonarCloudPublish@1
displayName: 'Publish Quality Gate Result'
condition: always()
- task: PowerShell@2
displayName: Authenticode Sign Packages
inputs:
filePath: build/sign-packages.ps1
env:
SignClientUser: $(SignClientUser)
SignClientSecret: $(SignClientSecret)
ArtifactDirectory: $(Build.ArtifactStagingDirectory)
condition: and(succeeded(), not(eq(variables['build.reason'], 'PullRequest')), not(eq(variables['SignClientSecret'], '')), not(eq(variables['SignClientUser'], '')))
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)
ArtifactName: Packages
publishLocation: Container
condition: always()