From 2633c82a01d06d96eae601e28a19ed33d2631153 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 7 Dec 2019 02:37:11 -0500 Subject: [PATCH] New: Hookup SonarCloud --- azure-pipelines.yml | 131 +++++++++--------- src/NzbDrone.Api.Test/Radarr.Api.Test.csproj | 3 + .../Radarr.Common.Test.csproj | 3 + .../Radarr.Core.Test.csproj | 3 + .../Radarr.Host.Test.csproj | 3 + .../Radarr.Libraries.Test.csproj | 3 + .../Radarr.Mono.Test.csproj | 1 + .../Radarr.Update.Test.csproj | 3 + .../Radarr.Windows.Test.csproj | 3 + src/coverlet.runsettings | 21 +++ test.sh | 23 +-- 11 files changed, 116 insertions(+), 81 deletions(-) create mode 100644 src/coverlet.runsettings diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 37b4f29d0..0177c6882 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -624,9 +624,9 @@ stages: displayName: Move Package Contents - bash: | if [[ $OSNAME == "Mac" ]]; then - url=https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-macos.tar.gz + url=https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-macos.tar.gz elif [[ $OSNAME == "Linux" ]]; then - url=https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz + url=https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz else echo "Unhandled OS" exit 1 @@ -682,66 +682,69 @@ stages: env: FORCE_COLOR: 0 - # - job: Analyze_Frontend - # displayName: Frontend - # condition: eq(variables['system.pullrequest.isfork'], false) - # pool: - # vmImage: windows-2019 - # steps: - # - checkout: self # Need history for Sonar analysis - # - task: SonarCloudPrepare@1 - # env: - # SONAR_SCANNER_OPTS: '' - # inputs: - # SonarCloud: 'SonarCloud' - # organization: 'radarr' - # scannerMode: 'CLI' - # configMode: 'manual' - # cliProjectKey: 'radarr_Radarr.UI' - # cliProjectName: 'RadarrUI' - # cliProjectVersion: '$(radarrVersion)' - # cliSources: './frontend' - # - task: SonarCloudAnalyze@1 + - job: Analyze_Frontend + displayName: Frontend + pool: + vmImage: windows-2019 + steps: + - checkout: self # Need history for Sonar analysis + - task: SonarCloudPrepare@1 + env: + SONAR_SCANNER_OPTS: '' + inputs: + SonarCloud: 'SonarCloud' + organization: 'radarr' + scannerMode: 'CLI' + configMode: 'manual' + cliProjectKey: 'Radarr_Radarr.UI' + cliProjectName: 'RadarrI' + cliProjectVersion: '$(radarrVersion)' + cliSources: './frontend' + - task: SonarCloudAnalyze@1 - # - job: Analyze_Backend - # displayName: Backend - # condition: eq(variables['system.pullrequest.isfork'], false) - # pool: - # vmImage: windows-2019 - # steps: - # - checkout: self # Need history for Sonar analysis - # submodules: true - # - task: UseDotNet@2 - # displayName: 'Install .net core' - # inputs: - # version: $(dotnetVersion) - # - task: SonarCloudPrepare@1 - # inputs: - # SonarCloud: 'SonarCloud' - # organization: 'radarr' - # scannerMode: 'MSBuild' - # projectKey: 'radarr_Radarr' - # projectName: 'Radarr' - # projectVersion: '$(radarrVersion)' - # extraProperties: | - # sonar.exclusions=**/obj/**,**/*.dll,**/NzbDrone.Core.Test/Files/**/*,./frontend/**,**/ExternalModules/**,./src/Libraries/** - # sonar.coverage.exclusions=**/Radarr.Api.V1/**/*,**/MonoTorrent/**/*,**/Marr.Data/**/* - # sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/_tests/CoverageResults/coverage.opencover.xml - # sonar.cs.nunit.reportsPaths=$(Build.SourcesDirectory)/TestResult.xml - # - task: DotNetCoreCLI@2 - # displayName: Build backend - # inputs: - # command: 'build' - # projects: 'src/Radarr.Windows.sln' - # - task: Bash@3 - # displayName: Coverage Unit Tests - # inputs: - # targetType: 'filePath' - # filePath: ./test.sh - # arguments: Windows Unit Coverage - # - task: PublishCodeCoverageResults@1 - # displayName: Publish Coverage Results - # inputs: - # codeCoverageTool: 'cobertura' - # summaryFileLocation: './_tests/CoverageResults/coverage.cobertura.xml' - # - task: SonarCloudAnalyze@1 + - job: Analyze_Backend + displayName: Backend + pool: + vmImage: windows-2019 + variables: + disable.coverage.autogenerate: 'true' + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - checkout: self # Need history for Sonar analysis + submodules: true + - powershell: Set-Service SCardSvr -StartupType Manual + displayName: Enable Windows Test Service + - task: SonarCloudPrepare@1 + inputs: + SonarCloud: 'SonarCloud' + organization: 'radarr' + scannerMode: 'MSBuild' + projectKey: 'Radarr_Radarr' + projectName: 'Radarr' + projectVersion: '$(radarrVersion)' + extraProperties: | + sonar.exclusions=**/obj/**,**/*.dll,**/NzbDrone.Core.Test/Files/**/*,./frontend/**,**/ExternalModules/**,./src/Libraries/** + sonar.coverage.exclusions=**/Radarr.Api.V3/**/*,**/Radarr.Api/**/*,**/MonoTorrent/**/*,**/Marr.Data/**/* + sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/CoverageResults/**/coverage.opencover.xml + sonar.cs.nunit.reportsPaths=$(Build.SourcesDirectory)/TestResult.xml + - bash: | + ./build.sh --backend -f netcoreapp3.1 -r win-x64 + TEST_DIR=_tests/netcoreapp3.1/win-x64/publish/ ./test.sh Windows Unit Coverage + displayName: Coverage Unit Tests + - task: SonarCloudAnalyze@1 + displayName: Publish SonarCloud Results + - task: reportgenerator@4 + displayName: Generate Coverage Report + inputs: + reports: '$(Build.SourcesDirectory)/CoverageResults/**/coverage.opencover.xml' + targetdir: '$(Build.SourcesDirectory)/CoverageResults/combined' + reporttypes: 'HtmlInline_AzurePipelines;Cobertura;Badges' + - task: PublishCodeCoverageResults@1 + displayName: Publish Coverage Report + inputs: + codeCoverageTool: 'cobertura' + summaryFileLocation: './CoverageResults/combined/Cobertura.xml' + reportDirectory: './CoverageResults/combined/' \ No newline at end of file diff --git a/src/NzbDrone.Api.Test/Radarr.Api.Test.csproj b/src/NzbDrone.Api.Test/Radarr.Api.Test.csproj index e3aebbce5..c2a0118a1 100644 --- a/src/NzbDrone.Api.Test/Radarr.Api.Test.csproj +++ b/src/NzbDrone.Api.Test/Radarr.Api.Test.csproj @@ -9,6 +9,9 @@ + + + diff --git a/src/NzbDrone.Common.Test/Radarr.Common.Test.csproj b/src/NzbDrone.Common.Test/Radarr.Common.Test.csproj index bdbb47b09..b4a092364 100644 --- a/src/NzbDrone.Common.Test/Radarr.Common.Test.csproj +++ b/src/NzbDrone.Common.Test/Radarr.Common.Test.csproj @@ -8,6 +8,9 @@ + + + diff --git a/src/NzbDrone.Core.Test/Radarr.Core.Test.csproj b/src/NzbDrone.Core.Test/Radarr.Core.Test.csproj index debfc8dd1..9dd7c95a7 100644 --- a/src/NzbDrone.Core.Test/Radarr.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/Radarr.Core.Test.csproj @@ -10,6 +10,9 @@ + + + diff --git a/src/NzbDrone.Host.Test/Radarr.Host.Test.csproj b/src/NzbDrone.Host.Test/Radarr.Host.Test.csproj index 665668278..4a9701152 100644 --- a/src/NzbDrone.Host.Test/Radarr.Host.Test.csproj +++ b/src/NzbDrone.Host.Test/Radarr.Host.Test.csproj @@ -8,6 +8,9 @@ + + + diff --git a/src/NzbDrone.Libraries.Test/Radarr.Libraries.Test.csproj b/src/NzbDrone.Libraries.Test/Radarr.Libraries.Test.csproj index 0f11c4123..e82cde5c2 100644 --- a/src/NzbDrone.Libraries.Test/Radarr.Libraries.Test.csproj +++ b/src/NzbDrone.Libraries.Test/Radarr.Libraries.Test.csproj @@ -8,6 +8,9 @@ + + + diff --git a/src/NzbDrone.Mono.Test/Radarr.Mono.Test.csproj b/src/NzbDrone.Mono.Test/Radarr.Mono.Test.csproj index 9ed767e22..568f56d28 100644 --- a/src/NzbDrone.Mono.Test/Radarr.Mono.Test.csproj +++ b/src/NzbDrone.Mono.Test/Radarr.Mono.Test.csproj @@ -16,6 +16,7 @@ See https://github.com/xamarin/XamarinComponents/issues/282 --> + diff --git a/src/NzbDrone.Update.Test/Radarr.Update.Test.csproj b/src/NzbDrone.Update.Test/Radarr.Update.Test.csproj index c4214bc6b..040cacd35 100644 --- a/src/NzbDrone.Update.Test/Radarr.Update.Test.csproj +++ b/src/NzbDrone.Update.Test/Radarr.Update.Test.csproj @@ -8,6 +8,9 @@ + + + diff --git a/src/NzbDrone.Windows.Test/Radarr.Windows.Test.csproj b/src/NzbDrone.Windows.Test/Radarr.Windows.Test.csproj index 6e54240d0..2f644bb7e 100644 --- a/src/NzbDrone.Windows.Test/Radarr.Windows.Test.csproj +++ b/src/NzbDrone.Windows.Test/Radarr.Windows.Test.csproj @@ -8,6 +8,9 @@ + + + diff --git a/src/coverlet.runsettings b/src/coverlet.runsettings new file mode 100644 index 000000000..2b0fb46df --- /dev/null +++ b/src/coverlet.runsettings @@ -0,0 +1,21 @@ + + + + + + + opencover + [Radarr.*.Test]*,[Radarr.Test.*]*,[Radarr.Api*]*,[Marr.Data]*,[MonoTorrent]* + + + + + + + + + + diff --git a/test.sh b/test.sh index 2e25cacd5..4391efbae 100755 --- a/test.sh +++ b/test.sh @@ -16,16 +16,12 @@ if [ -d "$TEST_DIR/_tests" ]; then TEST_DIR="$TEST_DIR/_tests" fi -COVERAGE_RESULT_DIRECTORY="$TEST_DIR/CoverageResults/" - rm -f "$TEST_LOG_FILE" # Uncomment to log test output to a file instead of the console export RADARR_TESTS_LOG_OUTPUT="File" -NUNIT="dotnet vstest" -NUNIT_COMMAND="$NUNIT" -NUNIT_PARAMS="--Platform:x64 --logger:nunit;LogFilePath=TestResult.xml" +VSTEST_PARAMS="--Platform:x64 --logger:nunit;LogFilePath=TestResult.xml" if [ "$PLATFORM" = "Mac" ]; then @@ -63,20 +59,13 @@ for i in `find $TEST_DIR -name "$TEST_PATTERN"`; do ASSEMBLIES="$ASSEMBLIES $i" done +DOTNET_PARAMS="$ASSEMBLIES --TestCaseFilter:$WHERE $VSTEST_PARAMS" + if [ "$COVERAGE" = "Coverage" ]; then - if [ "$PLATFORM" = "Windows" ] || [ "$PLATFORM" = "Linux" ]; then - dotnet tool install coverlet.console --tool-path="$TEST_DIR/coverlet/" - mkdir $COVERAGE_RESULT_DIRECTORY - OPEN_COVER="$TEST_DIR/coverlet/coverlet" - $OPEN_COVER "$TEST_DIR/" --verbosity "detailed" --format "cobertura" --format "opencover" --output "$COVERAGE_RESULT_DIRECTORY" --exclude "[Radarr.*.Test]*" --exclude "[Radarr.Test.*]*" --exclude "[Radarr.Api*]*" --exclude "[Marr.Data]*" --exclude "[MonoTorrent]*" --exclude "[CurlSharp]*" --target "$NUNIT" --targetargs "$NUNIT_PARAMS --where=\"$WHERE\" $ASSEMBLIES"; - EXIT_CODE=$? - else - echo "Coverage only supported on Windows and Linux" - exit 3 - fi + dotnet vstest $DOTNET_PARAMS --settings:"src/coverlet.runsettings" --ResultsDirectory:./CoverageResults + EXIT_CODE=$? elif [ "$COVERAGE" = "Test" ] ; then - echo "$NUNIT_COMMAND $ASSEMBLIES --TestCaseFilter:$WHERE $NUNIT_PARAMS" - $NUNIT_COMMAND $ASSEMBLIES --TestCaseFilter:"$WHERE" $NUNIT_PARAMS + dotnet vstest $DOTNET_PARAMS EXIT_CODE=$? else echo "Run Type must be provided as third argument: Coverage or Test"