-
Notifications
You must be signed in to change notification settings - Fork 32
137 lines (115 loc) · 3.83 KB
/
Copy pathci.yml
File metadata and controls
137 lines (115 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# Cancel in-progress runs for the same branch/PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
secrets-scan:
name: Secrets Scanning (Gitleaks)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Gitleaks Scan
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
vulnerability-scan:
name: Dependency Vulnerability Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm audit --audit-level=high
commitlint:
name: Commit Message Lint
runs-on: ubuntu-latest
# Only meaningful on PRs — on direct pushes to main we skip this check
# since squash merges are handled by the branch protection rule.
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
# Fetch enough history to validate all commits in the PR.
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm install
# Lint every commit in the PR from the merge base to HEAD.
- name: Lint commit messages
run: |
npx commitlint \
--from ${{ github.event.pull_request.base.sha }} \
--to ${{ github.event.pull_request.head.sha }} \
--verbose
backend:
name: Backend (Nest) – Node ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20, 22]
# Spin up a PostgreSQL service container so Prisma can connect during the
# migrate step (migrate deploy requires a live DB).
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: vortex
POSTGRES_PASSWORD: vortex
POSTGRES_DB: vortex
ports:
- 5432:5432
# Wait until postgres is healthy before the steps run.
options: >-
--health-cmd="pg_isready -U vortex"
--health-interval=10s
--health-timeout=5s
--health-retries=5
env:
DATABASE_URL: postgresql://vortex:vortex@localhost:5432/vortex?schema=public
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run lint
- run: npm run typecheck
- run: npm run build
- run: npm test -- --coverage
- run: npm run test:e2e
node-version: 20
cache: npm
- name: Install dependencies
run: npm install
# ── Prisma ──────────────────────────────────────────────────────────────
- name: Validate Prisma schema
run: npm run db:validate
- name: Generate Prisma client
run: npm run db:generate
# Apply all pending migrations to the CI database so the schema stays in
# sync and any broken migration SQL is caught before merge.
- name: Run database migrations
run: npm run db:migrate:prod
# ── Build & test ────────────────────────────────────────────────────────
- name: Lint
run: npm run lint
- name: Type-check
run: npm run typecheck
- name: Build
run: npm run build
- name: Unit tests
run: npm test
- name: E2E tests
run: npm run test:e2e