-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy path2-build-test.yml
51 lines (49 loc) · 1.93 KB
/
2-build-test.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
variables:
project_name: 'EnvironmentApi'
netcore_version: '2.2'
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'