-
Notifications
You must be signed in to change notification settings - Fork 32
/
3-build-test-qa.yml
78 lines (75 loc) · 2.79 KB
/
3-build-test-qa.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
variables:
project_name: 'EnvironmentApi'
netcore_version: '2.2'
sonarcloud_project: 'ThiagoBarradas_environment-api'
sonarcloud_organization: 'thiagobarradas-github'
sonarcloud_account: 'SonarCloudBarradas'
jobs:
- job: Build
steps:
- script: |
pwd && ls -la
dotnet restore
dotnet publish -c Release -o bin/Release/netcoreapp$(netcore_version)
mkdir artifact
cp -r $(project_name)/bin/Release/netcoreapp$(netcore_version) artifact/$(Build.SourceBranchName)
displayName: Build Application
- task: PublishPipelineArtifact@1
displayName: Store Application Artifact
inputs:
path: $(System.DefaultWorkingDirectory)/artifact
artifact: $(project_name)
- job: UnitTests
dependsOn: Build
steps:
- script: |
dotnet tool install --global coverlet.console
dotnet add $(project_name).Tests/$(project_name).Tests.csproj package coverlet.msbuild
dotnet add $(project_name).Tests/$(project_name).Tests.csproj package XunitXml.TestLogger
dotnet test /p:CollectCoverage=true \
/p:CoverletOutputFormat=\"opencover,cobertura\" \
/p:CoverletOutput=results/result \
/p:Exclude=[xunit.*]* $(project_name).sln \
--test-adapter-path:. --logger:"xunit;LogFilePath=results/result.xunit.xml"
displayName: Running Unit Tests
- task: PublishPipelineArtifact@1
displayName: Store Test Result
inputs:
path: $(System.DefaultWorkingDirectory)/$(project_name).Tests/results
artifact: UnitTestResults
- task: PublishCodeCoverageResults@1
displayName: Publish Code Coverage
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: $(System.DefaultWorkingDirectory)/$(project_name).Tests/results/result.cobertura.xml
pathToSources: .
failIfCoverageEmpty: true
- task: PublishTestResults@2
displayName: Publish Test Result
inputs:
testResultsFormat: 'XUnit'
testResultsFiles: '$(System.DefaultWorkingDirectory)/$(project_name).Tests/results/result.xunit.xml'
testRunTitle: 'Collecting Test Results'
- job: QualityAnalysis
dependsOn: UnitTests
steps:
- task: DownloadPipelineArtifact@2
displayName: Get Test Result
inputs:
artifact: UnitTestResults
- task: SonarCloudPrepare@1
inputs:
SonarCloud: '$(sonarcloud_account)'
organization: '$(sonarcloud_organization)'
scannerMode: 'MSBuild'
projectKey: '$(sonarcloud_project)'
projectName: '$(project_name)'
extraProperties: 'sonar.cs.opencover.reportsPaths=$(Pipeline.Workspace)/result.opencover.xml'
- script: |
dotnet build
displayName: Runnig Build For Analysis
- task: SonarCloudAnalyze@1
displayName: Finish Sonarqube Analysis
- task: SonarCloudPublish@1
inputs:
pollingTimeoutSec: '300'