This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SonarCloud Analysis (C#) | |
on: | |
push: | |
branches: | |
- main | |
- feature/* | |
pull_request: | |
branches: | |
- main | |
jobs: | |
sonarcloud: | |
name: Analyze with SonarCloud | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '7.0.x' | |
- name: Install SonarScanner for .NET | |
run: dotnet tool install --global dotnet-sonarscanner | |
- name: Install Coverlet.Console | |
run: dotnet tool install --global coverlet.console | |
- name: Build and Test with Coverage | |
run: | | |
dotnet build ./AutoGuru.KeyValuePush.sln | |
coverlet ./src/KeyValuePush.Tests/bin/Debug/net7.0/KeyValuePush.Tests.dll \ | |
--target "dotnet" \ | |
--targetargs "test ./src/KeyValuePush.Tests/KeyValuePush.Tests.csproj --no-build" \ | |
--output ./TestResults/Coverage/ \ | |
--format opencover | |
- name: Run SonarCloud analysis | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
dotnet sonarscanner begin \ | |
/k:"autoguru-au_kv-push" \ | |
/o:"autoguru-au" \ | |
/d:sonar.cs.opencover.reportsPaths="./TestResults/Coverage/coverage.opencover.xml" \ | |
/d:sonar.scanner.skipJreProvisioning=true | |
dotnet build ./AutoGuru.KeyValuePush.sln | |
dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" |