Skip to content

SonarCloud Scan

SonarCloud Scan #75

Workflow file for this run

name: SonarCloud Scan
on:
push:
branches:
- 'develop'
pull_request_target:
branches:
- 'develop'
workflow_dispatch:
env:
DOTNET_VERSION: '8.0.x'
jobs:
scan:
name: SonarCloud Scan
runs-on: ubuntu-latest
env:
DatabaseConfiguration__UseInMemoryDb: true
steps:
# Setup
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need to disable shallow clone for SonarCloud to scan properly: https://stackoverflow.com/a/62500400
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore Tools
run: |
cd Backend/Bones.Api
dotnet tool restore
cd ../..
cd Frontend/Bones.Api.Client
dotnet tool restore
cd ../..
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'adopt'
# Test
- name: Test and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet tool install --global dotnet-sonarscanner
dotnet-sonarscanner begin /k:"CorruptComputer_Bones" /o:"corruptcomputer" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=./Tests/*/*.UnitTests/TestResults/*/coverage.opencover.xml
dotnet build --no-incremental
dotnet test --no-build --collect:"XPlat Code Coverage;Format=opencover"
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"