Refactor test files for improved readability and consistency #197
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 Quality Gates | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| quality: | |
| name: Quality gates | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_DB: learnault_ci | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U postgres -d learnault_ci" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| redis: | |
| image: redis:7-alpine | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| env: | |
| NODE_ENV: test | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/learnault_ci?schema=public | |
| REDIS_URL: redis://localhost:6379 | |
| JWT_SECRET: ci-test-secret | |
| AUDIT_IP_HASH_SECRET: ci-audit-secret | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.0.0 | |
| run_install: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Check Prisma formatting | |
| run: pnpm prisma:format:check | |
| - name: Generate Prisma Client | |
| run: pnpm db:generate | |
| - name: Validate migrations on an empty database | |
| run: pnpm db:deploy | |
| - name: Check formatting | |
| run: pnpm format:check | |
| - name: Lint | |
| run: pnpm lint | |
| - name: Type check | |
| run: pnpm typecheck | |
| - name: Run tests | |
| run: pnpm test:ci | |
| - name: Enforce coverage | |
| run: pnpm test:coverage | |
| - name: Build | |
| run: pnpm build | |
| - name: Upload failure diagnostics | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ci-failure-diagnostics | |
| path: | | |
| coverage/ | |
| **/test-results/** | |
| **/*.log | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| - name: Upload coverage report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage/ | |
| if-no-files-found: ignore | |
| retention-days: 7 |