|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["**"] |
| 6 | + pull_request: |
| 7 | + branches: ["**"] |
| 8 | + |
| 9 | +jobs: |
| 10 | + ci: |
| 11 | + name: Typecheck · Test · Coverage |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + node-version: [20.x] |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Setup Node ${{ matrix.node-version }} |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: ${{ matrix.node-version }} |
| 26 | + cache: "npm" |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: npm ci |
| 30 | + |
| 31 | + # ── Secrets guard ──────────────────────────────────────────────────── |
| 32 | + # Fail fast if any file tracked by git contains a raw secret pattern. |
| 33 | + # This catches accidental commits of .env files or hardcoded credentials. |
| 34 | + - name: Check for secrets in repo |
| 35 | + run: | |
| 36 | + # Reject any file that looks like a real .env (not .env.example) |
| 37 | + if git ls-files | grep -E '^\.env$|^\.env\.' ; then |
| 38 | + echo "ERROR: .env file is tracked by git — remove it immediately" |
| 39 | + exit 1 |
| 40 | + fi |
| 41 | + # Reject placeholder JWT_SECRET if it somehow ends up in source |
| 42 | + if git grep -l 'dev-secret-key-change-in-production' -- '*.ts' '*.js' '*.json' 2>/dev/null; then |
| 43 | + echo "ERROR: hardcoded dev secret found in source files" |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | + echo "Secrets check passed" |
| 47 | +
|
| 48 | + # ── Type safety ────────────────────────────────────────────────────── |
| 49 | + - name: Typecheck |
| 50 | + run: npm run build |
| 51 | + |
| 52 | + # ── Tests (integration suite — tests/) ─────────────────────────────── |
| 53 | + - name: Test (tests/ suite) |
| 54 | + run: npm test |
| 55 | + env: |
| 56 | + JWT_SECRET: ci-test-secret-at-least-32-chars-long |
| 57 | + NODE_ENV: test |
| 58 | + |
| 59 | + # ── Tests (unit suite — src/) ───────────────────────────────────────── |
| 60 | + - name: Test (src/ suite) |
| 61 | + run: npm run test:src |
| 62 | + env: |
| 63 | + JWT_SECRET: ci-test-secret-at-least-32-chars-long |
| 64 | + NODE_ENV: test |
| 65 | + |
| 66 | + # ── Coverage (integration suite with threshold enforcement) ─────────── |
| 67 | + - name: Coverage check (tests/ suite) |
| 68 | + run: npm run test:coverage |
| 69 | + env: |
| 70 | + JWT_SECRET: ci-test-secret-at-least-32-chars-long |
| 71 | + NODE_ENV: test |
| 72 | + |
| 73 | + # ── Coverage (unit suite — src/ — ≥95% on changed modules) ─────────── |
| 74 | + - name: Coverage check (src/ suite) |
| 75 | + run: npm run test:coverage:src |
| 76 | + env: |
| 77 | + JWT_SECRET: ci-test-secret-at-least-32-chars-long |
| 78 | + NODE_ENV: test |
0 commit comments