-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (162 loc) · 6.98 KB
/
tests-integration.yml
File metadata and controls
179 lines (162 loc) · 6.98 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
name: Integration Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test-integration:
name: NC ${{ matrix.nextcloud-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nextcloud-version: ["32", "33"]
services:
nextcloud:
image: nextcloud:${{ matrix.nextcloud-version }}
env:
SQLITE_DATABASE: nextcloud
NEXTCLOUD_ADMIN_USER: admin
NEXTCLOUD_ADMIN_PASSWORD: admin
ports:
- 8080:80
options: >-
--health-cmd "curl -f http://localhost/status.php || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 30
--health-start-period 60s
smtp4dev:
image: rnwood/smtp4dev:latest
env:
ServerOptions__BasePath: /smtp4dev
ports:
- 9025:25
- 9143:143
- 9080:80
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: pip install -e ".[dev]"
- name: Wait for Nextcloud
run: |
for i in $(seq 1 60); do
if curl -sf http://localhost:8080/status.php | python3 -c "import sys,json; sys.exit(0 if json.load(sys.stdin)['installed'] else 1)" 2>/dev/null; then
echo "Nextcloud is ready"
break
fi
echo "Waiting... ($i)"
sleep 3
done
- name: Configure Nextcloud for testing
run: |
NC_CONTAINER=${{ job.services.nextcloud.id }}
OCC="docker exec $NC_CONTAINER su -s /bin/bash www-data -c"
$OCC "php occ config:system:set ratelimit_protection_enabled --value=false --type=boolean"
$OCC "php occ config:system:set auth.bruteforce.protection.enabled --value=false --type=boolean"
$OCC "php occ config:system:set loglevel --value=2 --type=integer"
$OCC "php occ config:system:set ratelimit_overwrite files_sharing.shareapi.createshare user limit --value=1000 --type=integer"
$OCC "php occ config:system:set ratelimit_overwrite files_sharing.shareapi.createshare user period --value=60 --type=integer"
$OCC "php occ app:install spreed" || echo "spreed already installed"
$OCC "php occ app:install announcementcenter" || echo "announcementcenter already installed"
$OCC "php occ app:install mail"
SMTP4DEV_IP=$(docker inspect ${{ job.services.smtp4dev.id }} --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')
echo "smtp4dev IP: $SMTP4DEV_IP"
$OCC "php occ mail:account:create admin 'Test Mail' test@localhost $SMTP4DEV_IP 143 none test test $SMTP4DEV_IP 25 none test test"
$OCC "php occ mail:account:sync 1"
APP_PASS=$($OCC "php occ user:auth-tokens:add admin" | grep -oP '[A-Za-z0-9]{72}' | head -1)
if [ -z "$APP_PASS" ]; then echo "::error::Failed to generate app password"; exit 1; fi
echo "::add-mask::$APP_PASS"
echo "NC_APP_PASSWORD=$APP_PASS" >> "$GITHUB_ENV"
- name: Run integration tests
env:
NEXTCLOUD_URL: http://localhost:8080
NEXTCLOUD_USER: admin
NEXTCLOUD_PASSWORD: ${{ env.NC_APP_PASSWORD }}
NEXTCLOUD_MCP_APP_PASSWORD: "true"
SMTP4DEV_HOST: localhost
SMTP4DEV_HTTP_PORT: "9080"
SMTP4DEV_SMTP_PORT: "9025"
MAIL_RECIPIENT: test@localhost
NC_CONTAINER: ${{ job.services.nextcloud.id }}
MAIL_ACCOUNT_ID: "1"
run: pytest tests/integration/ -v -m integration --ignore=tests/integration/test_session_cache.py --cov=nc_mcp_server --cov-report=xml:coverage-integration.xml
- name: Upload coverage
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5
with:
files: coverage-integration.xml
flags: integration,nc${{ matrix.nextcloud-version }}
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Dump Nextcloud logs on failure
if: failure()
run: |
docker exec ${{ job.services.nextcloud.id }} cat /var/www/html/data/nextcloud.log 2>/dev/null | tail -50 || echo "No logs found"
test-session-cache:
name: Session cache (NC ${{ matrix.nextcloud-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nextcloud-version: ["32", "33"]
services:
nextcloud:
image: nextcloud:${{ matrix.nextcloud-version }}
env:
SQLITE_DATABASE: nextcloud
NEXTCLOUD_ADMIN_USER: admin
NEXTCLOUD_ADMIN_PASSWORD: admin
ports:
- 8080:80
options: >-
--health-cmd "curl -f http://localhost/status.php || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 30
--health-start-period 60s
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: pip install -e ".[dev]"
- name: Wait for Nextcloud
run: |
for i in $(seq 1 60); do
if curl -sf http://localhost:8080/status.php | python3 -c "import sys,json; sys.exit(0 if json.load(sys.stdin)['installed'] else 1)" 2>/dev/null; then
echo "Nextcloud is ready"
break
fi
echo "Waiting... ($i)"
sleep 3
done
- name: Configure Nextcloud for testing
run: |
NC_CONTAINER=${{ job.services.nextcloud.id }}
docker exec $NC_CONTAINER su -s /bin/bash www-data -c "php occ config:system:set ratelimit_protection_enabled --value=false --type=boolean"
docker exec $NC_CONTAINER su -s /bin/bash www-data -c "php occ config:system:set auth.bruteforce.protection.enabled --value=false --type=boolean"
- name: Run session cache tests (regular password)
env:
NEXTCLOUD_URL: http://localhost:8080
NEXTCLOUD_USER: admin
NEXTCLOUD_PASSWORD: admin
NC_CONTAINER: ${{ job.services.nextcloud.id }}
run: pytest tests/integration/test_session_cache.py -v -m integration --cov=nc_mcp_server --cov-report=xml:coverage-session-cache.xml
- name: Upload coverage
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5
with:
files: coverage-session-cache.xml
flags: session-cache
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Dump Nextcloud logs on failure
if: failure()
run: |
docker exec ${{ job.services.nextcloud.id }} cat /var/www/html/data/nextcloud.log 2>/dev/null | tail -50 || echo "No logs found"