-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
127 lines (106 loc) · 3.57 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
# Inspired from https://www.meziantou.net/2019/02/18/computing-code-coverage-for-a-net-core-project-with-azure-devops-and-coverlet
# and https://github.com/wulfland/code-coverage-sample/blob/master/azure-pipelines.yml
name: $(Date:yyyyMMdd)$(Rev:.r)
strategy:
matrix:
linux:
imageName: 'ubuntu-16.04'
windows:
imageName: 'windows-2019'
pool:
vmImage: $(imageName)
trigger:
branches:
include:
- master
- develop
- release/*
- hotfix/*
- features/*
paths:
exclude:
- docs/*
variables:
buildConfiguration: 'Release'
DOTNET_SKIP_FIRST_TIME_EXPERIENCE : true
steps:
- task: SonarCloudPrepare@1
inputs:
SonarCloud: '927afb1a-f6f6-430b-b477-a0007d55b46c'
organization: 'fazzani-github'
projectKey: 'Fazzani_Synker'
projectName: 'SynkerAPI'
extraProperties: |
sonar.cs.opencover.reportsPaths="$(Build.SourcesDirectory)/**/coverage.opencover.xml"
- task: UseDotNet@2
displayName: ".NET Core 3.1.x"
inputs:
version: '3.1.x'
packageType: sdk
- script: dotnet restore
displayName: 'dotnet restore'
- task: DotNetCoreCLI@2
displayName: 'dotnet build $(buildConfiguration)'
inputs:
command: build
projects: '**/*.csproj'
arguments: '--no-restore -c $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'dotnet test $(buildConfiguration)'
inputs:
command: test
projects: 'tests/**/*.csproj'
arguments: '-p:Exclude=[xunit.*]* -c $(buildConfiguration) -p:CollectCoverage=true "-p:CoverletOutputFormat=\"cobertura,opencover\""'
nobuild: true
- task: DotNetCoreCLI@2
displayName: Install ReportGenerator Global Tool
inputs:
command: custom
custom: tool
arguments: install -g dotnet-reportgenerator-globaltool
# Generate the report using ReportGenerator (https://github.com/danielpalme/ReportGenerator)
# First install the tool on the machine, then run it
- script: |
reportgenerator -reports:$(Build.SourcesDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage "-reporttypes:\"HtmlInline_AzurePipelines;Cobertura\""
displayName: Create Code Coverage report
# 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 report'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
reportDirectory: '$(Build.SourcesDirectory)/CodeCoverage'
- task: PublishTestResults@2
displayName: 'Publishing Unit Test Results'
inputs:
testRunner: VSTest
testResultsFiles: '/home/vsts/work/**/*.trx'
- task: UseDotNet@2
displayName: ".NET Core 2.2.x"
inputs:
version: '2.2.x'
packageType: sdk
- task: SonarCloudAnalyze@1
displayName: 'Run Code Analysis'
# This will fail on PR builds https://go.microsoft.com/fwlink/?linkid=862029
continueOnError: true
- task: SonarCloudPublish@1
displayName: 'Publish Quality Gate Result'
continueOnError: true
- task: UseDotNet@2
displayName: ".NET Core 3.1.x"
inputs:
version: '3.1.x'
packageType: sdk
- task: DotNetCoreCLI@2
displayName: 'dotnet publish $(buildConfiguration)'
inputs:
command: publish
projects: src/Synker.Api/Synker.Api.csproj
arguments: '--no-build -c $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: true
publishWebProjects: false
modifyOutputPath: true
- task: PublishBuildArtifacts@1