forked from ceejaylaboratory/AnchorPoint
-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (117 loc) · 3.87 KB
/
Copy pathbackend.yml
File metadata and controls
133 lines (117 loc) · 3.87 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
name: Backend CI/CD
on:
push:
branches: ["**"]
paths:
- 'backend/**'
- '.github/workflows/backend.yml'
pull_request:
branches: [main]
paths:
- 'backend/**'
- '.github/workflows/backend.yml'
jobs:
validate:
name: Validate Migration Integrity
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres:15
env:
POSTGRES_USER: prisma
POSTGRES_PASSWORD: prisma_password
POSTGRES_DB: cidb
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres-shadow:
image: postgres:15
env:
POSTGRES_USER: prisma
POSTGRES_PASSWORD: prisma_password
POSTGRES_DB: shadowdb
ports:
- 5433:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Install dependencies
run: npm install
# Generate the Prisma client before any migration steps so that all
# downstream commands (migrate deploy, migrate diff, ts-node scripts)
# have the correct client bindings available.
- name: Generate Prisma client
env:
DATABASE_URL: "postgresql://prisma:prisma_password@localhost:5432/cidb"
run: npx prisma generate
# Fast environment check — fails immediately with a clear message if
# DATABASE_URL is missing or malformed, rather than surfacing a cryptic
# Prisma error several steps later.
- name: Validate migration environment
env:
DATABASE_URL: "postgresql://prisma:prisma_password@localhost:5432/cidb"
run: node scripts/validate-migration-env.js
- name: Verify Migrations Against Temporary Database
env:
DATABASE_URL: "postgresql://prisma:prisma_password@localhost:5432/cidb"
SHADOW_DATABASE_URL: "postgresql://prisma:prisma_password@localhost:5433/shadowdb"
run: npm run migrate:verify
- name: Run Migration Integrity Checker
env:
DATABASE_URL: "postgresql://prisma:prisma_password@localhost:5432/cidb"
SHADOW_DATABASE_URL: "postgresql://prisma:prisma_password@localhost:5433/shadowdb"
run: node scripts/check-migrations.js
# Emit migration status as an artefact so reviewers can see which
# migrations are applied without re-running CI.
- name: Report migration status
if: always()
env:
DATABASE_URL: "postgresql://prisma:prisma_password@localhost:5432/cidb"
run: |
echo "## Migration Status" > migration-status.md
npx prisma migrate status >> migration-status.md 2>&1 || true
- name: Upload migration status report
if: always()
uses: actions/upload-artifact@v4
with:
name: migration-status
path: backend/migration-status.md
retention-days: 7
- name: Audit dependencies
continue-on-error: true
run: npm audit --audit-level=high
- name: Run Lint
run: npm run lint
- name: Run Tests
env:
DATABASE_URL: "file:./test.db"
run: npm test
- name: Cleanup test artifacts
if: always()
run: rm -rf coverage logs test.db* migration-status.md