Files
labFusion/.gitea/workflows/api-docs.yml
GSRN 5cecc52572 fix: Resolve cache timeout issues in CI/CD pipelines
- Add fail-on-cache-miss: false to all cache actions in workflows
- Create improved runner configuration (config_cache_fixed.yaml) with:
  - Fixed cache host: host.docker.internal
  - Fixed cache port: 44029
  - Host network mode for better container networking
- Add cache troubleshooting scripts:
  - fix-cache-issues.sh (Linux/macOS)
  - fix-cache-issues.ps1 (Windows)
- Update all workflows: api-gateway, frontend, service-adapters, api-docs, ci

This resolves the 'connect ETIMEDOUT 172.31.0.3:44029' errors by:
1. Making cache failures non-fatal
2. Using proper Docker networking configuration
3. Providing tools to diagnose and fix cache issues
2025-09-15 16:40:52 +02:00

173 lines
4.7 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/**'
env:
REGISTRY: gitea.example.com
IMAGE_PREFIX: labfusion
SERVICE_NAME: api-docs
jobs:
test:
runs-on: [self-hosted]
defaults:
run:
working-directory: ./services/api-docs
strategy:
matrix:
node-version: [16, 18, 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
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('services/api-docs/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node-version }}-
${{ runner.os }}-node-
${{ runner.os }}-
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 --watchAll=false
npm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./services/api-docs/coverage/lcov.info
flags: api-docs
name: api-docs-coverage
- 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 18
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-18-${{ hashFiles('services/api-docs/package.json') }}
restore-keys: |
${{ runner.os }}-node-18-
${{ 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
- name: Build Docker image (test only)
run: docker build -t api-docs:test .