Repository navigation
111 lines (97 loc) · 3.65 KB
/
Copy pathbackend.yml
File metadata and controls
111 lines (97 loc) · 3.65 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:
push:
branches: [main, develop]
paths:
- "app/backend/**"
pull_request:
branches: [main, develop]
paths:
- "app/backend/**"
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/backend
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: ci_test
POSTGRES_PASSWORD: ci_test_password
POSTGRES_DB: quickex_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Lint
run: pnpm run lint
- name: Build
run: pnpm run build
# ── Database migrations ──────────────────────────────────────────────
- name: Run database migrations
env:
DATABASE_URL: postgresql://ci_test:ci_test_password@localhost:5432/quickex_test
run: |
echo "🗄️ Running migrations against PostgreSQL..."
bash scripts/run-ci-migrations.sh
- name: Validate migration schema
env:
DATABASE_URL: postgresql://ci_test:ci_test_password@localhost:5432/quickex_test
run: |
echo "🔍 Validating schema after migrations..."
EXPECTED_TABLES=$(find supabase/migrations -name '*.sql' -exec grep -h 'CREATE TABLE' {} \; | \
sed 's/.*CREATE TABLE.*IF NOT EXISTS *//; s/CREATE TABLE *//; s/ *(.*//; s/^public\.//' | \
sort -u | wc -l)
ACTUAL_TABLES=$(psql "$DATABASE_URL" -t -A -c \
"SELECT count(*) FROM information_schema.tables WHERE table_schema = 'public' AND table_type = 'BASE TABLE';")
echo " Expected tables (from migrations): ~$EXPECTED_TABLES"
echo " Actual tables in database: $ACTUAL_TABLES"
if [ "$ACTUAL_TABLES" -lt 1 ]; then
echo "❌ No tables found in the database — migrations may have failed silently."
exit 1
fi
echo "✅ Schema validation passed."
# ── Tests ────────────────────────────────────────────────────────────
# Tests are run separately to avoid CI failures during development
# Uncomment when tests are stable
# - name: Run Unit Tests
# run: pnpm run test:unit
# env:
# NODE_ENV: test
# STELLAR_NETWORK: testnet
# SUPABASE_URL: https://test.supabase.co
# SUPABASE_ANON_KEY: test-key
- name: Run Unit Tests with Coverage
run: pnpm run test:unit:coverage
env:
NODE_ENV: test
STELLAR_NETWORK: testnet
SUPABASE_URL: https://test.supabase.co
SUPABASE_ANON_KEY: test-key
- name: Run Integration Tests with Coverage
run: pnpm run test:int:coverage
env:
NODE_ENV: test
STELLAR_NETWORK: testnet
SUPABASE_URL: https://test.supabase.co
SUPABASE_ANON_KEY: test-key
DATABASE_URL: postgresql://ci_test:ci_test_password@localhost:5432/quickex_test