This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
build(deps): bump xunit.runner.console from 2.5.1 to 2.7.0 #298
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'SonarCloud' | |
on: | |
workflow_dispatch: # To can dispatch manually | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, reopened, edited, synchronize] | |
branches: | |
- main | |
env: | |
SDK_VERSION: '6.0.420' | |
jobs: | |
sonar-scanner: | |
name: "Sonar scanner" | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Setup .NET" | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.SDK_VERSION }} | |
- name: "Set up JDK" | |
uses: actions/setup-java@v4.2.1 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: "Create cache directory" | |
run: mkdir -p ~/sonar/cache | |
- name: "Cache SonarCloud packages" | |
uses: actions/cache@v4 | |
with: | |
path: ~/sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: "Cache SonarCloud scanner" | |
id: cache-sonar-scanner | |
uses: actions/cache@v4 | |
with: | |
path: ./.sonar/scanner | |
key: ${{ runner.os }}-sonar-scanner | |
restore-keys: ${{ runner.os }}-sonar-scanner | |
- name: "Install SonarCloud scanner" | |
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | |
run: | | |
mkdir -p ./.sonar/scanner | |
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner | |
dotnet tool update dotnet-coverage --tool-path ./.sonar/scanner | |
- name: "Build and analyze" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
shell: pwsh | |
run: | | |
./.sonar/scanner/dotnet-sonarscanner begin /k:"${{ secrets.SONAR_PROJECT_KEY }}" /o:"${{ secrets.SONAR_ORGANIZATION }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.projectBaseDir="$(pwd)" | |
dotnet build -c Release --no-incremental | |
./.sonar/scanner/dotnet-coverage collect "dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -c Release --no-restore --no-build" -f xml -o "coverage.xml" | |
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |