Skip to content

Feature/ag 14044 Testing sonar #52

Feature/ag 14044 Testing sonar

Feature/ag 14044 Testing sonar #52

Workflow file for this run

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: Restore dependencies
run: dotnet restore ./AutoGuru.KeyValuePush.sln
- name: Build solution
run: dotnet build ./AutoGuru.KeyValuePush.sln --no-restore --configuration Debug
- name: Run tests with coverage
run: |
coverlet ./src/KeyValuePush.Tests/bin/Debug/net7.0/KeyValuePush.Tests.dll \
--target "dotnet" \
--targetargs "test ./src/KeyValuePush.Tests/KeyValuePush.Tests.csproj --no-build --logger trx --results-directory ./TestResults/" \
--output ./TestResults/Coverage/ \
--format opencover
- name: Upload test results (optional, for visibility in GitHub Actions)
uses: actions/upload-artifact@v3
with:
name: TestResults
path: ./TestResults/
- name: Run SonarCloud analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet sonarscanner begin \
/k:"vanguille_kv-push-sonar" \
/o:"vanguille" \
/d:sonar.cs.opencover.reportsPaths="./TestResults/Coverage/coverage.opencover.xml" \
/d:sonar.inclusions="**/*.cs" \
/d:sonar.exclusions="**/bin/**,**/obj/**" \
/d:sonar.scanner.skipJreProvisioning=true \
/d:sonar.verbose=true \
/d:sonar.login="${{ secrets.SONAR_TOKEN }}"
dotnet build ./AutoGuru.KeyValuePush.sln
dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"