forked from DragosOnisei/FrameComment
-
Notifications
You must be signed in to change notification settings - Fork 0
534 lines (458 loc) · 21.5 KB
/
Copy pathtest-dev-clean-install.yml
File metadata and controls
534 lines (458 loc) · 21.5 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
name: Test Dev Build Clean Install
on:
workflow_call:
workflow_dispatch:
permissions:
contents: read
jobs:
test-dev-install:
name: Dev Clean Install Test (build from source)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Detect version and database versions
id: versions
run: |
VERSION=$(cat VERSION | tr -d '\n\r')
echo "version=$VERSION" >> $GITHUB_OUTPUT
PG_IMAGE=$(grep -A 1 "postgres:" docker-compose.yml | grep "image:" | sed 's/.*postgres:\([^-]*\).*/\1/')
echo "postgres_version=$PG_IMAGE" >> $GITHUB_OUTPUT
REDIS_IMAGE=$(grep -A 1 "redis:" docker-compose.yml | grep "image:" | sed 's/.*redis:\([^-]*\).*/\1/')
echo "redis_version=$REDIS_IMAGE" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image from source
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: framecomment:ci-test
build-args: |
APP_VERSION=${{ steps.versions.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Configure docker-compose for local image
run: |
sed -i "s|image: dragosonisei/framecomment:latest|image: framecomment:ci-test|g" docker-compose.yml
echo "Configured to use locally built image"
- name: Create test .env file
run: |
ENCRYPTION_KEY=$(openssl rand -base64 32)
JWT_SECRET=$(openssl rand -base64 64)
JWT_REFRESH_SECRET=$(openssl rand -base64 64)
SHARE_TOKEN_SECRET=$(openssl rand -base64 64)
cat > .env << 'EOF'
POSTGRES_USER=framecomment
POSTGRES_PASSWORD=test_postgres_password
POSTGRES_DB=framecomment
REDIS_PASSWORD=test_redis_password
APP_PORT=4321
TZ=UTC
PUID=1000
PGID=1000
ADMIN_EMAIL=admin@test.local
ADMIN_PASSWORD=TestPassword123!
ADMIN_NAME=Test Admin
HTTPS_ENABLED=false
EOF
echo "ENCRYPTION_KEY=\"$ENCRYPTION_KEY\"" >> .env
echo "JWT_SECRET=\"$JWT_SECRET\"" >> .env
echo "JWT_REFRESH_SECRET=\"$JWT_REFRESH_SECRET\"" >> .env
echo "SHARE_TOKEN_SECRET=\"$SHARE_TOKEN_SECRET\"" >> .env
- name: Start services with docker compose
run: |
docker compose up -d
echo "Waiting for services to be healthy..."
sleep 30
- name: Verify PostgreSQL version
run: |
EXPECTED_VERSION="${{ steps.versions.outputs.postgres_version }}"
PG_FULL_VERSION=$(docker exec framecomment-postgres psql --version | grep -oP '\d+\.\d+')
PG_MAJOR_VERSION=$(echo "$PG_FULL_VERSION" | cut -d'.' -f1)
echo "PostgreSQL version: $PG_FULL_VERSION (expected major: $EXPECTED_VERSION)"
if [[ "$PG_MAJOR_VERSION" != "$EXPECTED_VERSION" ]]; then
echo "[ERROR] Expected PostgreSQL major version $EXPECTED_VERSION, got $PG_MAJOR_VERSION (full: $PG_FULL_VERSION)"
exit 1
fi
echo "[OK] PostgreSQL $PG_MAJOR_VERSION.x verified (full version: $PG_FULL_VERSION)"
- name: Verify Redis version
run: |
EXPECTED_VERSION="${{ steps.versions.outputs.redis_version }}"
REDIS_VERSION=$(docker exec framecomment-redis redis-server --version | grep -oP 'v=\K[0-9]+\.[0-9]+')
echo "Redis version: $REDIS_VERSION (expected: $EXPECTED_VERSION)"
REDIS_MAJOR=$(echo $REDIS_VERSION | cut -d. -f1)
EXPECTED_MAJOR=$(echo $EXPECTED_VERSION | cut -d. -f1)
if [[ "$REDIS_MAJOR" != "$EXPECTED_MAJOR" ]]; then
echo "[ERROR] Expected Redis $EXPECTED_MAJOR.x, got $REDIS_VERSION"
exit 1
fi
echo "[OK] Redis $REDIS_MAJOR.x verified"
- name: Check container health
run: |
echo "Checking container statuses..."
docker compose ps
# Check if all containers are healthy
APP_HEALTH=$(docker inspect framecomment-app --format='{{.State.Health.Status}}')
POSTGRES_HEALTH=$(docker inspect framecomment-postgres --format='{{.State.Health.Status}}')
REDIS_HEALTH=$(docker inspect framecomment-redis --format='{{.State.Health.Status}}')
WORKER_HEALTH=$(docker inspect framecomment-worker --format='{{.State.Health.Status}}')
echo "App health: $APP_HEALTH"
echo "PostgreSQL health: $POSTGRES_HEALTH"
echo "Redis health: $REDIS_HEALTH"
echo "Worker health: $WORKER_HEALTH"
if [[ "$APP_HEALTH" != "healthy" ]] || \
[[ "$POSTGRES_HEALTH" != "healthy" ]] || \
[[ "$REDIS_HEALTH" != "healthy" ]] || \
[[ "$WORKER_HEALTH" != "healthy" ]]; then
echo "[ERROR] One or more containers are not healthy"
docker compose logs
exit 1
fi
echo "[OK] All containers are healthy"
- name: Test database connection
run: |
echo "Testing PostgreSQL connection..."
docker exec framecomment-postgres psql -U framecomment -d framecomment -c "SELECT version();"
echo "[OK] Database connection successful"
- name: Test Redis connection
run: |
echo "Testing Redis connection..."
docker exec framecomment-redis redis-cli -a test_redis_password --no-auth-warning ping
echo "[OK] Redis connection successful"
- name: Verify migrations ran
run: |
echo "Checking database migrations..."
TABLES=$(docker exec framecomment-postgres psql -U framecomment -d framecomment -t -c "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='public';")
echo "Number of tables: $TABLES"
if [[ $TABLES -lt 5 ]]; then
echo "[ERROR] Expected at least 5 tables, found $TABLES"
exit 1
fi
echo "[OK] Migrations completed successfully"
- name: Test API health endpoint
run: |
echo "Testing health endpoint..."
RESPONSE=$(curl -s http://localhost:4321/api/health)
echo "Response: $RESPONSE"
if [[ "$RESPONSE" != *"ok"* ]]; then
echo "[ERROR] Health check failed"
exit 1
fi
echo "[OK] API health check passed"
- name: Test admin login
run: |
echo "Testing admin login..."
LOGIN_RESPONSE=$(curl -s -X POST http://localhost:4321/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"admin@test.local","password":"TestPassword123!"}')
echo "Login response: $LOGIN_RESPONSE"
if [[ "$LOGIN_RESPONSE" == *"error"* ]]; then
echo "[ERROR] Admin login failed"
echo "$LOGIN_RESPONSE"
exit 1
fi
echo "[OK] Admin login successful"
# Extract accessToken from the tokens object in the response
AUTH_TOKEN=$(echo "$LOGIN_RESPONSE" | grep -o '"accessToken":"[^"]*"' | head -1 | sed 's/"accessToken":"//;s/"$//')
if [[ -z "$AUTH_TOKEN" ]]; then
echo "[ERROR] Failed to extract access token from login response"
echo "Full response: $LOGIN_RESPONSE"
exit 1
fi
echo "$AUTH_TOKEN" > /tmp/auth_token.txt
echo "Token extracted successfully (length: ${#AUTH_TOKEN})"
- name: Test API endpoints
run: |
echo "Testing additional API endpoints..."
AUTH_TOKEN=$(cat /tmp/auth_token.txt)
# Test session endpoint
echo "Testing session endpoint..."
SESSION_RESPONSE=$(curl -s http://localhost:4321/api/auth/session \
-H "Authorization: Bearer $AUTH_TOKEN")
echo "Session response: $SESSION_RESPONSE"
if [[ "$SESSION_RESPONSE" != *"admin@test.local"* ]] || [[ "$SESSION_RESPONSE" == *'"authenticated":false'* ]]; then
echo "[ERROR] Session endpoint failed"
echo "Full session response: $SESSION_RESPONSE"
exit 1
fi
echo "[OK] Session endpoint working"
# Test projects list endpoint
echo "Testing projects list..."
PROJECTS_RESPONSE=$(curl -s http://localhost:4321/api/projects \
-H "Authorization: Bearer $AUTH_TOKEN")
if [[ "$PROJECTS_RESPONSE" == *"error"* ]]; then
echo "[ERROR] Projects endpoint failed"
echo "$PROJECTS_RESPONSE"
exit 1
fi
echo "[OK] Projects endpoint working"
# Test users list endpoint
echo "Testing users list..."
USERS_RESPONSE=$(curl -s http://localhost:4321/api/users \
-H "Authorization: Bearer $AUTH_TOKEN")
if [[ "$USERS_RESPONSE" == *"error"* ]] || [[ "$USERS_RESPONSE" != *"admin@test.local"* ]]; then
echo "[ERROR] Users endpoint failed"
echo "$USERS_RESPONSE"
exit 1
fi
echo "[OK] Users endpoint working"
# Test settings endpoint
echo "Testing settings endpoint..."
SETTINGS_RESPONSE=$(curl -s http://localhost:4321/api/settings \
-H "Authorization: Bearer $AUTH_TOKEN")
if [[ "$SETTINGS_RESPONSE" == *"error"* ]]; then
echo "[ERROR] Settings endpoint failed"
echo "$SETTINGS_RESPONSE"
exit 1
fi
echo "[OK] Settings endpoint working"
# Test analytics endpoint
echo "Testing analytics endpoint..."
ANALYTICS_RESPONSE=$(curl -s http://localhost:4321/api/analytics \
-H "Authorization: Bearer $AUTH_TOKEN")
if [[ "$ANALYTICS_RESPONSE" == *"error"* ]]; then
echo "[ERROR] Analytics endpoint failed"
echo "$ANALYTICS_RESPONSE"
exit 1
fi
echo "[OK] Analytics endpoint working"
- name: Test project creation
run: |
echo "Testing project creation..."
AUTH_TOKEN=$(cat /tmp/auth_token.txt)
CREATE_PROJECT=$(curl -s -X POST http://localhost:4321/api/projects \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "CI Test Project",
"description": "Automated test project",
"recipientName": "Test Client",
"recipientEmail": "client@test.local",
"sharePassword": "TestPass123",
"authMode": "PASSWORD"
}')
if [[ "$CREATE_PROJECT" == *"error"* ]]; then
echo "[ERROR] Project creation failed"
echo "$CREATE_PROJECT"
exit 1
fi
PROJECT_ID=$(echo "$CREATE_PROJECT" | grep -o '"id":"[^"]*"' | head -1 | sed 's/"id":"//;s/"$//')
echo "Project created with ID: $PROJECT_ID"
echo "$PROJECT_ID" > /tmp/test_project_id.txt
echo "[OK] Project creation successful"
- name: Test recipient management
run: |
echo "[TEST] Testing recipient management..."
AUTH_TOKEN=$(cat /tmp/auth_token.txt)
PROJECT_ID=$(cat /tmp/test_project_id.txt)
# Test adding recipient
echo "Adding recipient to project..."
ADD_RECIPIENT=$(curl -s -X POST "http://localhost:4321/api/projects/$PROJECT_ID/recipients" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "devrecipient2@test.local",
"name": "Dev Second Recipient",
"isPrimary": false
}')
if [[ "$ADD_RECIPIENT" == *"error"* ]]; then
echo "[ERROR] Failed to add recipient"
echo "$ADD_RECIPIENT"
exit 1
fi
echo "[OK] Recipient added successfully"
# Test listing recipients
echo "Listing recipients..."
RECIPIENTS=$(curl -s "http://localhost:4321/api/projects/$PROJECT_ID/recipients" \
-H "Authorization: Bearer $AUTH_TOKEN")
if [[ "$RECIPIENTS" != *"devrecipient2@test.local"* ]]; then
echo "[ERROR] Failed to retrieve recipient"
echo "$RECIPIENTS"
exit 1
fi
echo "[OK] Recipients list working"
- name: Test user creation
run: |
echo "[TEST] Testing user creation..."
AUTH_TOKEN=$(cat /tmp/auth_token.txt)
# Create new user
CREATE_USER=$(curl -s -X POST http://localhost:4321/api/users \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "devnewuser@test.local",
"password": "DevUserPass456!",
"name": "Dev New Test User",
"role": "ADMIN"
}')
if [[ "$CREATE_USER" == *"error"* ]]; then
echo "[ERROR] Failed to create user"
echo "$CREATE_USER"
exit 1
fi
echo "[OK] User creation working"
# Verify user appears in users list
USERS_LIST=$(curl -s http://localhost:4321/api/users \
-H "Authorization: Bearer $AUTH_TOKEN")
if [[ "$USERS_LIST" != *"devnewuser@test.local"* ]]; then
echo "[ERROR] New user not found in users list"
exit 1
fi
echo "[OK] New user verified in database"
- name: Test notification queue table
run: |
echo "[TEST] Testing notification queue table..."
AUTH_TOKEN=$(cat /tmp/auth_token.txt)
# Query database to verify NotificationQueue table exists
QUEUE_CHECK=$(docker compose -f docker-compose.yml exec -T postgres \
psql -U framecomment -d framecomment -t -c \
"SELECT EXISTS (
SELECT FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name = 'NotificationQueue'
);")
if [[ "$QUEUE_CHECK" != *"t"* ]]; then
echo "[ERROR] NotificationQueue table missing"
exit 1
fi
echo "[OK] NotificationQueue table exists"
- name: Test project update
run: |
echo "[TEST] Testing project update (PATCH)..."
AUTH_TOKEN=$(cat /tmp/auth_token.txt)
PROJECT_ID=$(cat /tmp/test_project_id.txt)
# Update project properties
UPDATE_PROJECT=$(curl -s -X PATCH "http://localhost:4321/api/projects/$PROJECT_ID" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Updated Dev CI Test Project",
"description": "Description updated in dev clean install test",
"status": "IN_REVIEW"
}')
if [[ "$UPDATE_PROJECT" == *"error"* ]]; then
echo "[ERROR] Failed to update project"
echo "$UPDATE_PROJECT"
exit 1
fi
echo "[OK] Project update working"
# Verify the update worked
GET_PROJECT=$(curl -s "http://localhost:4321/api/projects/$PROJECT_ID" \
-H "Authorization: Bearer $AUTH_TOKEN")
if [[ "$GET_PROJECT" != *"Updated Dev CI Test Project"* ]]; then
echo "[ERROR] Project update not reflected in database"
exit 1
fi
echo "[OK] Project update verified in database"
- name: Test settings update
run: |
echo "[TEST] Testing settings update (PATCH)..."
AUTH_TOKEN=$(cat /tmp/auth_token.txt)
# Update global settings
UPDATE_SETTINGS=$(curl -s -X PATCH "http://localhost:4321/api/settings" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"companyName": "Dev Clean Install Test Studio",
"defaultPreviewResolution": "1080p",
"defaultWatermarkEnabled": true
}')
if [[ "$UPDATE_SETTINGS" == *"error"* ]]; then
echo "[ERROR] Failed to update settings"
echo "$UPDATE_SETTINGS"
exit 1
fi
echo "[OK] Settings update working"
# Verify the settings were updated
GET_SETTINGS=$(curl -s "http://localhost:4321/api/settings" \
-H "Authorization: Bearer $AUTH_TOKEN")
if [[ "$GET_SETTINGS" != *"Dev Clean Install Test Studio"* ]]; then
echo "[ERROR] Settings update not reflected"
exit 1
fi
echo "[OK] Settings update verified"
- name: Test project-specific analytics
run: |
echo "[TEST] Testing project-specific analytics endpoint..."
AUTH_TOKEN=$(cat /tmp/auth_token.txt)
PROJECT_ID=$(cat /tmp/test_project_id.txt)
# Test project-specific analytics endpoint
PROJ_ANALYTICS=$(curl -s "http://localhost:4321/api/analytics/$PROJECT_ID" \
-H "Authorization: Bearer $AUTH_TOKEN")
if [[ "$PROJ_ANALYTICS" == *"error"* ]]; then
echo "[ERROR] Project analytics endpoint failed"
echo "$PROJ_ANALYTICS"
exit 1
fi
if [[ "$PROJ_ANALYTICS" != *"stats"* ]] || [[ "$PROJ_ANALYTICS" != *"videoStats"* ]]; then
echo "[ERROR] Project analytics response missing required fields"
exit 1
fi
echo "[OK] Project-specific analytics working"
- name: Check worker logs
run: |
echo "Checking worker initialization..."
echo "Waiting for worker to fully initialize..."
sleep 10
docker logs framecomment-worker --tail 100
WORKER_LOGS=$(docker logs framecomment-worker 2>&1)
if [[ "$WORKER_LOGS" != *"[WORKER] Video processing worker started"* ]]; then
echo "[ERROR] Worker did not start properly"
echo "Expected to find: '[WORKER] Video processing worker started'"
exit 1
fi
echo "[OK] Worker started successfully"
- name: Generate test summary
if: always()
run: |
cat >> $GITHUB_STEP_SUMMARY << 'EOF'
# Dev Build Clean Install Test Results
## Test Configuration
- **Docker Image**: Built from source (commit ${{ github.sha }})
- **Version**: `${{ steps.versions.outputs.version }}`
- **PostgreSQL**: `${{ steps.versions.outputs.postgres_version }}`
- **Redis**: `${{ steps.versions.outputs.redis_version }}`
- **Branch**: `${{ github.ref_name }}`
## Test Results
| Test | Status |
|------|--------|
| Container Health | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| PostgreSQL Connection | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Redis Connection | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Database Migrations | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| API Health Endpoint | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Admin Login | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Session API | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Projects API | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Users API | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Settings API | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Analytics API | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Project Creation | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Recipient Management | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| User Creation | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| NotificationQueue Table | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Project Update (PATCH) | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Settings Update (PATCH) | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Project-Specific Analytics | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
| Worker Initialization | ${{ job.status == 'success' && '[OK] Passed' || '[ERROR] Failed' }} |
EOF
- name: Show application logs on failure
if: failure()
run: |
echo "=== Application Logs ==="
docker logs framecomment-app --tail 100
echo ""
echo "=== PostgreSQL Logs ==="
docker logs framecomment-postgres --tail 50
echo ""
echo "=== Redis Logs ==="
docker logs framecomment-redis --tail 50
echo ""
echo "=== Worker Logs ==="
docker logs framecomment-worker --tail 50
- name: Cleanup
if: always()
run: |
docker compose down -v || true
rm -f .env