From 6a61936ac1e74997953eb2258542ed411de6f702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B3th=20Tam=C3=A1s?= Date: Sat, 21 Dec 2024 18:31:19 +0100 Subject: [PATCH] Update ci.yml --- .github/workflows/ci.yml | 49 ++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 388fa2b..802c579 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,39 @@ jobs: with: dotnet-version: '8.x' + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'zulu' + + - name: Cache SonarQube Cloud packages + uses: actions/cache@v4 + with: + path: ~\sonar\cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache SonarQube Cloud 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 SonarQube Cloud 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: Start SonarQube Analysis + shell: powershell + run: | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"CloudFlare.Client" /o:"zingz0r-github" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.exclusions="bin/**,obj/**" /d:sonar.tests="CloudFlare.Client.Test/" /d:sonar.cs.opencover.reportsPaths="TestResults/**/coverage.opencover.xml" + - name: Build run: dotnet build -restore --configuration ${{ env.buildConfiguration }} @@ -41,15 +74,7 @@ jobs: dotnet test --logger "trx;logfilename=TestResults.trx" --no-build --configuration ${{ env.buildConfiguration }} --collect "XPlat Code Coverage;Format=opencover,cobertura" continue-on-error: false - - name: SonarQube Scan - uses: SonarSource/sonarqube-scan-action@v4.2.1 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - args: > - -Dsonar.organization=zingz0r-github - -Dsonar.projectKey=CloudFlare.Client - -Dsonar.tests=CloudFlare.Client.Test/ - -Dsonar.exclusions=bin/**,obj/** - -Dsonar.cs.opencover.reportsPaths=TestResults/**/coverage.opencover.xml - -Dsonar.verbose=true + - name: Finish SonarQube Analysis + shell: powershell + run: | + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"