92 lines
2.3 KiB
YAML
92 lines
2.3 KiB
YAML
name: API Gateway CI
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
push:
|
|
branches: [main, deploy-notification-service]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: oudelaa-api-ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
quality-and-tests:
|
|
name: Build, lint, and test
|
|
runs-on: ghaymah2
|
|
services:
|
|
mongodb:
|
|
image: mongo:7
|
|
ports:
|
|
- 27017:27017
|
|
options: >-
|
|
--health-cmd "mongosh --quiet --eval 'db.runCommand({ ping: 1 })'"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Use Node.js 20
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
|
|
- name: Install locked dependencies
|
|
run: npm ci
|
|
|
|
- name: Build API Gateway and project artifacts
|
|
run: npm run build
|
|
|
|
- name: Lint
|
|
run: npm run lint
|
|
|
|
- name: Unit and coverage tests
|
|
run: npm run test:coverage
|
|
|
|
- name: Upload coverage report
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: coverage-report
|
|
path: coverage/
|
|
if-no-files-found: error
|
|
retention-days: 14
|
|
|
|
- name: Performance tooling tests
|
|
run: npm run test:perf
|
|
|
|
- name: End-to-end tests
|
|
run: npm run test:e2e
|
|
env:
|
|
E2E_MONGODB_URI: mongodb://127.0.0.1:27017/oudelaa-e2e
|
|
|
|
- name: Dependency security audit
|
|
run: npm audit --audit-level=high
|
|
|
|
verify-image:
|
|
name: Build API Gateway image
|
|
needs: quality-and-tests
|
|
runs-on: ghaymah2
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Verify Docker runner access
|
|
run: docker info
|
|
|
|
- name: Build CI image locally
|
|
run: docker build --tag oudelaa-api:${{ github.sha }} .
|
|
|
|
- name: Verify image entrypoint and media tools
|
|
run: |
|
|
docker image inspect oudelaa-api:${{ github.sha }} --format '{{json .Config.Cmd}}' | grep -F 'dist/apps/api-gateway/apps/api-gateway/src/main.js'
|
|
docker run --rm --entrypoint ffmpeg oudelaa-api:${{ github.sha }} -version
|
|
docker run --rm --entrypoint ffprobe oudelaa-api:${{ github.sha }} -version
|