Skip to content

Commit

Permalink
Add: sonar qube
Browse files Browse the repository at this point in the history
  • Loading branch information
vulcandragi committed Aug 30, 2024
1 parent 85ed667 commit 6352db5
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions .github/workflows/dotnet8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
run: dotnet build --no-restore /WarnAsError

test:
needs: [ build ]
strategy:
matrix:
platform: [ ubuntu-latest, macos-latest, windows-latest ]
Expand All @@ -48,9 +47,48 @@ jobs:
run: dotnet restore
- name: Test
run: dotnet test --verbosity normal

sonar:
needs: [ build, test ]
runs-on: windows-latest
name: Sonar Qube

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~\.sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarQube scanner
id: cache-sonar-scanner
uses: actions/cache@v1
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarQube scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Build and analyze
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"Takasaki-Studio_Lina_15f9a6a7-ef3c-4937-88f6-40e4f890d8f1" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}"
dotnet build
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
publish_github:
needs: [ test ]
needs: [ sonar ]
environment: 'Production'
runs-on: ubuntu-latest
if: github.ref_name == 'dotnet8' && github.event_name == 'push'
Expand Down Expand Up @@ -81,7 +119,7 @@ jobs:
run: dotnet nuget push "./TakasakiStudio.Lina/bin/Release/*.nupkg" --api-key ${{ secrets.SECRET }} --source "github"

publish_nuget:
needs: [ test ]
needs: [ sonar ]
environment: 'Production Nuget'
runs-on: ubuntu-latest
if: github.ref_name == 'dotnet8' && github.event_name == 'push'
Expand Down

0 comments on commit 6352db5

Please sign in to comment.