Files
labFusion/.gitea/workflows/ci.yml
GSRN 6f8d7f6ca9
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
feat: Integrate SonarQube analysis into CI workflows
### 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.
2025-09-15 19:55:13 +02:00

327 lines
9.1 KiB
YAML

name: LabFusion CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
env:
REGISTRY: gitea.example.com
IMAGE_PREFIX: labfusion
jobs:
# Java Spring Boot API Gateway
api-gateway:
runs-on: [self-hosted]
env:
RUNNER_TOOL_CACHE: /toolcache
defaults:
run:
working-directory: ./services/api-gateway
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Make Maven wrapper executable
run: chmod +x ./mvnw
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: |
~/.m2/repository
~/.m2/wrapper
key: maven-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-${{ runner.os }}-
maven-
fail-on-cache-miss: false
- 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
- name: Build application
run: ./mvnw clean package -DskipTests
- name: Build Docker image (test only)
run: docker build -t api-gateway:test .
# Python FastAPI Service Adapters
service-adapters:
runs-on: [self-hosted]
env:
RUNNER_TOOL_CACHE: /toolcache
defaults:
run:
working-directory: ./services/service-adapters
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Cache pip dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.local/lib/python*/site-packages
key: pip-${{ runner.os }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
pip-${{ runner.os }}-
pip-
fail-on-cache-miss: false
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov flake8 black isort
- name: Run code formatting check
run: |
black --check .
isort --check-only .
- name: Run linting
run: flake8 . --count --max-complexity=10 --max-line-length=150
- name: Run tests
run: |
pytest --cov=. --cov-report=xml --cov-report=html --junitxml=tests/reports/junit.xml
- 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 .
# Node.js API Documentation Service
api-docs:
runs-on: [self-hosted]
env:
RUNNER_TOOL_CACHE: /toolcache
defaults:
run:
working-directory: ./services/api-docs
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: |
~/.npm
node_modules
~/.cache/node-gyp
key: npm-${{ runner.os }}-18-${{ hashFiles('services/api-docs/package-lock.json') }}
restore-keys: |
npm-${{ runner.os }}-18-
npm-${{ runner.os }}-
npm-
fail-on-cache-miss: false
- name: Install dependencies
run: |
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi
- name: Run linting
run: npm run lint
- name: Run tests
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
- name: Build Docker image (test only)
run: docker build -t api-docs:test .
# React Frontend
frontend:
runs-on: [self-hosted]
env:
RUNNER_TOOL_CACHE: /toolcache
defaults:
run:
working-directory: ./frontend
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: |
~/.npm
node_modules
~/.cache/node-gyp
key: npm-${{ runner.os }}-18-${{ hashFiles('frontend/package-lock.json') }}
restore-keys: |
npm-${{ runner.os }}-18-
npm-${{ runner.os }}-
npm-
fail-on-cache-miss: false
- name: Install dependencies
run: |
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi
- name: Run linting
run: npm run lint
- name: Run tests
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
- name: Build Docker image (test only)
run: docker build -t frontend:test .
# Integration Tests
integration-tests:
runs-on: [self-hosted]
needs: [api-gateway, service-adapters, api-docs, frontend]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Start services with Docker Compose
run: |
docker-compose -f docker-compose.dev.yml up -d
sleep 30 # Wait for services to start
- name: Run integration tests
run: |
# Test API Gateway health
curl -f http://localhost:8080/actuator/health || exit 1
# Test Service Adapters health
curl -f http://localhost:8000/health || exit 1
# Test API Docs health
curl -f http://localhost:3000/health || exit 1
# Test Frontend build
curl -f http://localhost:3001 || exit 1
- name: Stop services
if: always()
run: docker-compose -f docker-compose.dev.yml down