diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index c16c084..1975344 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -8,7 +8,7 @@ on: jobs: build: name: Build and analyze - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 with: @@ -17,44 +17,41 @@ jobs: with: dotnet-version: "9.0" - name: Set up JDK 17 - uses: actions/setup-java@v5 + uses: actions/setup-java@v4 with: java-version: 17 distribution: "zulu" # Alternative distribution options are available. - name: Cache SonarCloud packages uses: actions/cache@v4 with: - path: ~\sonar\cache + 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' - shell: powershell - run: | - New-Item -Path .\.sonar\scanner -ItemType Directory - dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner - - name: Install dotnet-coverage - run: dotnet tool install --global dotnet-coverage + - name: Install SonarCloud scanner (global) + run: dotnet tool install --global dotnet-sonarscanner - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - shell: powershell + shell: bash + working-directory: ${{ github.workspace }} run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"nikneem_sessionize-api-client" /o:"nikneem" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml - dotnet build src --no-incremental - dotnet-coverage collect "dotnet test src" -f xml -o coverage.xml - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + export PATH="$HOME/.dotnet/tools:$PATH" + dotnet sonarscanner begin \ + /k:"nikneem_sessionize-api-client" \ + /o:"nikneem" \ + /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ + /d:sonar.host.url="https://sonarcloud.io" \ + /d:sonar.verbose=true \ + /d:sonar.coverageReportPaths="**/TestResults/**/coverage.cobertura.xml" + dotnet build "src/Sessionize API Client.sln" --no-incremental + dotnet test "src/Sessionize API Client.sln" --no-build --collect:"XPlat Code Coverage" + ls -la .sonarqube || true + ls -la .sonarqube/conf || true + dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" - name: Publish Artifact uses: actions/upload-artifact@v4 with: name: coverage-report - path: coverage.xml + path: '**/TestResults/**/coverage.cobertura.xml' diff --git a/src/Sessionize.Api.Client.IntegrationTests/Sessionize.Api.Client.IntegrationTests.csproj b/src/Sessionize.Api.Client.IntegrationTests/Sessionize.Api.Client.IntegrationTests.csproj index ae6bab3..3254921 100644 --- a/src/Sessionize.Api.Client.IntegrationTests/Sessionize.Api.Client.IntegrationTests.csproj +++ b/src/Sessionize.Api.Client.IntegrationTests/Sessionize.Api.Client.IntegrationTests.csproj @@ -14,13 +14,13 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Sessionize.Api.Client.Tests/Sessionize.Api.Client.Tests.csproj b/src/Sessionize.Api.Client.Tests/Sessionize.Api.Client.Tests.csproj index 56989a8..f111b1b 100644 --- a/src/Sessionize.Api.Client.Tests/Sessionize.Api.Client.Tests.csproj +++ b/src/Sessionize.Api.Client.Tests/Sessionize.Api.Client.Tests.csproj @@ -10,18 +10,18 @@ - - - - + + + + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Sessionize.Api.Client/Sessionize.Api.Client.csproj b/src/Sessionize.Api.Client/Sessionize.Api.Client.csproj index 76f2f65..226947d 100644 --- a/src/Sessionize.Api.Client/Sessionize.Api.Client.csproj +++ b/src/Sessionize.Api.Client/Sessionize.Api.Client.csproj @@ -34,6 +34,6 @@ - + \ No newline at end of file