diff --git a/.github/workflows/qa-auto-monthly.yml b/.github/workflows/qa-auto-monthly.yml index f5839f9..48c72d8 100644 --- a/.github/workflows/qa-auto-monthly.yml +++ b/.github/workflows/qa-auto-monthly.yml @@ -3,7 +3,7 @@ name: Monthly SonarCloud Analysis on: schedule: # Runs at 2 AM UTC on the 1st of every month - # This will help keep the project alive on SonarCloud.io + # This will help keep me being on top of any new security issue. :) - cron: '0 2 1 * *' jobs: diff --git a/.github/workflows/qa-on-pull-requests.yml b/.github/workflows/qa-on-pull-requests.yml index 4d38a9c..e32dfa6 100644 --- a/.github/workflows/qa-on-pull-requests.yml +++ b/.github/workflows/qa-on-pull-requests.yml @@ -1,4 +1,5 @@ name: SonarCloud analysis on pull requests + on: push: branches: diff --git a/.github/workflows/template-qa-sonarcloud.yml b/.github/workflows/template-qa-sonarcloud.yml index 629f377..6d8029b 100644 --- a/.github/workflows/template-qa-sonarcloud.yml +++ b/.github/workflows/template-qa-sonarcloud.yml @@ -81,10 +81,19 @@ jobs: SONAR_TOKEN: ${{ secrets.sonarToken }} shell: powershell run: | - $verboseFlag = ${{ inputs.verbose }} + $verboseFlag = if (${{ inputs.verbose }}) {"true"} else {"false"} $sonarExclusions = "${{ inputs.sonarExclusions }}" $coverageExclusions = "${{ inputs.coverageExclusions }}" - .\.sonar\scanner\dotnet-sonarscanner begin /k:"${{ inputs.projectKey }}" /o:"${{ inputs.organization }}" /d:sonar.login="${{ secrets.sonarToken }}" /d:sonar.host.url="https://sonarcloud.io" /d:"sonar.verbose=$verboseFlag" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.exclusions="$sonarExclusions" /d:sonar.coverage.exclusions="$coverageExclusions" + + $sonarBeginCmd = ".\.sonar\scanner\dotnet-sonarscanner begin /k:`"${{ inputs.projectKey }}`" /o:`"${{ inputs.organization }}`" /d:sonar.login=`"${{ secrets.sonarToken }}`" /d:sonar.host.url=`"https://sonarcloud.io`" /d:`"sonar.verbose=$verboseFlag`"" + if (-not [string]::IsNullOrWhiteSpace($sonarExclusions)) { + $sonarBeginCmd += " /d:`"sonar.exclusions=$sonarExclusions`"" + } + if (-not [string]::IsNullOrWhiteSpace($coverageExclusions)) { + $sonarBeginCmd += " /d:`"sonar.coverage.exclusions=$coverageExclusions`"" + } + + Invoke-Expression $sonarBeginCmd dotnet build --configuration Release dotnet-coverage collect 'dotnet test' -f xml -o 'coverage.xml' .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.sonarToken }}"