-
Notifications
You must be signed in to change notification settings - Fork 15
101 lines (81 loc) · 2.27 KB
/
ci.yml
File metadata and controls
101 lines (81 loc) · 2.27 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
build:
name: Build & Validate
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm run install:all
- name: Audit production dependencies
run: npm audit --omit=dev
- name: Build shared
run: npm run build:shared
- name: Build server
run: npm run build:server
- name: Build client
run: npm run build:client
smoke-api:
name: Smoke API (Docker)
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm run install:all
- name: Prepare CI env
run: |
cat > .env << 'EOF'
POSTGRES_DB=openfamily
POSTGRES_USER=openfamily
POSTGRES_PASSWORD=openfamily-ci-password
POSTGRES_PORT=5433
SERVER_PORT=3001
NODE_ENV=production
JWT_SECRET=ci-openfamily-jwt-secret-0123456789-abcdefghijklmnopqrstuvwxyz
CORS_ORIGINS=http://localhost:3000,http://localhost:5173
VITE_API_URL=http://localhost:3001
VITE_WS_URL=ws://localhost:3001
REGISTRATION_ENABLED=true
EOF
- name: Start stack
run: docker compose up -d --build
- name: Wait for API health
run: |
for i in {1..60}; do
if curl -fsS http://localhost:3001/health >/dev/null; then
echo "API is healthy"
exit 0
fi
sleep 2
done
echo "API did not become healthy in time"
docker compose logs --tail=200 server
exit 1
- name: Run smoke API
run: npm run smoke:api
- name: Dump logs on failure
if: failure()
run: docker compose logs --tail=200
- name: Shutdown stack
if: always()
run: docker compose down -v