79 lines
2.6 KiB
YAML
79 lines
2.6 KiB
YAML
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.verbose=true
|
|
|
|
- name: 7. Build
|
|
run: dotnet build Strata.SqlTools.QueryBreakdown.sln --configuration Release
|
|
|
|
- name: 8. Test plugins endpoint from runner
|
|
if: false
|
|
run: |
|
|
echo "Test 1: curl with token via Basic auth"
|
|
curl -s -w "\nHTTP %{http_code}\n" \
|
|
-u "${{ secrets.SONAR_TOKEN }}:" \
|
|
"${{ secrets.SONAR_HOST_URL }}/api/plugins/installed" | tail -2
|
|
echo "---"
|
|
echo "Test 2: curl with token via Bearer auth"
|
|
curl -s -w "\nHTTP %{http_code}\n" \
|
|
-H "Authorization: Bearer ${{ secrets.SONAR_TOKEN }}" \
|
|
"${{ secrets.SONAR_HOST_URL }}/api/plugins/installed" | tail -2
|
|
echo "---"
|
|
echo "Test 3: same Java User-Agent the scanner uses"
|
|
curl -s -w "\nHTTP %{http_code}\n" \
|
|
-u "${{ secrets.SONAR_TOKEN }}:" \
|
|
-H "User-Agent: ScannerCLI/5.0.2.4997" \
|
|
"${{ secrets.SONAR_HOST_URL }}/api/plugins/installed" | tail -2
|
|
|
|
- name: 9. SonarScanner End
|
|
run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
|