forked from Pulsefy/Lumenpulse
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (94 loc) · 2.62 KB
/
Copy pathbackend.yml
File metadata and controls
111 lines (94 loc) · 2.62 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
name: Backend CI
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- 'apps/backend/**'
pull_request:
branches: [ "main" ]
paths:
- 'apps/backend/**'
- 'apps/backend/.ci-trigger'
jobs:
backend-checks:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./apps/backend
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
cache-dependency-path: './apps/backend/package-lock.json'
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Type Check
# Check if script exists to avoid failure if not set up yet
run: if npm run | grep -q "type-check"; then npm run type-check; else echo "No type-check script found, skipping"; fi
- name: Run Tests
if: env.SKIP_TESTS != 'true'
run: npm run test
- name: Build
run: npm run build
migration-safety:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./apps/backend
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: lumenpulse
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
cache-dependency-path: './apps/backend/package-lock.json'
- name: Install dependencies
run: npm ci
- name: Enable uuid-ossp extension
run: >
PGPASSWORD=postgres psql -h localhost -U postgres -d lumenpulse
-c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'
env:
PGPASSWORD: postgres
- name: Migration safety checks
run: npm run migration:check
- name: Verify migrations on clean database (up, schema drift, down)
env:
NODE_ENV: test
ENVIRONMENT: test
PORT: '3000'
DB_HOST: localhost
DB_PORT: '5432'
DB_USERNAME: postgres
DB_PASSWORD: postgres
DB_DATABASE: lumenpulse
JWT_SECRET: ci-jwt-secret
STELLAR_SERVER_SECRET: 'SB6RIPM3GJQ7RP3Q6R5F3QIBYZHP4N27SGGCQ3R4LWA2ZKXZWQ3NU3G4'
run: npm run migration:verify