-
Notifications
You must be signed in to change notification settings - Fork 11
183 lines (162 loc) · 5.83 KB
/
e2e_tests.yml
File metadata and controls
183 lines (162 loc) · 5.83 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
name: E2E Tests
on:
workflow_call:
jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 30
services:
postgres:
image: postgres:18.2-alpine
env:
POSTGRES_USER: thesis-management-postgres
POSTGRES_PASSWORD: thesis-management-postgres
POSTGRES_DB: thesis-management
ports:
- 5144:5432
options: >-
--health-cmd "pg_isready -d thesis-management -U thesis-management-postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 10
keycloak:
image: quay.io/keycloak/keycloak:26.4
env:
KC_BOOTSTRAP_ADMIN_USERNAME: admin
KC_BOOTSTRAP_ADMIN_PASSWORD: admin
ports:
- 8081:8080
# Note: realm import is handled via the entrypoint below
options: >-
--health-cmd "exec 3<>/dev/tcp/127.0.0.1/8080; echo -e 'GET /health/ready HTTP/1.1\r\nHost: localhost\r\n\r\n' >&3; head -1 <&3 | grep -q '200'"
--health-interval 10s
--health-timeout 5s
--health-retries 30
--health-start-period 60s
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.head_ref || github.ref }}
fetch-depth: 1
# Import Keycloak realm (service containers can't mount volumes, so we use the REST API)
- name: Wait for Keycloak to be ready
run: |
echo "Waiting for Keycloak..."
for i in $(seq 1 60); do
if curl -sf http://localhost:8081/health/ready > /dev/null 2>&1; then
echo "Keycloak is ready"
break
fi
sleep 2
done
- name: Import Keycloak realm
run: |
# Get admin token
TOKEN=$(curl -sf -X POST "http://localhost:8081/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:8081/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' &
env:
SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5144/thesis-management
SPRING_DATASOURCE_USERNAME: thesis-management-postgres
SPRING_DATASOURCE_PASSWORD: thesis-management-postgres
KEYCLOAK_HOST: http://localhost:8081
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:3000
# Set up Node.js for client
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
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:8080
KEYCLOAK_HOST: http://localhost:8081
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:8080/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:3000 > /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:3000
KEYCLOAK_HOST: http://localhost:8081
KEYCLOAK_REALM_NAME: thesis-management
KEYCLOAK_CLIENT_ID: thesis-management-app
- name: Upload Playwright report
uses: actions/upload-artifact@v6
if: ${{ !cancelled() }}
with:
name: playwright-report
path: client/playwright-report/
retention-days: 14
- name: Upload test results
uses: actions/upload-artifact@v6
if: ${{ !cancelled() }}
with:
name: playwright-results
path: client/test-results/
retention-days: 14