From 622ff1ad5fb31f254e3b1e041d51d5a8a5cdf7b7 Mon Sep 17 00:00:00 2001 From: Craig Fowler Date: Sat, 27 Feb 2021 12:43:04 +0000 Subject: [PATCH] WIP #665 - Add changes to YML in order to trigger SonarScanner The main things going on here in the YML are: * Adding some env vars for SonarScanner * Adding the SonarScanner package as a build tool * Adding before-build/after-test steps to setup/teardown SonarScanner * Separating the "pack" step from the "build" step * Pack moved to before-package which occurs after tests pass * See https://www.appveyor.com/docs/build-configuration/#build-pipeline * Tests run with logging & code-coverage detection * Test results are added as AppVeyor artifacts --- appveyor.yml | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index fb1b04e7d..444415fc6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,6 +2,16 @@ image: Previous Visual Studio 2019 environment: nodejs_version: "11" + # AppVeyor installs Java on its build agents by default, but it + # picks an old version that's not compatible with SonarQube. + # This brings it up to date. + JAVA_HOME: "C:\\Program Files\\Java\\jdk13" + sonarcloud_org_name: elsa-workflows + sonarcloud_project_name: elsa-core + sonarcloud_api_key: + secure: qaE9kOVkGGFM7ZMf3YeliZxDU9udTCy6W5xXHJ9T+tXv5qXPMYlIdR7hyNgxW04A + sample_variable: + secure: MrPipn2VVHXu68PxZWztGA== version: 2.0.0-preview6.{build} @@ -35,6 +45,22 @@ install: cd ..\..\..\..\ + dotnet tool install --global dotnet-sonarscanner + +before_build: + - cmd: echo "The sample variable is %sample_variable%" + - cmd: >- + dotnet-sonarscanner begin + /k:%sonarcloud_project_name% + /v:AppVeyor_build_%version% + /o:%sonarcloud_org_name% + /s:%APPVEYOR_BUILD_FOLDER%\.SonarQube.Analysis.xml + /d:sonar.host.url="https://sonarcloud.io" + /d:sonar.login=%sonarcloud_api_key% + /d:sonar.cs.xunit.reportsPaths=%APPVEYOR_BUILD_FOLDER%\**\TestResults\TestResults.xml + /d:sonar.cs.opencover.reportsPaths=%APPVEYOR_BUILD_FOLDER%\**\TestResults\*\coverage.opencover.xml + /d:sonar.branch.name=%APPVEYOR_REPO_BRANCH% + build_script: - ps: >- cd .\src\dashboards\blazor\ElsaDashboard.Application @@ -43,14 +69,21 @@ build_script: cd ..\..\..\..\ - dotnet pack Elsa.sln --include-symbols /p:Version=$env:APPVEYOR_BUILD_VERSION + dotnet build test_script: - - ps: dotnet test + - ps: dotnet test --collect:"XPlat Code Coverage" --logger:xunit -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover + +after_test: + - cmd: dotnet-sonarscanner end /d:sonar.login=%sonarcloud_api_key% + +before_package: + - ps: dotnet pack Elsa.sln --include-symbols /p:Version="$env:APPVEYOR_BUILD_VERSION" artifacts: - path: '**/*.nupkg' name: Packages + - path: '**/TestResults/TestResults.xml' deploy: # Deploy to MyGet on every build (in the appropriate branch)