Skip to content

Commit 2228400

Browse files
committed
Update adt_pullrequest.yml for Azure Pipelines
1 parent 915645c commit 2228400

File tree

2 files changed

+51
-13
lines changed

2 files changed

+51
-13
lines changed

adt_pull_request.yml

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,54 @@ variables:
1414
prPipeline: $[eq(variables['Build.Reason'], 'PullRequest')]
1515

1616
steps:
17-
- script: dotnet build --configuration $(buildConfiguration)
18-
displayName: 'dotnet build $(buildConfiguration)'
17+
- task: SonarQubePrepare@5
18+
inputs:
19+
SonarQube: 'SonarQube Developer Edition'
20+
scannerMode: 'MSBuild'
21+
projectKey: '$(SONAR_PROJECT_KEY)'
22+
extraProperties: |
23+
# Additional properties that will be passed to the scanner,
24+
# Put one key=value per line, example:
25+
# sonar.exclusions=**/*.bin
26+
sonar.cs.vscoveragexml.reportsPaths=**/CodeCoverage/Cobertura.xml
27+
28+
- task: CmdLine@2
29+
inputs:
30+
script: dotnet build --no-incremental
31+
displayName: 'Rodando dotnet build'
1932

33+
# Test with Coverage
34+
# Run all tests with "/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura" to generate the code coverage file
2035
- task: DotNetCoreCLI@2
21-
displayName: Rodando os testes da aplicação
36+
displayName: Rodando os testes da aplicação
2237
inputs:
2338
command: test
39+
arguments: '--configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura'
2440
projects: '**/*[Tt]ests/*.csproj'
25-
arguments: '--configuration $(BuildConfiguration) --collect "Code Coverage"'
26-
27-
- task: DotNetCoreCLI@2
28-
displayName: 'Rodando SonarScanner '
41+
nobuild: true
42+
43+
- task: reportgenerator@5
44+
displayName: ReportGenerator
45+
inputs:
46+
reports: '$(Build.SourcesDirectory)/tests/\*\*/coverage.cobertura.xml'
47+
targetdir: '$(Build.SourcesDirectory)/CodeCoverage'
48+
reporttypes: 'HtmlInline\_AzurePipelines;Cobertura;Badges'
49+
assemblyfilters: '-xunit\*'
50+
51+
# Publish the code coverage result (summary and web site)
52+
# The summary allows to view the coverage percentage in the summary tab
53+
# The web site allows to view which lines are covered directly in Azure Pipeline
54+
- task: PublishCodeCoverageResults@1
55+
displayName: 'Publish code coverage'
56+
inputs:
57+
codeCoverageTool: Cobertura
58+
summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
59+
reportDirectory: '$(Build.SourcesDirectory)/CodeCoverage'
60+
61+
- task: SonarQubeAnalyze@5
62+
displayName: 'Run SonarCloud analysis'
63+
64+
- task: SonarQubePublish@5
65+
displayName: 'Publish sonarqube analysis'
2966
inputs:
30-
command: custom
31-
custom: tool
32-
arguments: 'dotnet sonarscanner begin /k:"$(SONAR_PROJECT_KEY)" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="$(SONAR_TOKEN)" /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html
33-
dotnet build –no-incremental
34-
dotnet dotcover test --dcReportType=HTML
35-
dotnet sonarscanner end /d:sonar.login="$(SONAR_TOKEN)"'
67+
pollingTimeoutSec: '300'

src/AzureDevopsTracker.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@
2424
</PropertyGroup>
2525

2626
<ItemGroup>
27+
<PackageReference Include="altcover" Version="8.3.838" />
28+
<PackageReference Include="coverlet.msbuild" Version="3.1.2">
29+
<PrivateAssets>all</PrivateAssets>
30+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
31+
</PackageReference>
2732
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
2833
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
2934
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
35+
<PackageReference Include="ReportGenerator" Version="5.1.9" />
3036
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
3137
</ItemGroup>
3238

0 commit comments

Comments
 (0)