-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathazure-pipelines.yml
106 lines (96 loc) · 2.75 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
trigger:
branches:
include:
- master
- feature/*
- Feature/*
paths:
exclude:
- README.md
- cake/*
pr:
autoCancel: true
branches:
include:
- master
pool:
vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
NETCoreVersion: '8.x'
solutionFile: '$(Build.SourcesDirectory)/*.sln'
unitTestPath: '$(Build.SourcesDirectory)/source/Services/product-catalog/DDD.ProductCatalog.Tests'
unitTestProjects: '$(unitTestPath)/*Tests/*.csproj'
codeCoverageReportPath : '$(Build.SourcesDirectory)/CodeCoverage'
stages:
- stage: RunBuild
displayName: 'Run Build'
jobs:
- job: BuildJob
steps:
#############
# Install .net core
#############
- task: UseDotNet@2
displayName: "Install .NET Core $(NETCoreVersion)"
inputs:
version: '$(NETCoreVersion)'
#############
# dotnet restore solution
#############
- task: DotNetCoreCLI@2
displayName: "dotnet restore"
inputs:
command: 'restore'
projects: '$(solutionFile)'
#############
# dotnet build solution
#############
- task: DotNetCoreCLI@2
displayName: "dotnet build"
inputs:
command: 'build'
arguments: '--configuration $(buildConfiguration)'
projects: '$(solutionFile)'
- stage: RunTests
displayName: 'Run Tests'
jobs:
- job: RunTestsJob
displayName: 'Run Tests Projects'
steps:
- task: UseDotNet@2
displayName: "Install .NET Core $(NETCoreVersion)"
inputs:
version: '$(NETCoreVersion)'
#############
# dotnet test
#############
- task: DotNetCoreCLI@2
displayName: "dotnet test"
inputs:
command: test
projects: '$(unitTestProjects)'
arguments: '--configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura'
nobuild: true
- script: |
dotnet tool install -g dotnet-reportgenerator-globaltool --version 5.2.4
$HOME/.dotnet/tools/reportgenerator -reports:$(unitTestPath)/**/coverage.cobertura.xml -targetdir:$(codeCoverageReportPath) -reporttypes:Cobertura
displayName: 'Create Code coverage report'
- task: PublishCodeCoverageResults@1
continueOnError: true
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '$(codeCoverageReportPath)/Cobertura.xml'
reportDirectory: '$(codeCoverageReportPath)'
failIfCoverageEmpty: true
- stage: CleanUp
displayName: "Cleanup After Build"
jobs:
- job: "CleanUpJob"
steps:
- task: DeleteFiles@1
continueOnError: true
inputs:
SourceFolder: '$(Agent.BuildDirectory)'
Contents: '**/*'
RemoveSourceFolder: true