Some checks failed
API Gateway (Java Spring Boot) / test (17) (push) Failing after 35s
API Gateway (Java Spring Boot) / test (21) (push) Failing after 36s
API Gateway (Java Spring Boot) / build (push) Has been skipped
API Gateway (Java Spring Boot) / security (push) Has been skipped
Integration Tests / integration-tests (push) Failing after 34s
Integration Tests / performance-tests (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.1) (push) Failing after 14s
API Docs (Node.js Express) / test (20) (push) Successful in 1m29s
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 41s
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 43s
Frontend (React) / test (20) (push) Successful in 1m44s
Service Adapters (Python FastAPI) / test (3.9) (push) Failing after 43s
Service Adapters (Python FastAPI) / build (push) Has been skipped
API Docs (Node.js Express) / build (push) Successful in 40s
Docker Build and Push / build-and-push (push) Failing after 3m6s
Frontend (React) / build (push) Successful in 2m26s
Frontend (React) / lighthouse (push) Has been skipped
### Summary of Changes - Introduced `workflow_dispatch` inputs for `run_tests`, `run_lint`, `run_build`, and `run_sonar` in the CI workflows for `api-docs`, `api-gateway`, `frontend`, and `service-adapters`. - This enhancement allows for more flexible and controlled execution of CI processes, enabling developers to selectively run tests, linting, builds, and SonarQube analysis. ### Expected Results - Improved configurability of CI workflows, facilitating better management of build and testing processes based on specific needs.
202 lines
5.2 KiB
YAML
202 lines
5.2 KiB
YAML
name: Frontend (React)
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'frontend/**'
|
|
- '.gitea/workflows/frontend.yml'
|
|
pull_request:
|
|
paths:
|
|
- 'frontend/**'
|
|
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: frontend
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: [self-hosted]
|
|
env:
|
|
RUNNER_TOOL_CACHE: /toolcache
|
|
defaults:
|
|
run:
|
|
working-directory: ./frontend
|
|
|
|
strategy:
|
|
matrix:
|
|
node-version: [20]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
|
|
- name: Cache npm dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.npm
|
|
node_modules
|
|
~/.cache/node-gyp
|
|
key: npm-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('frontend/package-lock.json') }}
|
|
restore-keys: |
|
|
npm-${{ runner.os }}-${{ matrix.node-version }}-
|
|
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
|
|
npm run lint:fix --dry-run
|
|
|
|
- name: Run security audit
|
|
run: |
|
|
npm audit --audit-level=moderate
|
|
npm audit fix --dry-run
|
|
|
|
- name: Run tests
|
|
run: |
|
|
npx vitest run --coverage --reporter=verbose
|
|
|
|
- name: Verify coverage files
|
|
run: |
|
|
echo "Checking coverage files..."
|
|
ls -la coverage/
|
|
echo "Required coverage files:"
|
|
if [ -f "coverage/lcov.info" ]; then
|
|
echo "✓ lcov.info found"
|
|
else
|
|
echo "✗ lcov.info missing"
|
|
fi
|
|
|
|
- name: Send results to SonarQube
|
|
run: |
|
|
echo "Sending Frontend results to SonarQube..."
|
|
# Install SonarQube Scanner for Node.js
|
|
npm install -g @sonar/scan
|
|
|
|
# Run SonarQube analysis
|
|
sonar-scanner \
|
|
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
|
|
-Dsonar.login=${{ secrets.SONAR_TOKEN }} \
|
|
-Dsonar.projectKey=labfusion-frontend \
|
|
-Dsonar.projectName=LabFusion Frontend \
|
|
-Dsonar.sources=src \
|
|
-Dsonar.tests=src \
|
|
-Dsonar.sources.inclusions=**/*.js,**/*.jsx \
|
|
-Dsonar.sources.exclusions=**/*.test.js,**/*.test.jsx,**/*.spec.js,**/*.spec.jsx,src/index.js,src/setupTests.js \
|
|
-Dsonar.tests.inclusions=**/*.test.js,**/*.test.jsx,**/*.spec.js,**/*.spec.jsx \
|
|
-Dsonar.coverage.exclusions=**/*.test.js,**/*.test.jsx,**/*.spec.js,**/*.spec.jsx,src/index.js,src/setupTests.js \
|
|
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
|
|
|
|
- name: Test results summary
|
|
if: always()
|
|
run: |
|
|
echo "Test results available in pipeline logs"
|
|
echo "Coverage report: frontend/coverage/"
|
|
echo "Vitest test results: frontend/test-results/"
|
|
|
|
build:
|
|
runs-on: [self-hosted]
|
|
needs: test
|
|
defaults:
|
|
run:
|
|
working-directory: ./frontend
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js 20
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Cache npm dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-node-20-${{ hashFiles('frontend/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-20-
|
|
${{ runner.os }}-node-
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
if [ -f package-lock.json ]; then
|
|
npm ci
|
|
else
|
|
npm install
|
|
fi
|
|
|
|
- name: Build application
|
|
run: |
|
|
npm run build
|
|
npm run build:analyze
|
|
|
|
- name: Build artifacts summary
|
|
run: |
|
|
echo "Build artifacts created in frontend/build/"
|
|
echo "Build analysis available in pipeline logs"
|
|
|
|
- name: Build Docker image (test only)
|
|
run: docker build -t frontend:test .
|
|
|
|
lighthouse:
|
|
runs-on: [self-hosted]
|
|
needs: build
|
|
if: github.event_name == 'pull_request'
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build application for Lighthouse
|
|
run: |
|
|
cd frontend
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: Run Lighthouse CI
|
|
uses: treosh/lighthouse-ci-action@v10
|
|
with:
|
|
configPath: './frontend/.lighthouserc.json'
|
|
uploadArtifacts: true
|
|
temporaryPublicStorage: true
|