From 1fe5c69fde52f150e9cbeb93241a915eaeb92044 Mon Sep 17 00:00:00 2001 From: Italo Pessoa Date: Tue, 17 Sep 2024 20:55:15 -0300 Subject: [PATCH] configurue code coverage for sonarcloud --- .github/workflows/dotnet.yml | 25 ++++++++++++------------- sonar-project.properties | 1 + 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 3678832..dc481f0 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -38,12 +38,22 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x + - name: Restore dependencies run: dotnet restore + - name: Build run: dotnet build --no-restore + - name: Test run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" --logger trx --results-directory coverage --settings tests/coverage.runsettings + + - name: Sonarcloud + if: github.event_name != 'pull_request' || github.ref == 'refs/heads/main' + uses: sonarsource/sonarcloud-github-action@v3.0.0 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - name: Code Coverage Summary Report uses: irongut/CodeCoverageSummary@v1.3.0 with: @@ -51,6 +61,7 @@ jobs: badge: true format: 'markdown' output: 'both' + - name: Add Coverage PR Comment continue-on-error: true uses: marocchino/sticky-pull-request-comment@v2 @@ -58,22 +69,10 @@ jobs: with: recreate: true path: code-coverage-results.md + - name: Write to Job Summary run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY - sonarcloud: - needs: [build] - if: github.event_name != 'pull_request' || github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@v3.0.0 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - build-docker-image: if: github.ref == 'refs/heads/main' needs: [build] diff --git a/sonar-project.properties b/sonar-project.properties index 4193c2a..79c5c33 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,3 +1,4 @@ sonar.projectKey=soat-fiap_FIAP.TechChallenge.ByteMeBurger sonar.organization=soat-fiap sonar.projectName=Byte me burger API +sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml \ No newline at end of file