-
Notifications
You must be signed in to change notification settings - Fork 111
383 lines (365 loc) · 15.3 KB
/
tests.yaml
File metadata and controls
383 lines (365 loc) · 15.3 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
---
name: tests
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
tests:
name: ${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ${{ github.event_name == 'pull_request' && fromJSON('["3.10", "3.14"]') || fromJSON('["3.10", "3.11", "3.12", "3.13", "3.14"]') }}
services:
baikal:
image: ckulka/baikal:nginx
ports:
- 8800:80
options: >-
--health-cmd "curl -f http://localhost/ || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-start-period 30s
nextcloud:
image: nextcloud:latest
ports:
- 8801:80
env:
NEXTCLOUD_ADMIN_USER: admin
NEXTCLOUD_ADMIN_PASSWORD: admin
options: >-
--health-cmd "curl -f http://localhost/status.php || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-start-period 60s
cyrus:
# Pinned to last known-good build (pre-April-2026 multi-stage rebuild
# that broke CalDAV startup). Unpin once upstream is fixed.
# Working digest confirmed in CI run 23748898521 (2026-03-30).
image: ghcr.io/cyrusimap/cyrus-docker-test-server@sha256:d639a9116691a7a1c875073486c419d60843e5ef8e32e65c5ef56283874dbf2c
ports:
- 8802:8080
- 8001:8001
env:
DEFAULTDOMAIN: example.com
SERVERNAME: cyrus-test
options: >-
--health-cmd "curl -s http://localhost:8080/ || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-start-period 60s
sogo-db:
image: mariadb:11
env:
MYSQL_DATABASE: sogo
MYSQL_USER: sogo
MYSQL_PASSWORD: sogo
MYSQL_ROOT_PASSWORD: sogo
options: >-
--health-cmd "healthcheck.sh --connect --innodb_initialized"
--health-interval 5s
--health-timeout 5s
--health-retries 20
--health-start-period 10s
--network-alias db
sogo:
image: japoch/sogo:latest
ports:
- 8803:80
env:
sogo_user: testuser
sogo_pass: testpass
sogo_name: Test User
sogo_fqhn: example.com
bedework:
image: ioggstream/bedework:latest
ports:
- 8804:8080
options: >-
--health-cmd "curl -f http://localhost:8080/bedework/ || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 15
--health-start-period 120s
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip|${{ hashFiles('setup.py') }}|${{ hashFiles('tox.ini') }}
- run: pip install tox
- name: Configure Baikal with pre-seeded database
run: |
# Copy pre-configured database and config to Baikal container
docker cp tests/docker-test-servers/baikal/Specific/. ${{ job.services.baikal.id }}:/var/www/baikal/Specific/
docker cp tests/docker-test-servers/baikal/config/. ${{ job.services.baikal.id }}:/var/www/baikal/config/
# Fix permissions for SQLite
docker exec ${{ job.services.baikal.id }} chown -R nginx:nginx /var/www/baikal/Specific /var/www/baikal/config
docker exec ${{ job.services.baikal.id }} chmod -R 770 /var/www/baikal/Specific
# Restart to pick up configuration
docker restart ${{ job.services.baikal.id }}
- name: Wait for Baikal to be ready
run: |
sleep 5
if timeout 60 bash -c 'until curl -f http://localhost:8800/ 2>/dev/null; do echo "Waiting..."; sleep 2; done'; then
echo "✓ Baikal is ready!"
else
echo "✗ Error: Baikal did not become ready within 60 seconds"
exit 1
fi
- name: Configure Nextcloud
run: |
# Wait for Nextcloud web server to be up
echo "Waiting for Nextcloud web server..."
if timeout 60 bash -c 'until curl -f http://localhost:8801/status.php 2>/dev/null; do echo -n "."; sleep 2; done'; then
echo ""
echo "✓ Web server is up"
else
echo ""
echo "✗ Error: Nextcloud web server did not become ready within 60 seconds"
exit 1
fi
# Install Nextcloud if not already installed
if ! docker exec ${{ job.services.nextcloud.id }} php occ status 2>/dev/null | grep -q "installed: true"; then
echo "Installing Nextcloud..."
docker exec ${{ job.services.nextcloud.id }} php occ maintenance:install \
--database=sqlite \
--admin-user=admin \
--admin-pass=admin
echo "✓ Nextcloud installed"
else
echo "✓ Nextcloud is already installed"
fi
# Disable password policy
docker exec ${{ job.services.nextcloud.id }} php occ app:disable password_policy || true
# Create test user
docker exec -e OC_PASS="testpass" ${{ job.services.nextcloud.id }} php occ user:add --password-from-env --display-name="Test User" testuser || echo "User may already exist"
# Create scheduling test users (user1-user3)
for i in 1 2 3; do
docker exec -e OC_PASS="testpass${i}" ${{ job.services.nextcloud.id }} php occ user:add --password-from-env --display-name="User ${i}" "user${i}" || echo "user${i} may already exist"
done
# Enable calendar and contacts apps
docker exec ${{ job.services.nextcloud.id }} php occ app:enable calendar || true
docker exec ${{ job.services.nextcloud.id }} php occ app:enable contacts || true
# Disable rate limiting and bruteforce protection
docker exec ${{ job.services.nextcloud.id }} php occ config:system:set ratelimit.enabled --value=false --type=boolean || true
docker exec ${{ job.services.nextcloud.id }} php occ app:disable bruteforcesettings || true
docker exec ${{ job.services.nextcloud.id }} php occ config:system:set auth.bruteforce.protection.enabled --value=false --type=boolean || true
# Configure CalDAV rate limits
docker exec ${{ job.services.nextcloud.id }} php occ config:app:set dav rateLimitCalendarCreation --value=99999 || true
docker exec ${{ job.services.nextcloud.id }} php occ config:app:set dav maximumCalendarsSubscriptions --value=-1 || true
# Add IP whitelist for rate limiting
docker exec ${{ job.services.nextcloud.id }} php occ config:system:set ratelimit.whitelist.0 --value='172.17.0.0/16' || true
docker exec ${{ job.services.nextcloud.id }} php occ config:system:set ratelimit.whitelist.1 --value='127.0.0.1' || true
# Clear rate limit cache
docker exec ${{ job.services.nextcloud.id }} php -r "
\$db = new PDO('sqlite:/var/www/html/data/nextcloud.db');
\$db->exec('DELETE FROM oc_ratelimit_entries');
\$db->exec('DELETE FROM oc_bruteforce_attempts');
echo 'Cleared rate limit and bruteforce caches\n';
" || true
echo "Nextcloud is configured!"
- name: Wait for Cyrus to be ready
run: |
echo "Waiting for Cyrus server..."
# Cyrus takes a bit longer to initialize
sleep 10
if timeout 60 bash -c 'until curl -s http://localhost:8802/ 2>/dev/null | grep -q .; do echo -n "."; sleep 2; done'; then
echo ""
echo "✓ Cyrus HTTP server is ready"
else
echo ""
echo "✗ Error: Cyrus HTTP server did not become ready within 60 seconds"
exit 1
fi
# Verify CalDAV access with pre-created user
# Cyrus CalDAV can take significant time to initialize, especially in CI
echo "Waiting for CalDAV access..."
if timeout 120 bash -c 'until curl -s -X PROPFIND -H "Depth: 0" -u user1:x http://localhost:8802/dav/calendars/user/user1/ 2>/dev/null | grep -qi "multistatus\|collection" ; do echo -n "."; sleep 2; done'; then
echo ""
echo "✓ Cyrus CalDAV with pre-created user ready"
else
echo ""
echo "✗ Error: Cyrus CalDAV did not become accessible within 120 seconds"
echo "Attempting to debug..."
echo ""
echo "=== Container logs ==="
docker logs ${{ job.services.cyrus.id }} 2>&1 | tail -100 || true
echo ""
echo "=== Listening ports inside container ==="
docker exec ${{ job.services.cyrus.id }} netstat -tlnp 2>&1 || true
echo ""
echo "=== Running processes ==="
docker exec ${{ job.services.cyrus.id }} ps aux 2>&1 || true
echo ""
echo "=== HTTP response from host ==="
curl -v http://localhost:8802/ 2>&1 || true
echo ""
echo "=== CalDAV PROPFIND response from host ==="
curl -v -X PROPFIND -H "Depth: 0" -u user1:x http://localhost:8802/dav/calendars/user/user1/ 2>&1 || true
echo ""
echo "=== HTTP response from inside container ==="
docker exec ${{ job.services.cyrus.id }} curl -v http://localhost:8080/ 2>&1 || true
exit 1
fi
- name: Configure SOGo
run: |
echo "Configuring SOGo..."
# Wait for database to be ready
echo "Waiting for database..."
sleep 5
# Initialize database with test user
docker cp tests/docker-test-servers/sogo/init-sogo-users.sql ${{ job.services.sogo-db.id }}:/tmp/init-sogo-users.sql
docker exec -i ${{ job.services.sogo-db.id }} mariadb -usogo -psogo sogo < tests/docker-test-servers/sogo/init-sogo-users.sql
echo "✓ Database initialized with test user"
# Copy SOGo configuration (database is now reachable via network alias 'db')
docker cp tests/docker-test-servers/sogo/sogo.conf ${{ job.services.sogo.id }}:/etc/sogo/sogo.conf
echo "✓ SOGo configuration copied"
# Restart SOGo to pick up configuration
docker restart ${{ job.services.sogo.id }}
# Wait for SOGo to be ready
echo "Waiting for SOGo to start..."
if timeout 60 bash -c 'until curl -f http://localhost:8803/SOGo/ 2>/dev/null; do echo -n "."; sleep 2; done'; then
echo ""
echo "✓ SOGo is ready"
else
echo ""
echo "✗ Error: SOGo did not become ready within 60 seconds"
exit 1
fi
# Verify CalDAV access
echo "Verifying CalDAV access..."
if curl -s -X PROPFIND -H "Depth: 0" -u testuser:testpass http://localhost:8803/SOGo/dav/testuser/Calendar/ 2>/dev/null | grep -qi "multistatus"; then
echo "✓ SOGo CalDAV access verified"
else
echo "✗ Error: SOGo CalDAV access failed"
exit 1
fi
- name: Configure Bedework
run: |
echo "Waiting for Bedework..."
# Bedework/JBoss takes longer to start up
if timeout 180 bash -c 'until curl -f http://localhost:8804/bedework/ 2>/dev/null; do echo -n "."; sleep 5; done'; then
echo ""
echo "✓ Bedework web interface is ready"
else
echo ""
echo "✗ Error: Bedework did not become ready within 180 seconds"
exit 1
fi
# Verify CalDAV access with default user (vbede:bedework)
echo "Verifying CalDAV access..."
if curl -s -X PROPFIND -H "Depth: 0" -u vbede:bedework http://localhost:8804/ucaldav/user/vbede/ 2>/dev/null | grep -qi "multistatus"; then
echo "✓ Bedework CalDAV access verified"
else
echo "✗ Error: Bedework CalDAV access failed"
exit 1
fi
- run: tox -e py
env:
NEXTCLOUD_URL: http://localhost:8801
BAIKAL_URL: http://localhost:8800
CYRUS_URL: http://localhost:8802
SOGO_URL: http://localhost:8803
BEDEWORK_URL: http://localhost:8804
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.14"
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip|${{ hashFiles('setup.py') }}|${{ hashFiles('tox.ini') }}
- run: pip install tox
- run: tox -e docs
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.14"
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip|${{ hashFiles('setup.py') }}|${{ hashFiles('tox.ini') }}
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ hashFiles('.pre-commit-config.yaml') }}
- run: pip install tox
- run: tox -e style
deptry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip|${{ hashFiles('setup.py') }}|${{ hashFiles('tox.ini') }}
- run: pip install tox
- run: tox -e deptry
async-niquests:
# Test that async code works with niquests when httpx is not installed
name: async (niquests fallback)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies without httpx
run: |
pip install --editable .[test]
pip uninstall -y httpx
- name: Verify niquests is used
run: |
python -c "
from caldav.async_davclient import _USE_HTTPX, _USE_NIQUESTS
assert not _USE_HTTPX, 'httpx should not be available'
assert _USE_NIQUESTS, 'niquests should be used'
print('✓ Using niquests for async HTTP')
"
- name: Run async tests with niquests
run: pytest tests/test_async_davclient.py -v
sync-requests:
# Test that sync code works with requests when niquests is not installed
name: sync (requests fallback)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies with requests instead of niquests
run: |
pip install --editable .[test]
pip uninstall -y niquests
pip install requests
- name: Verify requests is used
run: |
python -c "
from caldav.davclient import _USE_REQUESTS, _USE_NIQUESTS
assert _USE_REQUESTS, 'requests should be available'
assert not _USE_NIQUESTS, 'niquests should not be available'
print('✓ Using requests for sync HTTP')
"
- name: Run sync tests with requests
run: pytest tests/test_caldav.py -v -k "Radicale" --ignore=tests/test_async_integration.py