Some checks failed
API Docs (Node.js Express) / test (20) (push) Failing after 43s
API Docs (Node.js Express) / build (push) Has been skipped
Integration Tests / integration-tests (push) Failing after 24s
Integration Tests / performance-tests (push) Has been skipped
Frontend (React) / test (20) (push) Failing after 1m25s
Frontend (React) / build (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 23s
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 23s
Frontend (React) / lighthouse (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.13) (push) Failing after 22s
Service Adapters (Python FastAPI) / build (push) Has been skipped
API Gateway (Java Spring Boot) / test (17) (push) Successful in 2m1s
API Gateway (Java Spring Boot) / test (21) (push) Successful in 2m7s
API Gateway (Java Spring Boot) / build (push) Successful in 2m2s
### Summary of Changes - Removed unnecessary Docker build steps from the CI workflows for API Docs, API Gateway, and Frontend. - Streamlined the build process by eliminating duplicate commands, enhancing clarity and maintainability. ### Expected Results - Improved readability of CI configuration and reduced complexity in the build process, making it easier to manage and update in the future.
203 lines
5.6 KiB
YAML
203 lines
5.6 KiB
YAML
name: API Docs (Node.js Express)
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'services/api-docs/**'
|
|
- '.gitea/workflows/api-docs.yml'
|
|
pull_request:
|
|
paths:
|
|
- 'services/api-docs/**'
|
|
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-docs
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: [self-hosted]
|
|
env:
|
|
RUNNER_TOOL_CACHE: /toolcache
|
|
defaults:
|
|
run:
|
|
working-directory: ./services/api-docs
|
|
|
|
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('services/api-docs/package-lock.json') }}
|
|
restore-keys: |
|
|
npm-${{ runner.os }}-${{ matrix.node-version }}-
|
|
npm-${{ runner.os }}-
|
|
npm-
|
|
fail-on-cache-miss: false
|
|
id: npm-cache
|
|
|
|
- name: Cache status
|
|
run: |
|
|
if [ "${{ steps.npm-cache.outputs.cache-hit }}" == "true" ]; then
|
|
echo "✅ Cache hit! Dependencies will be restored from cache."
|
|
else
|
|
echo "❌ Cache miss. Dependencies will be downloaded fresh."
|
|
fi
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
if [ -f package-lock.json ]; then
|
|
npm ci || npm install
|
|
else
|
|
npm install
|
|
fi
|
|
|
|
- name: Verify dependencies installation
|
|
run: |
|
|
if [ ! -d "node_modules" ]; then
|
|
echo "Dependencies not installed, running npm install..."
|
|
npm install
|
|
fi
|
|
echo "Dependencies verified successfully"
|
|
|
|
- name: Add node_modules/.bin to PATH
|
|
run: echo "$(pwd)/node_modules/.bin" >> $GITHUB_PATH
|
|
|
|
- name: Verify ESLint installation
|
|
run: |
|
|
if ! npx eslint --version > /dev/null 2>&1; then
|
|
echo "ESLint not found, installing..."
|
|
npm install eslint eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-promise --save-dev
|
|
fi
|
|
echo "ESLint verified successfully"
|
|
|
|
- name: Run linting
|
|
run: |
|
|
npx eslint . --ext .js
|
|
npx eslint . --ext .js --fix-dry-run
|
|
|
|
- name: Run type checking
|
|
run: npm run type-check
|
|
|
|
- name: Run security audit
|
|
run: |
|
|
npm audit --audit-level=moderate
|
|
npm audit fix --dry-run
|
|
|
|
- name: Run tests
|
|
run: |
|
|
npm test -- --coverage --coverageReporters=lcov --coverageReporters=text --coverageReporters=html
|
|
npm run test:coverage
|
|
|
|
- name: Send results to SonarQube
|
|
run: |
|
|
echo "Sending API Docs 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-api-docs \
|
|
-Dsonar.projectName=LabFusion API Docs
|
|
|
|
- name: Test results summary
|
|
if: always()
|
|
run: |
|
|
echo "Test results available in pipeline logs"
|
|
echo "Coverage report: services/api-docs/coverage/"
|
|
echo "Jest test results: services/api-docs/test-results/"
|
|
|
|
build:
|
|
runs-on: [self-hosted]
|
|
needs: test
|
|
defaults:
|
|
run:
|
|
working-directory: ./services/api-docs
|
|
|
|
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('services/api-docs/package.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-20-
|
|
${{ runner.os }}-node-
|
|
fail-on-cache-miss: false
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
if [ -f package-lock.json ]; then
|
|
npm ci || npm install
|
|
else
|
|
npm install
|
|
fi
|
|
|
|
- name: Verify dependencies installation
|
|
run: |
|
|
if [ ! -d "node_modules" ]; then
|
|
echo "Dependencies not installed, running npm install..."
|
|
npm install
|
|
fi
|
|
echo "Dependencies verified successfully"
|
|
|
|
- name: Add node_modules/.bin to PATH
|
|
run: echo "$(pwd)/node_modules/.bin" >> $GITHUB_PATH
|
|
|
|
- name: Verify ESLint installation
|
|
run: |
|
|
if ! npx eslint --version > /dev/null 2>&1; then
|
|
echo "ESLint not found, installing..."
|
|
npm install eslint eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-promise --save-dev
|
|
fi
|
|
echo "ESLint verified successfully"
|
|
|
|
- name: Build application
|
|
run: npm run build |