-
Notifications
You must be signed in to change notification settings - Fork 11
196 lines (173 loc) · 6.05 KB
/
e2e_tests.yml
File metadata and controls
196 lines (173 loc) · 6.05 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
name: E2E Tests
on:
workflow_call:
permissions:
contents: read
jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 30
services:
postgres:
image: postgres:18.3-alpine
env:
POSTGRES_USER: thesis-management-postgres
POSTGRES_PASSWORD: thesis-management-postgres
POSTGRES_DB: thesis-management
ports:
- 5444:5432
options: >-
--health-cmd "pg_isready -d thesis-management -U thesis-management-postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 10
mailpit:
image: axllent/mailpit:v1.29
ports:
- 1125:1025
- 8125:8025
options: >-
--health-cmd "wget -qO- http://localhost:8025/api/v1/messages || exit 1"
--health-interval 5s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.head_ref || github.ref }}
fetch-depth: 1
# Start Keycloak manually (service containers don't support custom commands)
- name: Start Keycloak
run: |
docker run -d --name keycloak \
-e KC_BOOTSTRAP_ADMIN_USERNAME=admin \
-e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
-p 8181:8080 \
quay.io/keycloak/keycloak:26.5 \
start-dev
- name: Wait for Keycloak to be ready
run: |
echo "Waiting for Keycloak..."
for i in $(seq 1 60); do
if curl -sf http://localhost:8181/realms/master > /dev/null 2>&1; then
echo "Keycloak is ready"
break
fi
if [ "$i" -eq 60 ]; then
echo "Keycloak failed to start"
docker logs keycloak
exit 1
fi
sleep 2
done
- name: Import Keycloak realm
run: |
# Get admin token
TOKEN=$(curl -sf -X POST "http://localhost:8181/realms/master/protocol/openid-connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=admin&password=admin&grant_type=password&client_id=admin-cli" | jq -r '.access_token')
# Import realm
curl -sf -X POST "http://localhost:8181/admin/realms" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d @keycloak/thesis-management-realm.json
echo "Realm imported successfully"
# Set up Java for server
- name: Set up JDK 25
uses: actions/setup-java@v5
with:
java-version: '25'
distribution: 'zulu'
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x ./server/gradlew
# Start server in background with dev profile
- name: Start server
working-directory: ./server
run: ./gradlew bootRun --args='--spring.profiles.active=dev --server.port=8180' &
env:
SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5444/thesis-management
SPRING_DATASOURCE_USERNAME: thesis-management-postgres
SPRING_DATASOURCE_PASSWORD: thesis-management-postgres
KEYCLOAK_HOST: http://localhost:8181
KEYCLOAK_REALM_NAME: thesis-management
KEYCLOAK_CLIENT_ID: thesis-management-app
KEYCLOAK_SERVICE_CLIENT_ID: thesis-management-service-client
KEYCLOAK_SERVICE_CLIENT_SECRET: "**********"
CLIENT_HOST: http://localhost:3100
# Set up Node.js for client
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24.7.0'
cache: 'npm'
cache-dependency-path: client/package-lock.json
- name: Install client dependencies
working-directory: ./client
run: npm ci
- name: Install Playwright browsers
working-directory: ./client
run: npx playwright install --with-deps chromium
# Start client dev server in background
- name: Start client dev server
working-directory: ./client
run: npx webpack serve --env NODE_ENV=development &
env:
SERVER_HOST: http://localhost:8180
KEYCLOAK_HOST: http://localhost:8181
KEYCLOAK_REALM_NAME: thesis-management
KEYCLOAK_CLIENT_ID: thesis-management-app
# Wait for both services to be ready
- name: Wait for server to be ready
run: |
echo "Waiting for Spring Boot server..."
for i in $(seq 1 120); do
if curl -sf http://localhost:8180/api/actuator/health > /dev/null 2>&1; then
echo "Server is ready"
break
fi
if [ "$i" -eq 120 ]; then
echo "Server failed to start"
exit 1
fi
sleep 2
done
- name: Wait for client to be ready
run: |
echo "Waiting for client dev server..."
for i in $(seq 1 60); do
if curl -sf http://localhost:3100 > /dev/null 2>&1; then
echo "Client is ready"
break
fi
if [ "$i" -eq 60 ]; then
echo "Client failed to start"
exit 1
fi
sleep 2
done
# Run E2E tests
- name: Run Playwright tests
working-directory: ./client
run: npx playwright test
env:
CI: "1"
CLIENT_URL: http://localhost:3100
KEYCLOAK_HOST: http://localhost:8181
KEYCLOAK_REALM_NAME: thesis-management
KEYCLOAK_CLIENT_ID: thesis-management-app
- name: Upload Playwright report
uses: actions/upload-artifact@v7
if: ${{ !cancelled() }}
with:
name: playwright-report
path: client/playwright-report/
retention-days: 14
- name: Upload test results
uses: actions/upload-artifact@v7
if: ${{ !cancelled() }}
with:
name: playwright-results
path: client/test-results/
retention-days: 14