Files
labFusion/.gitea/workflows/api-gateway.yml
GSRN dddf59eae1
Some checks failed
Integration Tests / integration-tests (push) Failing after 30s
Integration Tests / performance-tests (push) Has been skipped
Docker Build and Push / build-and-push (push) Failing after 37s
API Gateway (Java Spring Boot) / test (17) (push) Successful in 1m49s
API Gateway (Java Spring Boot) / test (21) (push) Successful in 1m52s
API Gateway (Java Spring Boot) / build (push) Successful in 40s
chore: Remove conditional check for test reports in CI workflow for api-gateway
### Summary of Changes
- Eliminated the conditional check for the existence of test reports in the CI workflow for `api-gateway.yml`, further streamlining the process.
- This change continues to enhance the efficiency of the CI pipeline by focusing on essential steps without unnecessary pre-checks.

### Expected Results
- Improved CI workflow efficiency, allowing for faster feedback on code changes and reducing complexity in the build process.
2025-09-17 00:54:47 +02:00

159 lines
4.2 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/**'
workflow_dispatch:
inputs:
run_tests:
description: 'Run tests'
required: false
default: true
type: boolean
run_lint:
description: 'Run linting'
required: false
default: true
type: boolean
run_build:
description: 'Run build'
required: false
default: true
type: boolean
run_sonar:
description: 'Run SonarQube analysis'
required: false
default: true
type: boolean
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: 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: Send test results to SonarQube
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 }}" \
-Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml \
-Dsonar.junit.reportPaths=target/surefire-reports
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 .