feat(backend): propagate correlationId to background jobs #669
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Backend CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - main | |
| tags: | |
| - 'v*' | |
| paths: | |
| - 'backend/**' | |
| - 'sdk/**' | |
| - 'package.json' | |
| - 'pnpm-workspace.yaml' | |
| - '.github/workflows/backend-ci-cd.yml' | |
| pull_request: | |
| branches: | |
| - develop | |
| - main | |
| paths: | |
| - 'backend/**' | |
| - 'sdk/**' | |
| - 'package.json' | |
| - 'pnpm-workspace.yaml' | |
| - '.github/workflows/backend-ci-cd.yml' | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }}/backend | |
| jobs: | |
| # ============================================================================ | |
| # CONTRACTS / SDK: Keep OpenAPI + generated client in sync | |
| # ============================================================================ | |
| openapi-sdk: | |
| runs-on: ubuntu-latest | |
| name: OpenAPI / SDK Sync | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| cache-dependency-path: 'backend/pnpm-lock.yaml' | |
| - name: Install backend dependencies | |
| run: cd backend && pnpm install --frozen-lockfile | |
| - name: Install SDK generator dependencies | |
| run: cd sdk && pnpm install --no-frozen-lockfile | |
| - name: Generate OpenAPI and SDK artifacts | |
| run: pnpm run generate:api-sdk | |
| - name: Run contract tests | |
| run: cd backend && npm run test:contract | |
| - name: Upload generated SDK artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nestera-typed-sdk | |
| path: sdk/src/generated | |
| retention-days: 7 | |
| # ============================================================================ | |
| # TEST: Unit Tests | |
| # ============================================================================ | |
| test: | |
| runs-on: ubuntu-latest | |
| name: Test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| cache-dependency-path: 'backend/pnpm-lock.yaml' | |
| - name: Install dependencies | |
| run: cd backend && pnpm install --frozen-lockfile | |
| - name: Run unit tests | |
| run: cd backend && pnpm run test | |
| - name: Generate coverage report | |
| run: cd backend && pnpm run test:cov | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| files: ./backend/coverage/coverage-final.json | |
| flags: unittests | |
| fail_ci_if_error: false | |
| # ============================================================================ | |
| # BUILD: Ensure the NestJS project compiles cleanly | |
| # ============================================================================ | |
| build: | |
| runs-on: ubuntu-latest | |
| name: Build | |
| needs: | |
| - openapi-sdk | |
| - test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| cache-dependency-path: 'backend/pnpm-lock.yaml' | |
| - name: Install dependencies | |
| run: cd backend && pnpm install --frozen-lockfile | |
| - name: Build | |
| run: cd backend && pnpm run build | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-dist | |
| path: backend/dist | |
| retention-days: 7 | |
| # ============================================================================ | |
| # MIGRATIONS: Validate migrations and test rollbacks | |
| # ============================================================================ | |
| migrations-check: | |
| runs-on: ubuntu-latest | |
| name: Validate Migrations | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_USER: user | |
| POSTGRES_PASSWORD: password | |
| POSTGRES_DB: nestera | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| cache-dependency-path: 'backend/pnpm-lock.yaml' | |
| - name: Install dependencies | |
| run: cd backend && pnpm install --frozen-lockfile | |
| - name: Check idempotency (down methods exist) | |
| run: cd backend && node scripts/check-migrations-down.js | |
| - name: Test Migration Rollbacks | |
| env: | |
| DATABASE_URL: postgresql://user:password@localhost:5432/nestera | |
| run: cd backend && bash scripts/test-rollback.sh |