Skip to content

Page

Page #16

Workflow file for this run

name: SonarCloud
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Cache NuGet
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-sonar-nuget-${{ hashFiles('Directory.Packages.props', '.config/dotnet-tools.json') }} #hash of project files
restore-keys: ${{ runner.os }}-sonar-nuget-
- name: Install Tools
run: dotnet tool restore
- name: SonarScanner for .NET
uses: na1307/dotnet-sonarscanner-cloud@v1
with:
sonar-token: ${{ secrets.SONAR_TOKEN }}
additional-properties: -d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
build-commands: |
dotnet restore
dotnet build --no-restore --no-incremental
dotnet coverage collect 'dotnet test --no-build --verbosity normal' -f xml -o 'coverage.xml'