|
| 1 | +## |
| 2 | +# CI Pipeline — TalentTrust Backend |
| 3 | +# |
| 4 | +# Gates (all must pass before merge): |
| 5 | +# 1. lint — ESLint with TypeScript rules |
| 6 | +# 2. test — Jest with ≥95% line/function/statement coverage |
| 7 | +# 3. build — TypeScript compilation (strict) |
| 8 | +# 4. security — npm audit (fails on HIGH or CRITICAL vulnerabilities) |
| 9 | +# |
| 10 | +# Branch protection: configure GitHub to require all four status checks |
| 11 | +# before merging into `main`. See docs/backend/branch-protection.md. |
| 12 | +## |
| 13 | + |
1 | 14 | name: CI |
2 | 15 |
|
3 | 16 | on: |
|
6 | 19 | pull_request: |
7 | 20 | branches: [main] |
8 | 21 |
|
| 22 | +# Cancel in-progress runs for the same branch to save CI minutes. |
| 23 | +concurrency: |
| 24 | + group: ci-${{ github.ref }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
9 | 27 | jobs: |
| 28 | + # ── 1. Lint ──────────────────────────────────────────────────────────────── |
| 29 | + lint: |
| 30 | + name: Lint |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Setup Node.js |
| 36 | + uses: actions/setup-node@v4 |
| 37 | + with: |
| 38 | + node-version: '20' |
| 39 | + cache: 'npm' |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + run: npm ci |
| 43 | + |
| 44 | + - name: Run ESLint |
| 45 | + run: npm run lint |
| 46 | + |
| 47 | + # ── 2. Test (with coverage) ──────────────────────────────────────────────── |
| 48 | + test: |
| 49 | + name: Test |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Setup Node.js |
| 55 | + uses: actions/setup-node@v4 |
| 56 | + with: |
| 57 | + node-version: '20' |
| 58 | + cache: 'npm' |
| 59 | + |
| 60 | + - name: Install dependencies |
| 61 | + run: npm ci |
| 62 | + |
| 63 | + - name: Run tests with coverage |
| 64 | + run: npm run test:ci |
| 65 | + |
| 66 | + - name: Upload coverage report |
| 67 | + uses: actions/upload-artifact@v4 |
| 68 | + if: always() |
| 69 | + with: |
| 70 | + name: coverage-report |
| 71 | + path: coverage/ |
| 72 | + retention-days: 14 |
| 73 | + |
| 74 | + # ── 3. Build ─────────────────────────────────────────────────────────────── |
10 | 75 | build: |
| 76 | + name: Build |
11 | 77 | runs-on: ubuntu-latest |
| 78 | + needs: [lint, test] |
12 | 79 | steps: |
13 | 80 | - uses: actions/checkout@v4 |
14 | 81 |
|
|
21 | 88 | - name: Install dependencies |
22 | 89 | run: npm ci |
23 | 90 |
|
24 | | - - name: Build |
| 91 | + - name: Compile TypeScript |
25 | 92 | run: npm run build |
26 | 93 |
|
27 | | - - name: Run tests |
28 | | - run: npm test |
| 94 | + - name: Upload build artifact |
| 95 | + uses: actions/upload-artifact@v4 |
| 96 | + with: |
| 97 | + name: dist |
| 98 | + path: dist/ |
| 99 | + retention-days: 7 |
| 100 | + |
| 101 | + # ── 4. Security audit ───────────────────────────────────────────────────── |
| 102 | + security: |
| 103 | + name: Security Audit |
| 104 | + runs-on: ubuntu-latest |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v4 |
| 107 | + |
| 108 | + - name: Setup Node.js |
| 109 | + uses: actions/setup-node@v4 |
| 110 | + with: |
| 111 | + node-version: '20' |
| 112 | + cache: 'npm' |
| 113 | + |
| 114 | + - name: Install dependencies |
| 115 | + run: npm ci |
| 116 | + |
| 117 | + - name: npm audit (HIGH + CRITICAL) |
| 118 | + run: npm run audit:ci |
0 commit comments