-
Notifications
You must be signed in to change notification settings - Fork 112
455 lines (410 loc) · 18.5 KB
/
Copy pathtesting.yml
File metadata and controls
455 lines (410 loc) · 18.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
name: EGroupware Testing
on:
pull_request:
push:
branches:
- master
workflow_dispatch:
jobs:
phpunit:
runs-on: ubuntu-24.04
timeout-minutes: 45
env:
EGW_DB_ROOT_PW: ciroot
COMPOSE_PROJECT_NAME: egwci
EGW_CI_ROOT: ${{ github.workspace }}/sources
EGW_CI_DOCKER_DIR: ${{ github.workspace }}/sources/doc/docker
EGW_SRC_DIR: /var/www
EGW_CONFIG_USER: ""
EGW_CONFIG_PASSWD: ""
SYSOP_USER: ""
SYSOP_PASS: ""
steps:
- uses: actions/checkout@v4
with:
submodules: true
path: sources
- name: Cache Composer downloads
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: composer-cache-${{ runner.os }}-${{ hashFiles('sources/composer.lock') }}
restore-keys: |
composer-cache-${{ runner.os }}-
- name: Install PHP dependencies in sources
shell: bash
run: |
set -euo pipefail
COMPOSER_CACHE_DIR="${HOME}/.composer/cache"
docker run --rm --user "$(id -u):$(id -g)" \
-v "${COMPOSER_CACHE_DIR}":/tmp/composer-cache \
-v "${GITHUB_WORKSPACE}/sources":/app -w /app \
-e COMPOSER_CACHE_DIR=/tmp/composer-cache \
composer install --no-interaction --ignore-platform-reqs
php "${GITHUB_WORKSPACE}/sources/install-cli.php" --git-apps pull
- name: Prepare compose project layout
run: |
set -euo pipefail
mkdir -p "$GITHUB_WORKSPACE/sources/doc/docker/data" "$GITHUB_WORKSPACE/sources/doc/docker/sessions"
rm -f "$GITHUB_WORKSPACE/sources/doc/docker/data/header.inc.php"
- name: Start CI containers
run: |
set -euo pipefail
COMPOSE="docker compose --project-directory $GITHUB_WORKSPACE/sources \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml"
$COMPOSE up -d --force-recreate db egroupware nginx
- name: Wait for install
run: |
set -euo pipefail
COMPOSE="docker compose --project-directory $GITHUB_WORKSPACE/sources \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml"
MAX_WAIT=60
WAIT_INTERVAL=5
ELAPSED=0
SUCCESS_MSG="EGroupware successful installed"
echo "Waiting for database to be ready..."
until $COMPOSE exec -T db mariadb-admin ping -h "db" --silent --user=root --password="$EGW_DB_ROOT_PW"; do
if [ "$ELAPSED" -ge "$MAX_WAIT" ]; then
echo "::error::Timed out waiting for EGroupware installation"
echo "==== egroupware logs ===="
$COMPOSE logs egroupware || true
echo "==== database logs ===="
$COMPOSE logs db || true
exit 1
fi
echo " ... waiting for DB"
sleep "$WAIT_INTERVAL"
ELAPSED=$((ELAPSED + WAIT_INTERVAL))
done
echo "Waiting for EGroupware installation log message..."
INSTALL_LOG="$(mktemp)"
until $COMPOSE logs egroupware > "$INSTALL_LOG" && grep -q "$SUCCESS_MSG" "$INSTALL_LOG"; do
if [ "$ELAPSED" -ge "$MAX_WAIT" ]; then
echo "::error::Timed out waiting for EGroupware installation"
echo "==== egroupware logs ===="
$COMPOSE logs egroupware || true
echo "==== database logs ===="
$COMPOSE logs db || true
exit 1
fi
sleep "$WAIT_INTERVAL"
ELAPSED=$((ELAPSED + WAIT_INTERVAL))
echo " ... still waiting (${ELAPSED}s)"
done
$COMPOSE exec -T egroupware ln -sf /var/lib/egroupware/header.inc.php "$EGW_SRC_DIR/header.inc.php"
- name: Extract install credentials
run: |
set -euo pipefail
COMPOSE="docker compose --project-directory $GITHUB_WORKSPACE/sources \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml"
INSTALL_LOG="$(mktemp)"
$COMPOSE logs egroupware > "$INSTALL_LOG"
# Get sysop admin user from install log
SYSOP_USER="sysop"
SYSOP_PASS="$(
awk '
/EGroupware username: sysop/ {found=1; next}
found && /password:/ {
sub(/^[^:]*:[[:space:]]*/, "", $0)
print
exit
}
' "$INSTALL_LOG"
)"
# Get setup user/password from install log.
CONFIG_USER="$(
awk '
/Setup username:/ {sub(/.*Setup username:[[:space:]]*/, "", $0); print; exit}
' "$INSTALL_LOG"
)"
CONFIG_PASS="$(
awk '
/Setup username:/ {found=1; next}
found && /password:/ {
sub(/^[^:]*:[[:space:]]*/, "", $0)
print
exit
}
' "$INSTALL_LOG"
)"
for v in SYSOP_USER SYSOP_PASS CONFIG_USER CONFIG_PASS; do
if [ -z "${!v}" ]; then
echo "::error::Missing $v"
exit 1
fi
done
{
echo "SYSOP_USER=$SYSOP_USER"
echo "SYSOP_PASS=$SYSOP_PASS"
echo "EGW_CONFIG_USER=$CONFIG_USER"
echo "EGW_CONFIG_PASSWD=$CONFIG_PASS"
} >> "$GITHUB_ENV"
- name: Debug admin-cli path mapping
run: |
set -euo pipefail
COMPOSE="docker compose --project-directory $GITHUB_WORKSPACE/sources \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml"
echo "== Host checks =="
pwd
ls -la "$GITHUB_WORKSPACE/sources/admin/admin-cli.php" || true
ls -la "$GITHUB_WORKSPACE/sources/admin" | sed -n '1,80p' || true
echo "== Compose resolved mounts (egroupware service) =="
docker compose --project-directory "$GITHUB_WORKSPACE/sources" \
-f "$GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml" \
-f "$GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml" \
config | sed -n '/egroupware:/,/db:/p'
echo "== Container checks =="
$COMPOSE exec -T egroupware sh -lc 'pwd; ls -la /var/www | sed -n "1,80p"; ls -la /var/www/admin | sed -n "1,80p" || true; ls -la /var/www/egroupware/admin | sed -n "1,80p" || true'
$COMPOSE exec -T egroupware sh -lc 'test -f /var/www/admin/admin-cli.php && echo "admin-cli in /var/www" || true; test -f /var/www/egroupware/admin/admin-cli.php && echo "admin-cli in /var/www/egroupware" || true'
- name: Detect app root in container
run: |
set -euo pipefail
COMPOSE="docker compose --project-directory $GITHUB_WORKSPACE/sources \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml"
APP_DIR="$(
$COMPOSE exec -T egroupware sh -lc '
if [ -f /var/www/admin/admin-cli.php ]; then
echo /var/www
elif [ -f /var/www/egroupware/admin/admin-cli.php ]; then
echo /var/www/egroupware
else
exit 1
fi
'
)"
echo "EGW_SRC_DIR=$APP_DIR" >> "$GITHUB_ENV"
echo "Detected EGW_SRC_DIR=$APP_DIR"
- name: Configure for phpunit test (apps, user)
run: |
set -euo pipefail
COMPOSE="docker compose --project-directory $GITHUB_WORKSPACE/sources \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml"
# Get test user from phpunit.xml
EGW_TEST_USER="$(
sed -n 's/.*<var name="EGW_USER" value="\([^"]*\)".*/\1/p' "$GITHUB_WORKSPACE/sources/doc/phpunit.xml"
)"
EGW_TEST_PASS="$(
sed -n 's/.*<var name="EGW_PASSWORD" value="\([^"]*\)".*/\1/p' "$GITHUB_WORKSPACE/sources/doc/phpunit.xml"
)"
for v in SYSOP_USER SYSOP_PASS EGW_TEST_USER EGW_TEST_PASS; do
if [ -z "${!v}" ]; then
echo "::error::Missing $v"
exit 1
fi
done
{
echo "SYSOP_USER=$SYSOP_USER"
echo "SYSOP_PASS=$SYSOP_PASS"
} >> "$GITHUB_ENV"
$COMPOSE exec -T -w "$EGW_SRC_DIR" egroupware php admin/admin-cli.php \
--edit-user "$SYSOP_USER,$SYSOP_PASS,$EGW_TEST_USER,Test,User,$EGW_TEST_PASS,$EGW_TEST_USER@example.invalid"
$COMPOSE exec -T -w "$EGW_SRC_DIR" egroupware php admin/admin-cli.php \
--allow-app "$SYSOP_USER,$SYSOP_PASS,$EGW_TEST_USER,projectmanager"
# Ensure share links resolve locally in CI
$COMPOSE exec -T -w "$EGW_SRC_DIR" egroupware php setup/setup-cli.php \
--config default,"$EGW_CONFIG_USER","$EGW_CONFIG_PASSWD",hostname=localhost,webserver_url=/egroupware
- name: Debug web access
run: |
set -euo pipefail
COMPOSE="docker compose --project-directory $GITHUB_WORKSPACE/sources \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml"
docker compose exec nginx nginx -T || true
docker compose exec nginx ss -lntp || true
$COMPOSE exec -T egroupware sh -lc '
which curl || apt-get update && apt-get install -y curl
echo "Testing 'nginx' URL:"
curl -I -v http://nginx/ || true
echo
echo "Listening ports:"
ss -lntp || netstat -lntp || true
'
- name: Install fixture test app
run: |
set -euo pipefail
COMPOSE="docker compose --project-directory $GITHUB_WORKSPACE/sources \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml"
# Ensure fixture test app is linked and installed before tests
$COMPOSE exec -T \
-e EGW_CONFIG_USER="$EGW_CONFIG_USER" \
-e EGW_CONFIG_PASSWD="$EGW_CONFIG_PASSWD" \
-w "$EGW_SRC_DIR" egroupware sh -lc '
if [ -d api/tests/fixtures/apps/test ]; then
ln -sfn api/tests/fixtures/apps/test test
set +e
php setup/setup-cli.php --update default,$EGW_CONFIG_USER,$EGW_CONFIG_PASSWD,no,test
rc=$?
set -e
echo "setup-cli exit code: $rc"
fi
'
if ! $COMPOSE exec -T db mariadb -u root -p"$EGW_DB_ROOT_PW" -D "egroupware" -e "SHOW TABLES LIKE 'egw_test%';" | grep -q "egw_test"; then
echo "egw_test table not found after test app install, some tests will be skipped"
fi
- name: Install webauthn app
run: |
set -euo pipefail
COMPOSE="docker compose --project-directory $GITHUB_WORKSPACE/sources \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml"
# webauthn is a newer first-party app (composer.json require egroupware/webauthn); the CI
# image's baked-in install predates it, so its schema (egw_webauthn_pubkeys) was never
# created - install it explicitly, same as the "test" fixture app above.
#
# header.inc.php still points EGW_SERVER_ROOT at the image's baked-in /usr/share/egroupware
# at this point in the pipeline (that only gets patched to $EGW_SRC_DIR later, in "Run
# PHPUnit") - without this, setup-cli.php scans the old baked-in app list, never sees
# webauthn as new, and silently no-ops with "No update necessary". Patch it here too
# (idempotent, harmless if "Run PHPUnit" repeats it) so the scan sees the real checkout.
$COMPOSE exec -T egroupware sed -i "s#/usr/share/egroupware#$EGW_SRC_DIR#g" /var/lib/egroupware/header.inc.php
$COMPOSE exec -T \
-e EGW_CONFIG_USER="$EGW_CONFIG_USER" \
-e EGW_CONFIG_PASSWD="$EGW_CONFIG_PASSWD" \
-w "$EGW_SRC_DIR" egroupware sh -lc '
set +e
php setup/setup-cli.php --update default,$EGW_CONFIG_USER,$EGW_CONFIG_PASSWD,no,webauthn
rc=$?
set -e
echo "setup-cli exit code: $rc"
'
if ! $COMPOSE exec -T db mariadb -u root -p"$EGW_DB_ROOT_PW" -D "egroupware" -e "SHOW TABLES LIKE 'egw_webauthn_pubkeys';" | grep -q "egw_webauthn_pubkeys"; then
echo "::error::egw_webauthn_pubkeys table not found after webauthn app install"
exit 1
fi
- name: Disable swoolepush for CI tests
run: |
set -euo pipefail
COMPOSE="docker compose --project-directory $GITHUB_WORKSPACE/sources \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml"
$COMPOSE exec -T db mariadb -u root -p"$EGW_DB_ROOT_PW" -D "egroupware" -e \
"UPDATE egw_applications SET app_enabled=-1 WHERE app_name='swoolepush';"
$COMPOSE exec -T -w "$EGW_SRC_DIR" egroupware php -r '
require "api/src/loader/common.php";
\EGroupware\Api\Cache::unsetInstance(\EGroupware\Api\Egw\Applications::class, "apps");
\EGroupware\Api\Cache::unsetInstance(\EGroupware\Api\Hooks::class, "locations");
'
- name: Run PHPUnit
timeout-minutes: 30
run: |
set -euo pipefail
COMPOSE="docker compose --project-directory $GITHUB_WORKSPACE/sources \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml"
EGW_CONFIG_USER="${EGW_CONFIG_USER:-}"
EGW_CONFIG_PASSWD="${EGW_CONFIG_PASSWD:-}"
for v in EGW_CONFIG_USER EGW_CONFIG_PASSWD; do
if [ -z "${!v}" ]; then
echo "::error::Missing $v"
exit 1
fi
done
# header.inc.php is generated against the image's own baked-in /usr/share/egroupware
# install (rsynced from the image at container start), but the "Run PHPUnit" step below
# serves the actual checked-out branch from $EGW_SRC_DIR instead - patch the mismatched
# EGW_SERVER_ROOT so the app-specific autoloader (api/src/autoload.php, which resolves
# classes via EGW_INCLUDE_ROOT rather than composer's own correctly-resolved base dir)
# looks in the right place. Done inside the container (not via the host bind-mount path)
# since the file is owned by the container's own user, not the Actions runner.
$COMPOSE exec -T egroupware \
sed -i "s#/usr/share/egroupware#$EGW_SRC_DIR#g" /var/lib/egroupware/header.inc.php
# Run tests with local HTTP endpoint inside egroupware container
$COMPOSE exec -T \
-e HTTP_HOST=127.0.0.1:8081 \
-e HTTP_X_FORWARDED_PROTO=http \
-e EGW_URL=http://127.0.0.1:8081 \
-e EGW_CONFIG_USER="$EGW_CONFIG_USER" \
-e EGW_CONFIG_PASSWD="$EGW_CONFIG_PASSWD" \
-w "$EGW_SRC_DIR" egroupware \
bash -lc '
set -euo pipefail
php -S 127.0.0.1:8081 -t "$PWD" "$PWD/.github/ci-router.php" > /tmp/egw-phpunit-http.log 2>&1 &
server_pid=$!
trap "kill $server_pid 2>/dev/null || true" EXIT
for i in $(seq 1 20); do
php -r '\''$fp=@fsockopen("127.0.0.1",8081,$errno,$errstr,0.2); if($fp){fclose($fp); exit(0);} exit(1);'\'' && break
sleep 1
done
set +e
php vendor/bin/phpunit --configuration doc/phpunit.xml
rc=$?
set -e
echo "=== php built-in server log (last 300 lines) ==="
tail -n 300 /tmp/egw-phpunit-http.log || true
exit $rc
'
- name: Tear down
if: always()
run: |
COMPOSE="docker compose --project-directory $GITHUB_WORKSPACE/sources \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.yml \
-f $GITHUB_WORKSPACE/sources/doc/docker/docker-compose.ci.yml"
$COMPOSE down -v --remove-orphans
jstest:
runs-on: ubuntu-24.04
timeout-minutes: 10
env:
EGW_DB_ROOT_PW: ciroot
COMPOSE_PROJECT_NAME: egwci
EGW_CI_ROOT: ${{ github.workspace }}/sources
EGW_CI_DOCKER_DIR: ${{ github.workspace }}/sources/doc/docker
EGW_SRC_DIR: /var/www
EGW_CONFIG_USER: ""
EGW_CONFIG_PASSWD: ""
SYSOP_USER: ""
SYSOP_PASS: ""
defaults:
run:
shell: bash
working-directory: sources
steps:
- uses: actions/checkout@v4
with:
submodules: true
path: sources
- name: Cache Composer downloads
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: composer-cache-${{ runner.os }}-${{ hashFiles('sources/composer.lock') }}
restore-keys: |
composer-cache-${{ runner.os }}-
- name: Install PHP dependencies in sources
shell: bash
run: |
set -euo pipefail
COMPOSER_CACHE_DIR="${HOME}/.composer/cache"
docker run --rm --user "$(id -u):$(id -g)" \
-v "${COMPOSER_CACHE_DIR}":/tmp/composer-cache \
-v "${GITHUB_WORKSPACE}/sources":/app -w /app \
-e COMPOSER_CACHE_DIR=/tmp/composer-cache \
composer install --no-interaction --ignore-platform-reqs
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: sources/package-lock.json
- name: Install npm dependencies
run: npm ci
- name: Install Playwright system dependencies
run: npx playwright install-deps chromium firefox
- name: Install Playwright Chromium
timeout-minutes: 10
env:
DEBUG: pw:install
run: npx playwright install chromium
- name: Install Playwright Firefox
timeout-minutes: 10
env:
DEBUG: pw:install
run: npx playwright install firefox
- name: Run jstest
run: npm run jstest