name: SonarQube Analysis on: push: branches: [main, master] pull_request: types: [opened, synchronize, reopened] workflow_dispatch: jobs: sonarqube: runs-on: ubuntu-latest steps: - name: 1. Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: 2. Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' - name: 3. Setup Java uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17' - name: 4. Install SonarScanner for .NET run: | dotnet tool install --global dotnet-sonarscanner echo "$HOME/.dotnet/tools" >> $GITHUB_PATH - name: 5. Debug token sanity check if: false run: | curl -s -w "\nHTTP %{http_code}\n" \ -u "${{ secrets.SONAR_TOKEN }}:" \ "${{ secrets.SONAR_HOST_URL }}/api/plugins/installed" | head -5 echo "---" curl -s -w "\nHTTP %{http_code}\n" \ -u "${{ secrets.SONAR_TOKEN }}:" \ "${{ secrets.SONAR_HOST_URL }}/api/authentication/validate" - name: 6. SonarScanner Begin run: | dotnet sonarscanner begin \ /k:"sql-utilities" \ /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" \ /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ /d:sonar.exclusions="**/bin/**,**/obj/**" \ /d:sonar.coverage.exclusions="tests/**,**/*.Tests/**" \ /d:sonar.cs.opencover.reportsPaths="tests/**/TestResults/**/coverage.opencover.xml" \ /d:sonar.verbose=true - name: 7. Build run: dotnet build Strata.SqlTools.QueryBreakdown.sln --configuration Release - name: 8. Test with coverage run: | dotnet test Strata.SqlTools.QueryBreakdown.sln \ --configuration Release --no-build \ --settings coverlet.runsettings \ --collect "XPlat Code Coverage" - name: 9. SonarScanner End run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"