-
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (120 loc) · 4.08 KB
/
e2e-tests.yml
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
name: End-to-End Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
e2e-tests:
name: Run E2E Tests
runs-on: ubuntu-latest
services:
db:
image: ankane/pgvector
env:
POSTGRES_DB: app
POSTGRES_USER: app
POSTGRES_PASSWORD: pass
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U app"
--health-interval=10s
--health-timeout=5s
--health-retries=5
oauth-mock-server:
image: ghcr.io/shaharia-lab/oauth-mock-server:0.0.1
env:
PORT: 9999
CLIENT_ID: test-client
CLIENT_SECRET: test-secret
ports:
- 9999:9999
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Build Backend Docker Image
run: |
cd backend
docker build -t backend-image .
- name: Wait for OAuth Mock Server to be Ready
run: |
timeout 60s bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:9999/authorize)" != "400" ]]; do sleep 5; done' || false
- name: Check OAuth Mock Server Status
run: |
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:9999/authorize)
if [ $response -eq 400 ]; then
echo "OAuth Mock Server is up and running"
else
echo "OAuth Mock Server is not responding as expected. Status code: $response"
exit 1
fi
- name: Run Backend Docker Container
run: |
docker run -d --name backend-container \
--network host \
-e DB_HOST=127.0.0.1 \
-e DB_PORT=5432 \
-e DB_NAME=app \
-e DB_USER=app \
-e DB_PASS=pass \
-e MOCK_OAUTH_BASE_URL=http://127.0.0.1:9999 \
-e MOCK_OAUTH_CLIENT_ID=test-client \
-e MOCK_OAUTH_CLIENT_SECRET=test-secret \
-e MOCK_OAUTH_REDIRECT_URL=http://localhost:3000/auth/google/callback \
backend-image
- name: Check Docker Container Status
run: |
docker ps -a
docker logs backend-container
- name: Wait for Backend to be Ready
run: |
timeout 60s bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/system/ping)" != "200" ]]; do sleep 5; done' || false
- name: Check Backend Logs if Startup Failed
if: failure()
run: |
echo "Backend failed to start. Checking logs:"
docker logs backend-container
- name: Install Frontend Dependencies
run: |
cd frontend/smarty-pants
npm ci
- name: Build Frontend
run: |
cd frontend/smarty-pants
npm run build
- name: Start Frontend
run: |
cd frontend/smarty-pants
npm run start & # Run in background
echo $! > frontend.pid # Save process ID
- name: Wait for Frontend to be Ready
run: |
timeout 60s bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:3000/login)" != "200" ]]; do sleep 5; done' || false
- name: Run E2E Tests
run: |
cd frontend/smarty-pants
npm run cypress:run -- --config baseUrl=http://localhost:3000
- name: Check Backend Logs After Tests
if: always()
run: |
echo "Backend logs after tests:"
docker logs backend-container
- name: Upload Cypress Screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: frontend/smarty-pants/cypress/screenshots
- name: Upload Cypress Videos
uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-videos
path: frontend/smarty-pants/cypress/videos