feat: Integrate SonarQube analysis into CI workflows
Some checks failed
Docker Build and Push / build-and-push (push) Failing after 43s
LabFusion CI/CD Pipeline / service-adapters (push) Failing after 25s
API Gateway (Java Spring Boot) / test (17) (push) Failing after 1m50s
LabFusion CI/CD Pipeline / api-docs (push) Failing after 50s
LabFusion CI/CD Pipeline / api-gateway (push) Failing after 1m34s
API Gateway (Java Spring Boot) / test (21) (push) Failing after 1m44s
API Gateway (Java Spring Boot) / build (push) Has been skipped
API Gateway (Java Spring Boot) / security (push) Has been skipped
LabFusion CI/CD Pipeline / frontend (push) Failing after 1m57s
LabFusion CI/CD Pipeline / integration-tests (push) Has been skipped
Frontend (React) / test (16) (push) Failing after 1m44s
Frontend (React) / test (20) (push) Failing after 1m31s
Frontend (React) / test (18) (push) Failing after 1m47s
Frontend (React) / build (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.1) (push) Failing after 19s
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 26s
Service Adapters (Python FastAPI) / test (3.9) (push) Failing after 23s
Service Adapters (Python FastAPI) / build (push) Has been skipped
Frontend (React) / lighthouse (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 22s
Integration Tests / performance-tests (push) Has been skipped
Integration Tests / integration-tests (push) Failing after 2m23s
API Docs (Node.js Express) / test (16) (push) Failing after 54s
API Docs (Node.js Express) / test (18) (push) Failing after 55s
API Docs (Node.js Express) / test (20) (push) Failing after 58s
API Docs (Node.js Express) / build (push) Has been skipped

### Summary of Changes
- Added SonarQube analysis steps to all CI workflows (API Docs, API Gateway, Frontend, Service Adapters).
- Configured SonarQube properties for each service to ensure proper reporting and analysis.
- Enhanced test coverage reporting by specifying multiple coverage reporters in test commands.
- Updated Maven and Python dependencies to include SonarQube integration tools.

### Expected Results
- CI pipelines will now send test and coverage results to SonarQube for better quality tracking.
- Improved visibility into code quality and test coverage across all services.
This commit is contained in:
GSRN
2025-09-15 19:55:13 +02:00
parent 7cf0819b58
commit 6f8d7f6ca9
8 changed files with 460 additions and 43 deletions

View File

@@ -125,13 +125,40 @@ jobs:
echo "TEST_REPORTS_EXIST=false" >> $GITHUB_ENV
fi
- name: Generate test report
uses: dorny/test-reporter@v1
- name: Send test results to SonarQube
if: env.TEST_REPORTS_EXIST == 'true'
with:
name: Maven Tests (Java ${{ matrix.java-version }})
path: target/surefire-reports/*.xml
reporter: java-junit
run: |
echo "Sending test results to SonarQube..."
# Configure SonarQube properties
cat > sonar-project.properties << EOF
sonar.projectKey=labFusion
sonar.projectName=LabFusion
sonar.projectVersion=1.0.0
sonar.modules=api-gateway
sonar.sources=src/main/java
sonar.tests=src/test/java
sonar.java.binaries=target/classes
sonar.java.test.binaries=target/test-classes
sonar.junit.reportPaths=target/surefire-reports
sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
sonar.host.url=${{ secrets.SONAR_HOST_URL }}
sonar.login=${{ secrets.SONAR_TOKEN }}
EOF
# Run SonarQube analysis
./mvnw sonar:sonar \
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
-Dsonar.login=${{ secrets.SONAR_TOKEN }} \
-Dsonar.projectKey=labFusion \
-Dsonar.projectName="LabFusion" \
-Dsonar.projectVersion=1.0.0 \
-Dsonar.modules=api-gateway \
-Dsonar.sources=src/main/java \
-Dsonar.tests=src/test/java \
-Dsonar.java.binaries=target/classes \
-Dsonar.java.test.binaries=target/test-classes \
-Dsonar.junit.reportPaths=target/surefire-reports \
-Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
- name: Fail if no test reports found
if: env.TEST_REPORTS_EXIST == 'false'
@@ -152,14 +179,10 @@ jobs:
./mvnw pmd:check
- name: Generate code coverage
run: ./mvnw jacoco:report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./services/api-gateway/target/site/jacoco/jacoco.xml
flags: api-gateway
name: api-gateway-coverage
run: |
echo "Generating JaCoCo code coverage report..."
./mvnw jacoco:report
echo "Code coverage report generated at target/site/jacoco/jacoco.xml"
build:
runs-on: [self-hosted]