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
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:
@@ -101,15 +101,27 @@ jobs:
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
npm test -- --coverage --watchAll=false
|
||||
npm test -- --coverage --watchAll=false --coverageReporters=lcov --coverageReporters=text --coverageReporters=html
|
||||
npm run test:coverage
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
file: ./services/api-docs/coverage/lcov.info
|
||||
flags: api-docs
|
||||
name: api-docs-coverage
|
||||
- name: Send results to SonarQube
|
||||
run: |
|
||||
echo "Sending API Docs results to SonarQube..."
|
||||
# Install SonarQube Scanner for Node.js
|
||||
npm install -g sonar-scanner
|
||||
|
||||
# Run SonarQube analysis
|
||||
sonar-scanner \
|
||||
-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-docs \
|
||||
-Dsonar.sources=. \
|
||||
-Dsonar.tests=__tests__ \
|
||||
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info \
|
||||
-Dsonar.testExecutionReportPaths=test-results.xml
|
||||
|
||||
- name: Test results summary
|
||||
if: always()
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -49,6 +49,26 @@ jobs:
|
||||
- name: Run tests
|
||||
run: ./mvnw test
|
||||
|
||||
- name: Generate code coverage
|
||||
run: ./mvnw jacoco:report
|
||||
|
||||
- name: Send results to SonarQube
|
||||
run: |
|
||||
echo "Sending API Gateway results to SonarQube..."
|
||||
./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: Run code quality checks
|
||||
run: ./mvnw spotbugs:check checkstyle:check
|
||||
|
||||
@@ -104,13 +124,26 @@ jobs:
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
pytest --cov=. --cov-report=xml --cov-report=html
|
||||
pytest --cov=. --cov-report=xml --cov-report=html --junitxml=tests/reports/junit.xml
|
||||
|
||||
- name: Upload coverage reports
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
file: ./coverage.xml
|
||||
flags: service-adapters
|
||||
- name: Send results to SonarQube
|
||||
run: |
|
||||
echo "Sending Service Adapters results to SonarQube..."
|
||||
# Install SonarQube Scanner for Python
|
||||
pip install sonar-scanner
|
||||
|
||||
# Run SonarQube analysis
|
||||
sonar-scanner \
|
||||
-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=service-adapters \
|
||||
-Dsonar.sources=. \
|
||||
-Dsonar.tests=tests \
|
||||
-Dsonar.python.coverage.reportPaths=coverage.xml \
|
||||
-Dsonar.python.xunit.reportPath=tests/reports/junit.xml
|
||||
|
||||
- name: Build Docker image (test only)
|
||||
run: docker build -t service-adapters:test .
|
||||
@@ -159,7 +192,26 @@ jobs:
|
||||
run: npm run lint
|
||||
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
run: npm test -- --coverage --coverageReporters=lcov --coverageReporters=text --coverageReporters=html
|
||||
|
||||
- name: Send results to SonarQube
|
||||
run: |
|
||||
echo "Sending API Docs results to SonarQube..."
|
||||
# Install SonarQube Scanner for Node.js
|
||||
npm install -g sonar-scanner
|
||||
|
||||
# Run SonarQube analysis
|
||||
sonar-scanner \
|
||||
-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-docs \
|
||||
-Dsonar.sources=. \
|
||||
-Dsonar.tests=__tests__ \
|
||||
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info \
|
||||
-Dsonar.testExecutionReportPaths=test-results.xml
|
||||
|
||||
- name: Build application
|
||||
run: npm run build
|
||||
@@ -211,7 +263,26 @@ jobs:
|
||||
run: npm run lint
|
||||
|
||||
- name: Run tests
|
||||
run: npm test -- --coverage --watchAll=false
|
||||
run: npm test -- --coverage --watchAll=false --coverageReporters=lcov --coverageReporters=text --coverageReporters=html
|
||||
|
||||
- name: Send results to SonarQube
|
||||
run: |
|
||||
echo "Sending Frontend results to SonarQube..."
|
||||
# Install SonarQube Scanner for Node.js
|
||||
npm install -g sonar-scanner
|
||||
|
||||
# Run SonarQube analysis
|
||||
sonar-scanner \
|
||||
-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=frontend \
|
||||
-Dsonar.sources=src \
|
||||
-Dsonar.tests=src \
|
||||
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info \
|
||||
-Dsonar.testExecutionReportPaths=test-results.xml
|
||||
|
||||
- name: Build application
|
||||
run: npm run build
|
||||
|
||||
@@ -73,15 +73,27 @@ jobs:
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
npm test -- --coverage --watchAll=false --passWithNoTests
|
||||
npm test -- --coverage --watchAll=false --passWithNoTests --coverageReporters=lcov --coverageReporters=text --coverageReporters=html
|
||||
npm run test:coverage
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
file: ./frontend/coverage/lcov.info
|
||||
flags: frontend
|
||||
name: frontend-coverage
|
||||
- name: Send results to SonarQube
|
||||
run: |
|
||||
echo "Sending Frontend results to SonarQube..."
|
||||
# Install SonarQube Scanner for Node.js
|
||||
npm install -g sonar-scanner
|
||||
|
||||
# Run SonarQube analysis
|
||||
sonar-scanner \
|
||||
-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=frontend \
|
||||
-Dsonar.sources=src \
|
||||
-Dsonar.tests=src \
|
||||
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info \
|
||||
-Dsonar.testExecutionReportPaths=test-results.xml
|
||||
|
||||
- name: Test results summary
|
||||
if: always()
|
||||
|
||||
@@ -85,15 +85,28 @@ jobs:
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
pytest --cov=. --cov-report=xml --cov-report=html --cov-report=term-missing
|
||||
pytest --cov=. --cov-report=xml --cov-report=html --cov-report=term-missing --junitxml=tests/reports/junit.xml
|
||||
pytest --cov=. --cov-report=xml --cov-report=html --cov-report=term-missing --cov-fail-under=80
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
file: ./services/service-adapters/coverage.xml
|
||||
flags: service-adapters
|
||||
name: service-adapters-coverage
|
||||
- name: Send results to SonarQube
|
||||
run: |
|
||||
echo "Sending Service Adapters results to SonarQube..."
|
||||
# Install SonarQube Scanner for Python
|
||||
pip install sonar-scanner
|
||||
|
||||
# Run SonarQube analysis
|
||||
sonar-scanner \
|
||||
-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=service-adapters \
|
||||
-Dsonar.sources=. \
|
||||
-Dsonar.tests=tests \
|
||||
-Dsonar.python.coverage.reportPaths=coverage.xml \
|
||||
-Dsonar.python.xunit.reportPath=tests/reports/junit.xml
|
||||
|
||||
|
||||
- name: Test results summary
|
||||
if: always()
|
||||
|
||||
Reference in New Issue
Block a user