Fix SonarQube issues (#268) #912
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: continous integration | |
on: | |
push: | |
branches: | |
- main | |
create: | |
tags: | |
- '*' | |
pull_request: | |
jobs: | |
build: | |
name: build | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- run: | | |
git fetch --prune --unshallow | |
- name: Set up JDK | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 17 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
- name: Setup dotnet-cover | |
run: dotnet tool install --global dotnet-coverage | |
- name: Setup SonarScanner | |
run: dotnet tool install --global dotnet-sonarscanner | |
- name: Patch version info | |
run: .\PatchVersion.ps1 | |
shell: pwsh | |
env: | |
GITHUB_PR_REF: ${{ github.head_ref }} | |
- name: Restore packages | |
run: dotnet restore --configfile nuget.config --verbosity normal | |
- name: Publish Release | |
run: dotnet publish --configuration Release -r win-x64 --self-contained | |
working-directory: src\SimpleAccounting | |
- name: Prepare SonarScanner | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
$prNo=${{ github.event.number }} | |
if ($prNo -gt 0) { | |
$branch="${{ github.HEAD_REF }}" | |
Write-Host analyzing Pull Request $prNo on branch $branch | |
$branchCommand="/d:sonar.pullrequest.key=$prNo" | |
} else { | |
$branch=$env:GITHUB_REF -replace "(\w+/)*","" | |
Write-Host analyzing branch $branch | |
$branchCommand="/d:sonar.branch.name=$branch" | |
} | |
Write-Host CMDs=$branchCommand | |
dotnet sonarscanner begin /d:"sonar.host.url=https://sonarcloud.io" /o:lg2de /k:lg2de_SimpleAccounting $branchCommand /d:sonar.token=$env:SONAR_TOKEN /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml | |
shell: pwsh | |
- name: Build Debug and Test | |
run: dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml" | |
- name: Complete SonarScanner | |
run: dotnet sonarscanner end /d:sonar.login=${{ secrets.SONAR_TOKEN }} | |
- name: Upload product artifact | |
uses: actions/upload-artifact@v1 | |
with: | |
name: SimpleAccounting | |
path: src\SimpleAccounting\bin\Release\net8.0-windows\win-x64\publish |