Я пытаюсь подключить свой проект в sonarcloud. Я строю и запускаю свои тесты, используя Azure Devops Yaml конвейер. Вот краткое изложение того, что происходит.
Сначала у меня есть задача анализа Prepare:
- task: SonarCloudPrepare@1
displayName: 'Prepare analysis on Sonarcloud'
inputs:
SonarCloud: 'Sonarcloud'
organization: ***redacted***
scannerMode: 'MSBuild'
projectKey: ***redacted***
projectName: ***redacted***
extraProperties: |
sonar.exclusions=**/obj/**,**/*.dll
sonar.branch.name=$(Build.SourceBranchName)
sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/**/coverage.opencover.xml
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/*.trx
Затем я строю проект, все здесь хорошо. Затем я запускаю тесты и создаю отчет html для моего azure конвейера, используя генератор отчетов:
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
arguments: '--configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --logger trx'
projects: 'Tests/**/*.csproj'
nobuild: true
- script: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator "-reports:$(Build.SourcesDirectory)/**/coverage.opencover.xml" "-targetdir:$(Build.SourcesDirectory)/CodeCoverage" "-reporttypes:HtmlInline_AzurePipelines;Cobertura"
displayName: Create Code coverage report
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
reportDirectory: '$(Build.SourcesDirectory)/CodeCoverage'
Здесь снова все в порядке, тесты выполняются, покрытие вычисляется, отчет сгенерировано.
Затем я устанавливаю машинопись (для анализа гидролокатора) и запускаю анализ кода:
- script: |
cd $(Build.SourcesDirectory)/Src/***ProjectDir***
npm install typescript
displayName: 'Install typescript for sonar analysis'
- task: SonarCloudAnalyze@1
displayName: 'Run code analysis'
continueOnError: false
- task: SonarCloudPublish@1
displayName: 'Publish code analysis'
continueOnError: false
inputs:
pollingTimeoutSec: '300'
Анализ гидролокатора находит файл trx, но не отчеты о покрытии opencover, даже если путь предоставляется в параметре sonar.cs.opencover.reportsPaths в задаче подготовки анализа.
Вот журналы:
D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.10.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 4.8
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
17:31:43.118 Property 'sonar.cs.vstest.reportsPaths' provided, skipping the search for TRX files in default folders...
17:31:43.197 Did not find any binary coverage files in the expected location.
17:31:43.197 Falling back on locating coverage files in the agent temp directory.
17:31:43.197 Searching for coverage files in D:\a\_temp
17:31:43.243 No coverage files found in the agent temp directory.
Анализ правильно загружен в sonarcloud, но покрытие показывает 0% ...