I’m using github action with SonarCloud on my .NET project, however even after many hours of search I have not managed to have my code covergae appearing in my Sonar analysis
Here is my Github Action yaml:
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET
on:
pull_request:
branches: [ "main" ]
push:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore workload
working-directory: ./src
run: dotnet workload restore
- name: Restore dependencies
working-directory: ./src
run: dotnet restore
- name: Build
working-directory: ./src
run: dotnet build --no-restore
- name: Install Dotnet Code Coverage
working-directory: ./src
run: dotnet tool install --global dotnet-coverage
- name: Test with compute code coverage
working-directory: ./src
run: dotnet test --collect "Code Coverage"
- name: SonarCloud Scan
# You may pin to the exact commit or the version.
# uses: SonarSource/sonarcloud-github-action@49e6cd3b187936a73b8280d59ffd9da69df63ec9
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: .
Firstly thanks for the answer.I read the link you provided me and after a few adjustments I manage to have the action running. However at the final I still get the following error:
Sorry for the delay but I’m a bit at a loss here, I use d Github Actions provided by Sonar and I don’t think I can run the command that was provided in the link.
Furthermore I supposed that it was supposed to work Sonar and sonarscanner were to work together.
Is there a simple tutorial that shows how to configure my Sonar analysis with code coverage in Github for .NET project ?