-
Notifications
You must be signed in to change notification settings - Fork 9
182 lines (149 loc) · 5.13 KB
/
Copy pathci.yml
File metadata and controls
182 lines (149 loc) · 5.13 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: CI
on:
pull_request:
push:
branches:
- dev
- master
jobs:
configuration:
name: Production configuration checks
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Validate production metrics configuration
run: scripts/test-compose-metrics-config.sh
- name: Validate CI branch coverage
run: scripts/test-ci-branches.sh
- name: Validate CodeQL branch coverage
run: scripts/test-codeql-branches.sh
- name: Rehearse MongoDB backup and restore scripts
run: scripts/test-mongo-backup-restore.sh
- name: Rehearse a live MongoDB backup and restore
run: scripts/test-mongo-backup-restore-live.sh
server:
name: Server lint and unit tests
runs-on: ubuntu-latest
env:
PGHOST: 127.0.0.1
PGPORT: 5432
PGDATABASE: letscube
PGUSER: letscube
PGPASSWORD: letscube
services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_DB: letscube
POSTGRES_USER: letscube
POSTGRES_PASSWORD: letscube
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U letscube -d letscube"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 22.17.0
cache: yarn
cache-dependency-path: yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Validate Prisma schema
run: yarn workspace letscube-server postgres:schema:validate
- name: Apply PostgreSQL migrations
run: yarn workspace letscube-server postgres:migrate
- name: Check PostgreSQL schema drift
run: yarn workspace letscube-server postgres:schema:check
- name: Run server lint
run: yarn turbo run lint --filter=letscube-server
- name: Run server unit tests
run: yarn turbo run test:ci --filter=letscube-server
client:
name: Client lint and unit tests
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 22.17.0
cache: yarn
cache-dependency-path: yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run client lint
run: yarn turbo run lint --filter=letscube-client
- name: Run client unit tests
run: yarn turbo run test:ci --filter=letscube-client
cypress:
name: Cypress full-stack smoke
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node for client
uses: actions/setup-node@v4
with:
node-version: 22.17.0
cache: yarn
cache-dependency-path: yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Start client
run: BROWSER=none yarn workspace letscube-client start > client.log 2>&1 &
- name: Set up Node for server and Cypress
uses: actions/setup-node@v4
with:
node-version: 22.17.0
- name: Start backing services
run: docker compose -f compose.yml -f compose.dev.yml up -d mongo redis
- name: Start server
run: CORS_ORIGINS=http://localhost:3000,http://localhost:8080 LETSCUBE_TEST_AUTH=true SOCIAL_FEATURES_ENABLED=true POSTGRES_ENABLED=false yarn workspace letscube-server node index.js > server.log 2>&1 &
- name: Start socket server
run: SOCIAL_FEATURES_ENABLED=true POSTGRES_ENABLED=false yarn workspace letscube-server node socket/ > socket.log 2>&1 &
- name: Wait for local stack
run: |
for url in \
http://localhost:3000/ \
http://localhost:8080/api/announcements \
"http://localhost:9000/socket.io/?EIO=4&transport=polling"
do
for i in {1..60}; do
if curl --fail --silent --output /dev/null "$url"; then
break
fi
if [ "$i" -eq 60 ]; then
echo "Timed out waiting for $url"
echo "--- client.log"
cat client.log || true
echo "--- server.log"
cat server.log || true
echo "--- socket.log"
cat socket.log || true
docker compose -f compose.yml -f compose.dev.yml ps
exit 1
fi
sleep 2
done
done
- name: Run Cypress
run: yarn cypress:run
- name: Print app logs on failure
if: failure()
run: |
echo "--- client.log"
cat client.log || true
echo "--- server.log"
cat server.log || true
echo "--- socket.log"
cat socket.log || true
docker compose -f compose.yml -f compose.dev.yml ps || true