Some checks failed
SonarQube Scan / SonarQube Analysis (push) Failing after 1m13s
Co-authored-by: Copilot <copilot@github.com>
1.6 KiB
1.6 KiB
SonarQube Configuration
This project uses SonarQube for code quality analysis.
Setup
To enable SonarQube scanning, you need to configure the following GitHub/Gitea secrets:
Secrets Required
SONAR_HOST_URL: Your SonarQube server URL (e.g.,https://sonarqube.example.com)SONAR_LOGIN: Your SonarQube authentication token
Adding Secrets in Gitea
- Go to your repository settings
- Navigate to "Secrets and variables" → "Actions"
- Add the following secrets:
SONAR_HOST_URLSONAR_LOGIN
SonarQube Properties
The sonar-project.properties file configures:
- Project Key:
epage-go - Sources:
src/directory - Tests: All
*_test.gofiles insrc/ - Coverage: Reports from
coverage.out - Exclusions: Test files excluded from main analysis
Workflow Triggers
-
CI Workflow (
.gitea/workflows/ci.yml):- Runs on: Pull requests to
mainordevelop - Tests, lints, and builds the application
- Runs on: Pull requests to
-
SonarQube Workflow (
.gitea/workflows/sonarqube.yml):- Runs on: Pushes to
mainbranch - Generates coverage reports and uploads to SonarQube
- Runs on: Pushes to
Local SonarQube Scanning
To scan locally (requires SonarQube CLI):
# Generate coverage report
go test -coverprofile=coverage.out ./src
# Run SonarQube scanner
sonar-scanner \
-Dsonar.projectKey=epage-go \
-Dsonar.sources=src \
-Dsonar.host.url=https://sonarqube.example.com \
-Dsonar.login=your_token
Coverage Reports
Test coverage is automatically collected and can be viewed:
# Run tests with coverage
go test -v -coverprofile=coverage.out ./src
# View coverage report
go tool cover -html=coverage.out