Skip to content

Commit

Permalink
feature/workflow-template: Fixed (🤞) the Sonarcloud workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
Breno RdV committed Feb 4, 2024
1 parent 7ee3f83 commit 899cdc8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/qa-auto-monthly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/qa-on-pull-requests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: SonarCloud analysis on pull requests

on:
push:
branches:
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/template-qa-sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

0 comments on commit 899cdc8

Please sign in to comment.