Skip to content

Commit 87d1057

Browse files
committed
feat(ci): add ocr/stt integration test
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent 50d5ed2 commit 87d1057

27 files changed

Lines changed: 406 additions & 15 deletions

.github/workflows/integration-test.yml

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
path: apps/context_chat
115115
persist-credentials: false
116116
# todo: remove later
117-
ref: feat/reverse-content-flow
117+
ref: feat/noid/ocr-support
118118

119119
- name: Checkout backend
120120
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
@@ -153,8 +153,8 @@ jobs:
153153
./occ maintenance:install --verbose --database=${{ matrix.databases }} --database-name=nextcloud --database-host=127.0.0.1 --database-port=$PGSQL_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
154154
composer run serve &
155155
156-
- name: Enable context_chat, app_api and testing
157-
run: ./occ app:enable -vvv -f context_chat app_api testing
156+
- name: Enable context_chat and app_api
157+
run: ./occ app:enable -vvv -f context_chat app_api
158158

159159
- name: Checkout documentation
160160
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
@@ -165,6 +165,7 @@ jobs:
165165

166166
- name: Prepare docs
167167
run: |
168+
cp -r context_chat_backend/tests/res data/admin/files/
168169
cd data/admin/files
169170
mv documentation/admin_manual .
170171
cp -R documentation/developer_manual .
@@ -204,12 +205,25 @@ jobs:
204205
echo $! > ../pid.txt # Save the process ID (PID)
205206
sleep 60 # Wait for the backend to get ready
206207
207-
- name: Register backend
208+
- name: Setup the fake OCR and STT provider
209+
run: |
210+
cd context_chat_backend/tests/ex_app/lib
211+
python3 -u main.py >& ../../../ocr_stt_exapp_logs &
212+
213+
- name: Register backend and the OCR/STT provider
208214
run: |
209215
timeout 10 ./occ app_api:daemon:register --net host manual_install "Manual Install" manual-install http localhost http://localhost:8080
210-
timeout 120 ./occ app_api:app:register context_chat_backend manual_install --json-info "{\"appid\":\"context_chat_backend\",\"name\":\"Context Chat Backend\",\"daemon_config_name\":\"manual_install\",\"version\":\"${{ fromJson(steps.appinfo.outputs.result).version }}\",\"secret\":\"12345\",\"port\":10034,\"scopes\":[],\"system_app\":0}" --force-scopes --wait-finish
216+
timeout 120 ./occ app_api:app:register ccb_test_providers manual_install --json-info "{\"appid\":\"ccb_test_providers\",\"name\":\"CCB Test Providers\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":10020}" --wait-finish
217+
timeout 120 ./occ app_api:app:register context_chat_backend manual_install --json-info "{\"appid\":\"context_chat_backend\",\"name\":\"Context Chat Backend\",\"daemon_config_name\":\"manual_install\",\"version\":\"${{ fromJson(steps.appinfo.outputs.result).version }}\",\"secret\":\"12345\",\"port\":10034}" --wait-finish
211218
ls -la context_chat_backend/persistent_storage/*
212219
220+
- name: Enable multimodal indexing
221+
run: |
222+
./occ context_chat:queue-multimodal-files
223+
224+
- name: Enable the testing app late so it does not register for the OCR/STT first
225+
run: ./occ app:enable testing
226+
213227
- name: Initial memory usage check
214228
run: |
215229
ps -p $(cat pid.txt) -o pid,cmd,%mem,rss --sort=-%mem
@@ -301,17 +315,34 @@ jobs:
301315
./occ background-job:worker 'OC\TaskProcessing\SynchronousBackgroundJob' > worker1_logs 2>&1 &
302316
./occ background-job:worker 'OC\TaskProcessing\SynchronousBackgroundJob' > worker2_logs 2>&1 &
303317
304-
echo ::group::English prompt
305-
OUT1=$(./occ context_chat:prompt admin "Which factors are taken into account for the Ethical AI Rating?")
306-
echo "$OUT1"
307-
echo "$OUT1" | grep -q "If all of these points are met, we give a Green label." || exit 1
308-
echo ::endgroup::
318+
# Each entry: "Label|prompt text|grep pattern|grep flags"
319+
checks=(
320+
"Text - Ethical AI Rating (EN)|Which factors are taken into account for the Ethical AI Rating?|If all of these points are met, we give a Green label.|"
321+
"Text - Ethical AI Rating (DE)|Welche Faktoren beeinflussen das Ethical AI Rating?|If all of these points are met, we give a Green label.|"
322+
"Text - occ maintenance mode|How do I enable maintenance mode in Nextcloud using the command line?|maintenance:mode --on|-iE"
323+
"Text - background job configuration|What are the available background job execution methods in Nextcloud?|cron|webcron|ajax|-iE"
324+
"STT - Amazon oxygen fraction|What fraction of the world's oxygen supply does the Amazon rainforest produce?|twenty percent|-i"
325+
"STT - quantum computing|How does quantum computing perform calculations?|superposition|entanglement|-iE"
326+
"STT - Jungle Book|Who raised Mowgli in the jungle and which villain does he face?|wolves|Shere Khan|-iE"
327+
"OCR - invoice total|What is the total amount on invoice number 10042?|299|-E"
328+
"OCR - train to Amsterdam|What time does the express train to Amsterdam depart from Platform 3?|08:14|"
329+
)
330+
331+
failed=0
332+
for entry in "${checks[@]}"; do
333+
IFS='|' read -r label prompt pattern flags <<< "$entry"
334+
echo "::group::$label"
335+
OUT=$(./occ context_chat:prompt admin "$prompt")
336+
echo "$OUT"
337+
# shellcheck disable=SC2086
338+
if ! echo "$OUT" | grep -q $flags "$pattern"; then
339+
echo "FAIL: expected to find '$pattern' in output"
340+
failed=1
341+
fi
342+
echo "::endgroup::"
343+
done
309344
310-
echo ::group::German prompt
311-
OUT2=$(./occ context_chat:prompt admin "Welche Faktoren beeinflussen das Ethical AI Rating?")
312-
echo "$OUT2"
313-
echo "$OUT2" | grep -q "If all of these points are met, we give a Green label." || exit 1
314-
echo ::endgroup::
345+
[ $failed -eq 0 ] || exit 1
315346
316347
- name: Check python memory usage
317348
run: |
@@ -351,6 +382,11 @@ jobs:
351382
run: |
352383
tail -v -n +1 worker?_logs || echo "No worker logs"
353384
385+
- name: Show ccb_test_providers app logs
386+
if: always()
387+
run: |
388+
cat context_chat_backend/ocr_stt_exapp_logs || echo "No ccb_test_providers app logs"
389+
354390
- name: Show main app logs
355391
if: always()
356392
run: |

REUSE.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ path = ["requirements.txt", "requirements_dev.txt"]
1010
precedence = "aggregate"
1111
SPDX-FileCopyrightText = "2024 Nextcloud GmbH and Nextcloud contributors"
1212
SPDX-License-Identifier = "AGPL-3.0-or-later"
13+
14+
[[annotations]]
15+
path = ["tests/res/**"]
16+
precedence = "aggregate"
17+
SPDX-FileCopyrightText = "2026 Nextcloud GmbH and Nextcloud contributors"
18+
SPDX-License-Identifier = "CC0-1.0"

tests/ex_app/appinfo/info.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
- SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
4+
- SPDX-License-Identifier: AGPL-3.0-or-later
5+
-->
6+
<info>
7+
<id>ccb_test_providers</id>
8+
<name>CCB Test Providers</name>
9+
<summary>Mock STT and OCR providers for CCB integration tests</summary>
10+
<version>1.0.0</version>
11+
<licence>AGPL-3.0-or-later</licence>
12+
<author>Nextcloud</author>
13+
<namespace>CcbTestProviders</namespace>
14+
<category>ai</category>
15+
<dependencies>
16+
<nextcloud min-version="32" max-version="99" />
17+
</dependencies>
18+
<external-app>
19+
<docker-install>
20+
<registry>ghcr.io</registry>
21+
<image>nextcloud/ccb_test_providers</image>
22+
<image-tag>1.0.0</image-tag>
23+
</docker-install>
24+
</external-app>
25+
</info>

0 commit comments

Comments
 (0)