Some checks failed
Integration Tests / performance-tests (push) Has been cancelled
Integration Tests / integration-tests (push) Has been cancelled
Frontend (React) / test (16) (push) Failing after 1m37s
Frontend (React) / test (20) (push) Failing after 1m28s
Docker Build and Push / build-and-push (push) Failing after 37s
Service Adapters (Python FastAPI) / test (3.1) (push) Failing after 20s
API Docs (Node.js Express) / test (20) (push) Successful in 1m37s
API Docs (Node.js Express) / test (16) (push) Successful in 1m40s
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 24s
API Docs (Node.js Express) / test (18) (push) Successful in 1m39s
Frontend (React) / test (18) (push) Failing after 1m53s
API Gateway (Java Spring Boot) / test (17) (push) Failing after 1m56s
Frontend (React) / build (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 26s
LabFusion CI/CD Pipeline / service-adapters (push) Failing after 23s
LabFusion CI/CD Pipeline / api-gateway (push) Failing after 1m47s
Service Adapters (Python FastAPI) / test (3.9) (push) Failing after 26s
Service Adapters (Python FastAPI) / build (push) Has been skipped
API Gateway (Java Spring Boot) / test (21) (push) Failing after 2m1s
API Docs (Node.js Express) / build (push) Successful in 40s
API Gateway (Java Spring Boot) / build (push) Has been skipped
API Gateway (Java Spring Boot) / security (push) Has been skipped
LabFusion CI/CD Pipeline / api-docs (push) Successful in 1m46s
LabFusion CI/CD Pipeline / frontend (push) Failing after 1m57s
Frontend (React) / lighthouse (push) Has been skipped
LabFusion CI/CD Pipeline / integration-tests (push) Has been skipped
### Summary of Changes - Changed SonarQube project keys and names for all services to follow a consistent naming convention. - Replaced `sonar-scanner` with `@sonar/scan` in the frontend and other workflows for improved compatibility. - Simplified SonarQube analysis commands by removing unnecessary parameters and ensuring each service reports to its dedicated project. ### Expected Results - Enhanced clarity and maintainability of CI configurations. - Improved isolation of quality metrics for each service in SonarQube. - Streamlined integration process for better reporting and analysis.
209 lines
6.3 KiB
YAML
209 lines
6.3 KiB
YAML
name: API Gateway (Java Spring Boot)
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'services/api-gateway/**'
|
|
- '.gitea/workflows/api-gateway.yml'
|
|
pull_request:
|
|
paths:
|
|
- 'services/api-gateway/**'
|
|
|
|
env:
|
|
REGISTRY: gitea.example.com
|
|
IMAGE_PREFIX: labfusion
|
|
SERVICE_NAME: api-gateway
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: [self-hosted]
|
|
env:
|
|
RUNNER_TOOL_CACHE: /toolcache
|
|
defaults:
|
|
run:
|
|
working-directory: ./services/api-gateway
|
|
|
|
strategy:
|
|
matrix:
|
|
java-version: [17, 21]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up JDK ${{ matrix.java-version }}
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: ${{ matrix.java-version }}
|
|
distribution: 'temurin'
|
|
cache: maven
|
|
|
|
- name: Make Maven wrapper executable
|
|
run: chmod +x ./mvnw
|
|
|
|
- name: Verify Maven installation
|
|
run: ./mvnw --version
|
|
|
|
- name: Cache Maven dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.m2/repository
|
|
~/.m2/wrapper
|
|
key: maven-${{ runner.os }}-${{ matrix.java-version }}-${{ hashFiles('**/pom.xml') }}
|
|
restore-keys: |
|
|
maven-${{ runner.os }}-${{ matrix.java-version }}-
|
|
maven-${{ runner.os }}-
|
|
maven-
|
|
fail-on-cache-miss: false
|
|
|
|
- name: Validate POM
|
|
run: ./mvnw validate
|
|
|
|
- name: Compile code
|
|
run: ./mvnw compile
|
|
|
|
- name: Check for test files
|
|
run: |
|
|
echo "Checking for test files in src/test/java/..."
|
|
if [ -d "src/test/java" ]; then
|
|
TEST_COUNT=$(find src/test/java -name "*Test*.java" -type f | wc -l)
|
|
echo "Found $TEST_COUNT test files"
|
|
if [ $TEST_COUNT -eq 0 ]; then
|
|
echo "⚠️ No test files found! Please add test files to src/test/java/"
|
|
echo "TEST_FILES_EXIST=false" >> $GITHUB_ENV
|
|
else
|
|
echo "✅ Test files found"
|
|
echo "TEST_FILES_EXIST=true" >> $GITHUB_ENV
|
|
fi
|
|
else
|
|
echo "❌ No src/test/java directory found!"
|
|
echo "TEST_FILES_EXIST=false" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Fail if no test files exist
|
|
if: env.TEST_FILES_EXIST == 'false'
|
|
run: |
|
|
echo "❌ No test files found in src/test/java/"
|
|
echo "This pipeline requires test files to be present."
|
|
echo "Please add test files with names ending in 'Test.java' or 'Tests.java'"
|
|
echo "Example: src/test/java/com/labfusion/MyServiceTest.java"
|
|
exit 1
|
|
|
|
- name: Run unit tests
|
|
run: |
|
|
echo "Running Maven tests..."
|
|
./mvnw test -X
|
|
echo "Maven test execution completed"
|
|
echo "Checking target directory structure..."
|
|
find target -name "*.xml" -type f 2>/dev/null || echo "No XML files found in target"
|
|
echo "Checking surefire-reports directory..."
|
|
if [ -d "target/surefire-reports" ]; then
|
|
echo "Contents of surefire-reports:"
|
|
ls -la target/surefire-reports/
|
|
else
|
|
echo "surefire-reports directory does not exist"
|
|
echo "Creating surefire-reports directory..."
|
|
mkdir -p target/surefire-reports
|
|
fi
|
|
|
|
- name: Check test reports
|
|
run: |
|
|
echo "Checking for test report files..."
|
|
if [ -d "target/surefire-reports" ]; then
|
|
echo "Surefire reports directory exists"
|
|
ls -la target/surefire-reports/
|
|
if [ -n "$(find target/surefire-reports -name '*.xml' -type f)" ]; then
|
|
echo "✅ Found test report XML files"
|
|
echo "TEST_REPORTS_EXIST=true" >> $GITHUB_ENV
|
|
else
|
|
echo "⚠️ No XML files found in surefire-reports"
|
|
echo "TEST_REPORTS_EXIST=false" >> $GITHUB_ENV
|
|
fi
|
|
else
|
|
echo "❌ Surefire reports directory does not exist"
|
|
echo "TEST_REPORTS_EXIST=false" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Send test results to SonarQube
|
|
if: env.TEST_REPORTS_EXIST == 'true'
|
|
run: |
|
|
echo "Sending test results to SonarQube..."
|
|
./mvnw clean verify sonar:sonar \
|
|
-Dsonar.projectKey=labfusion-api-gateway \
|
|
-Dsonar.projectName=LabFusion API Gateway \
|
|
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
|
|
-Dsonar.token=${{ secrets.SONAR_TOKEN }}
|
|
|
|
- name: Fail if no test reports found
|
|
if: env.TEST_REPORTS_EXIST == 'false'
|
|
run: |
|
|
echo "❌ No test reports were generated!"
|
|
echo "This indicates that either:"
|
|
echo "1. No test files were found in src/test/java/"
|
|
echo "2. Tests failed to execute properly"
|
|
echo "3. Maven Surefire plugin did not generate reports"
|
|
echo ""
|
|
echo "Please ensure you have test files and they are executing correctly."
|
|
exit 1
|
|
|
|
- name: Run code quality checks
|
|
run: |
|
|
./mvnw spotbugs:check
|
|
./mvnw checkstyle:check
|
|
./mvnw pmd:check
|
|
|
|
- name: Generate code 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]
|
|
needs: test
|
|
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: Verify Maven installation
|
|
run: ./mvnw --version
|
|
|
|
- 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: Build application
|
|
run: ./mvnw clean package -DskipTests
|
|
|
|
- name: Build Docker image (test only)
|
|
run: docker build -t api-gateway:test .
|
|
|
|
security:
|
|
runs-on: [self-hosted]
|
|
needs: build
|
|
|