Some checks failed
CI / lint-and-test (push) Failing after 2m25s
CI / secret-scanning (push) Successful in 1m33s
CI / security-scan (push) Successful in 2m13s
CI / dependency-scan (push) Successful in 1m39s
CI / sast-scan (push) Successful in 2m42s
CI / container-scan (push) Successful in 2m14s
CI / sonar-analysis (push) Failing after 2m44s
CI / docker-build-test (push) Failing after 1m40s
CI / workflow-summary (push) Successful in 1m30s
CHANGES: ======== ✅ Added conditional execution - Runs on pull_request or main/dev/qa branches - Matches pattern from other project ✅ Graceful secret handling - Exits 0 if secrets not set (doesn't break CI) - Clear warning message ✅ Non-blocking on failure - Exits 0 on SonarScanner failure (not exit 1) - Prevents CI failures from SonarQube issues - Matches established pattern ✅ Kept coverage report generation - Generates coverage.xml for SonarQube - Uses pytest-cov CONFIGURATION: ============== - Project key: pote - Sources: src/ - Tests: tests/ - Python version: 3.11 - Coverage: coverage.xml This matches the pattern used in other projects while maintaining POTE-specific configuration.
2.4 KiB
2.4 KiB
SonarQube Quick Start
5-minute setup guide for SonarQube code quality analysis.
✅ What's Already Done
- ✅
sonar-project.properties- Project configuration - ✅ CI pipeline job -
sonar-analysisadded - ✅ Coverage report generation - Integrated with pytest
🚀 Quick Setup (3 Steps)
Step 1: Create Project in SonarQube
- Login to SonarQube:
http://your-server:9000 - Projects → Create Project
- Project Key:
pote - Display Name:
POTE - Click Set Up
Step 2: Generate Token
- My Account → Security → Generate Token
- Name:
POTE CI/CD - Type: User Token
- Click Generate
- ⚠️ COPY THE TOKEN (you won't see it again!)
Step 3: Add Secrets to Gitea
- Go to:
https://git.levkin.ca/ilia/POTE/settings/secrets/actions - Add secret:
SONAR_HOST_URL=http://your-server:9000 - Add secret:
SONAR_TOKEN= (paste token from Step 2)
🧪 Test It
# Push to dev branch
git push origin dev
# Check CI results
# https://git.levkin.ca/ilia/POTE/actions
# View SonarQube results
# http://your-server:9000/dashboard?id=pote
📋 Configuration
Project Key
- Key:
pote(insonar-project.properties) - Name:
POTE - Version:
0.1.0
Source Code
- Sources:
src/ - Tests:
tests/ - Coverage:
coverage.xml(auto-generated)
Exclusions
__pycache__/,*.pycvenv/,tests/alembic/versions/
🔧 Customize
Edit sonar-project.properties:
sonar.projectKey=pote
sonar.projectName=POTE
sonar.sources=src
sonar.tests=tests
📊 View Results
SonarQube Dashboard:
http://your-server:9000/dashboard?id=pote
Metrics:
- Code Coverage
- Bugs & Vulnerabilities
- Code Smells
- Technical Debt
- Quality Gate Status
🐛 Troubleshooting
"Project does not exist"
→ Create project manually in SonarQube UI
"Authentication failed"
→ Check SONAR_TOKEN secret is correct
"Connection refused"
→ Verify SONAR_HOST_URL and server accessibility
"Coverage not found"
→ Ensure pytest runs before SonarScanner (already configured)
📖 Full Documentation
See: docs/17_sonarqube_setup.md for complete guide.
Setup Time: ~5 minutes
CI Integration: ✅ Already done
Manual Steps: 3 (create project, generate token, add secrets)