Files
labFusion/.gitea/workflows/api-gateway.yml
GSRN 64653a91da
Some checks failed
Integration Tests / integration-tests (push) Failing after 31s
Integration Tests / performance-tests (push) Has been skipped
Docker Build and Push / build-and-push (push) Failing after 36s
API Gateway (Java Spring Boot) / test (17) (push) Successful in 1m7s
API Gateway (Java Spring Boot) / test (21) (push) Successful in 1m13s
API Gateway (Java Spring Boot) / build (push) Successful in 39s
API Gateway (Java Spring Boot) / security (push) Failing after 0s
chore: Simplify CI workflow for api-gateway by removing redundant test checks
### Summary of Changes
- Removed checks for the existence of test files and test reports in the CI workflow for `api-gateway.yml`, streamlining the process.
- Updated the workflow to focus on running unit tests and sending results to SonarQube without pre-checks.

### Expected Results
- Enhanced efficiency of the CI process by eliminating unnecessary steps, allowing for quicker feedback on code changes.
2025-09-17 00:51:25 +02:00

164 lines
4.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/**'
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
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 }}" \
-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 .
security:
runs-on: [self-hosted]
needs: build