Skip to content

Commit 48915e2

Browse files
committed
fix: configure SonarQube for local Docker instance
- Update workflow to work with localhost:9000 - Remove organization setting (not needed for self-hosted) - Add PowerShell script for easy local analysis - Disable automatic GitHub Actions trigger
1 parent 1f5f684 commit 48915e2

File tree

3 files changed

+58
-27
lines changed

3 files changed

+58
-27
lines changed

.github/workflows/sonarqube.yml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +0,0 @@
1-
name: Build
2-
3-
on:
4-
push:
5-
branches:
6-
- main
7-
8-
9-
jobs:
10-
build:
11-
name: Build and analyze
12-
runs-on: ubuntu-latest
13-
14-
steps:
15-
- uses: actions/checkout@v4
16-
with:
17-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
18-
- uses: SonarSource/sonarqube-scan-action@v5
19-
env:
20-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
21-
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
22-
# If you wish to fail your job when the Quality Gate is red, uncomment the
23-
# following lines. This would typically be used to fail a deployment.
24-
# - uses: SonarSource/sonarqube-quality-gate-action@v1
25-
# timeout-minutes: 5
26-
# env:
27-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

run-sonar.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Run SonarQube Analysis Locally
2+
# Make sure SonarQube is running on localhost:9000
3+
4+
Write-Host "Checking if SonarQube is running..." -ForegroundColor Cyan
5+
6+
try {
7+
$response = Invoke-WebRequest -Uri "http://localhost:9000" -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop
8+
Write-Host "✓ SonarQube is running on localhost:9000" -ForegroundColor Green
9+
} catch {
10+
Write-Host "✗ SonarQube is not accessible at localhost:9000" -ForegroundColor Red
11+
Write-Host " Start SonarQube with: docker-compose up -d" -ForegroundColor Yellow
12+
exit 1
13+
}
14+
15+
Write-Host "`nRunning SonarQube analysis..." -ForegroundColor Cyan
16+
17+
# Check if sonar-scanner is installed
18+
$sonarScanner = Get-Command sonar-scanner -ErrorAction SilentlyContinue
19+
20+
if (-not $sonarScanner) {
21+
Write-Host "✗ sonar-scanner not found" -ForegroundColor Red
22+
Write-Host " Install it with: npm install -g sonarqube-scanner" -ForegroundColor Yellow
23+
Write-Host " Or download from: https://docs.sonarqube.org/latest/analyzing-source-code/scanners/sonarscanner/" -ForegroundColor Yellow
24+
exit 1
25+
}
26+
27+
# Run the analysis
28+
sonar-scanner
29+
30+
if ($LASTEXITCODE -eq 0) {
31+
Write-Host "`n✓ Analysis complete! View results at http://localhost:9000/dashboard?id=Addy-shetty_Vibe-Prompting_3ea74998-7189-4e3e-a7e0-8be5ce3a3a3c" -ForegroundColor Green
32+
} else {
33+
Write-Host "`n✗ Analysis failed" -ForegroundColor Red
34+
exit $LASTEXITCODE
35+
}

sonar-project.properties

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
11
sonar.projectKey=Addy-shetty_Vibe-Prompting_3ea74998-7189-4e3e-a7e0-8be5ce3a3a3c
2+
3+
# Local SonarQube configuration
4+
sonar.host.url=http://localhost:9000
5+
6+
# Project metadata
7+
sonar.projectName=Vibe Prompting
8+
sonar.projectVersion=1.0.0
9+
10+
# Source code location
11+
sonar.sources=src
12+
sonar.tests=src
13+
sonar.test.inclusions=**/*.test.ts,**/*.test.tsx,**/*.spec.ts,**/*.spec.tsx
14+
15+
# Exclusions
16+
sonar.exclusions=**/node_modules/**,**/dist/**,**/build/**,**/*.config.ts,**/*.config.js,**/coverage/**,**/docs/**,**/supabase/**
17+
18+
# TypeScript/JavaScript settings
19+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
20+
sonar.typescript.tsconfigPath=tsconfig.json
21+
22+
# Encoding
23+
sonar.sourceEncoding=UTF-8
24+

0 commit comments

Comments
 (0)