Skip to content

Commit 500dffa

Browse files
committed
fix(ci): adjust CI according to the new changes
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent 316f667 commit 500dffa

2 files changed

Lines changed: 190 additions & 93 deletions

File tree

.github/workflows/integration-test-cron.yml

Lines changed: 93 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -282,45 +282,81 @@ jobs:
282282
- name: Enable context chat
283283
run: ./occ app:enable -vvv -f ${{ env.APP_NAME }}
284284

285-
- name: Run indexer cron
285+
- name: Run cron jobs
286286
run: |
287-
# Run cron in speed mode: Set interval to 0 minutes
288-
./occ config:app:set --value 30 --type integer context_chat indexing_job_interval # 30 seconds
289-
./occ config:app:set --value 10 --type integer context_chat crawl_job_interval # 10 seconds
290-
./occ config:app:set --value '10' --type string context_chat action_job_interval # 10 seconds
291-
./occ config:app:set --value '10' --type string context_chat fs_listener_job_interval # 10 seconds
292-
for i in {1..100}; do
293-
php cron.php & # Starting with stable31 we can use -v here for better visibility
294-
wait
295-
./occ context_chat:stats
296-
done
287+
# every 10 seconds indefinitely
288+
while true; do
289+
php cron.php
290+
sleep 10
291+
done &
292+
sleep 30
293+
# list all the bg jobs
294+
./occ background-job:list
297295
298-
- name: Check context chat state
296+
- name: Periodically check context_chat stats for 15 minutes to allow the backend to index the files
299297
run: |
300-
./occ context_chat:stats
301-
./occ background-job:list
302-
./occ context_chat:stats | grep -q "Index complete time" || echo "Indexing did not complete"
303-
./occ context_chat:stats | awk '
304-
/Total eligible files/ {
305-
total = $NF + 0 # force conversion to number
306-
}
307-
/files__default/ {
308-
indexed = $NF;
309-
sub(/,$/, "", indexed) # remove trailing comma
310-
indexed = indexed + 0 # force conversion to number
311-
}
312-
END {
313-
low = total * 0.85;
314-
high = total * 1.15;
315-
if (indexed >= low && indexed <= high) {
316-
print "✅ Indexed files (" indexed ") are within 15% of eligible files (" total ").";
317-
exit 0;
318-
} else {
319-
print "❌ Indexed files (" indexed ") are OUTSIDE the 15% range of eligible files (" total ").";
320-
exit 1;
321-
}
322-
}
323-
'
298+
success=0
299+
echo "::group::Checking stats periodically for 15 minutes to allow the backend to index the files"
300+
for i in {1..90}; do
301+
echo "Checking stats, attempt $i..."
302+
303+
stats_err=$(mktemp)
304+
stats=$(timeout 5 ./occ context_chat:stats --json 2>"$stats_err")
305+
stats_exit=$?
306+
echo "Stats output:"
307+
echo "$stats"
308+
if [ -s "$stats_err" ]; then
309+
echo "Stderr:"
310+
cat "$stats_err"
311+
fi
312+
echo "---"
313+
rm -f "$stats_err"
314+
315+
# Check for critical errors in output
316+
if [ $stats_exit -ne 0 ] || echo "$stats" | grep -q "Error during request"; then
317+
echo "Backend connection error detected (exit=$stats_exit), retrying..."
318+
sleep 10
319+
continue
320+
fi
321+
322+
# Extract total eligible files
323+
total_eligible_files=$(echo "$stats" | jq '.eligible_files_count' || echo "")
324+
325+
# Extract indexed documents count (files__default)
326+
indexed_count=$(echo "$stats" | jq '.vectordb_document_counts.files__default' || echo "")
327+
328+
echo "Total eligible files: $total_eligible_files"
329+
echo "Indexed documents (files__default): $indexed_count"
330+
331+
diff=$((total_eligible_files - indexed_count))
332+
threshold=$((total_eligible_files * 3 / 100))
333+
334+
# Check if difference is within tolerance
335+
if [ $diff -le $threshold ]; then
336+
echo "Indexing within 3% tolerance (diff=$diff, threshold=$threshold)"
337+
success=1
338+
break
339+
else
340+
progress=$((diff * 100 / total_eligible_files))
341+
echo "Outside 3% tolerance: diff=$diff (${progress}%), threshold=$threshold"
342+
fi
343+
344+
# Check if backend is still alive
345+
ccb_alive=$(ps -p $(cat pid.txt) -o cmd= | grep -c "main.py" || echo "0")
346+
if [ "$ccb_alive" -eq 0 ]; then
347+
echo "Error: Context Chat Backend process is not running. Exiting."
348+
exit 1
349+
fi
350+
351+
sleep 10
352+
done
353+
354+
echo "::endgroup::"
355+
356+
if [ $success -ne 1 ]; then
357+
echo "Max attempts reached"
358+
exit 1
359+
fi
324360
325361
- name: Run the prompts
326362
run: |
@@ -360,13 +396,30 @@ jobs:
360396
run: |
361397
cat data/context_chat.log
362398
363-
- name: Show backend logs
399+
- name: Show CCB main app logs
364400
if: always()
365401
run: |
366402
cat context_chat_backend/backend_logs || echo "No main backend logs"
367-
cat context_chat_backend/em_backend_logs || echo "No embedding server logs"
368-
echo '--------------------------------------------------'
369-
tail -v -n +1 context_chat_backend/persistent_storage/logs/* || echo "No logs in logs directory"
403+
404+
- name: Show CCB main app JSON logs
405+
if: always()
406+
run: |
407+
tail -v -n +1 context_chat_backend/persistent_storage/logs/ccb.log* || echo "No logs in logs directory"
408+
409+
- name: Show CCB embedding server logs
410+
if: always()
411+
run: |
412+
cat context_chat_backend/em_backend_logs || echo "No main backend logs"
413+
414+
- name: Show CCB embedding server JSON logs
415+
if: always()
416+
run: |
417+
tail -v -n +1 context_chat_backend/persistent_storage/logs/em_server.log* || echo "No logs in logs directory"
418+
419+
- name: Final stats log
420+
run: |
421+
./occ context_chat:stats
422+
./occ context_chat:stats --json
370423
371424
summary:
372425
permissions:

.github/workflows/integration-test-file-listener.yml

Lines changed: 97 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,6 @@ jobs:
210210
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
211211
sleep 60 # Wait for the embedding server to get ready
212212
213-
- name: Enable context chat
214-
run: |
215-
./occ app:enable -vvv -f ${{ env.APP_NAME }}
216-
# Run cron in speed mode
217-
./occ config:app:set --value 30 --type integer context_chat indexing_job_interval # 30 seconds
218-
./occ config:app:set --value 10 --type integer context_chat crawl_job_interval # 10 seconds
219-
./occ config:app:set --value '10' --type string context_chat action_job_interval # 10 seconds
220-
./occ config:app:set --value '10' --type string context_chat fs_listener_job_interval # 10 seconds
221-
# Run normal indexing jobs which will only pick up welcome.txt etc
222-
for i in {1..10}; do
223-
php cron.php & # Starting with stable31 we can use -v here for better visibility
224-
wait
225-
./occ context_chat:stats
226-
done
227-
228213
- name: Checkout documentation
229214
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
230215
with:
@@ -286,40 +271,81 @@ jobs:
286271
run: |
287272
./occ files:scan admin # We do the scan after enabling context chat here, so we can test the file listeners
288273
289-
- name: Run indexer cron
274+
- name: Run cron jobs
290275
run: |
291-
for i in {1..100}; do
292-
php cron.php & # Starting with stable31 we can use -v here for better visibility
293-
wait
294-
./occ context_chat:stats
295-
done
276+
# every 10 seconds indefinitely
277+
while true; do
278+
php cron.php
279+
sleep 10
280+
done &
281+
sleep 30
282+
# list all the bg jobs
283+
./occ background-job:list
296284
297-
- name: Check context chat state
285+
- name: Periodically check context_chat stats for 15 minutes to allow the backend to index the files
298286
run: |
299-
./occ context_chat:stats
300-
./occ background-job:list
301-
./occ context_chat:stats | grep -q "Index complete time" || echo "Indexing did not complete"
302-
./occ context_chat:stats | awk '
303-
/Total eligible files/ {
304-
total = $NF + 0 # force conversion to number
305-
}
306-
/files__default/ {
307-
indexed = $NF;
308-
sub(/,$/, "", indexed) # remove trailing comma
309-
indexed = indexed + 0 # force conversion to number
310-
}
311-
END {
312-
low = total * 0.85;
313-
high = total * 1.15;
314-
if (indexed >= low && indexed <= high) {
315-
print "✅ Indexed files (" indexed ") are within 15% of eligible files (" total ").";
316-
exit 0;
317-
} else {
318-
print "❌ Indexed files (" indexed ") are OUTSIDE the 15% range of eligible files (" total ").";
319-
exit 1;
320-
}
321-
}
322-
'
287+
success=0
288+
echo "::group::Checking stats periodically for 15 minutes to allow the backend to index the files"
289+
for i in {1..90}; do
290+
echo "Checking stats, attempt $i..."
291+
292+
stats_err=$(mktemp)
293+
stats=$(timeout 5 ./occ context_chat:stats --json 2>"$stats_err")
294+
stats_exit=$?
295+
echo "Stats output:"
296+
echo "$stats"
297+
if [ -s "$stats_err" ]; then
298+
echo "Stderr:"
299+
cat "$stats_err"
300+
fi
301+
echo "---"
302+
rm -f "$stats_err"
303+
304+
# Check for critical errors in output
305+
if [ $stats_exit -ne 0 ] || echo "$stats" | grep -q "Error during request"; then
306+
echo "Backend connection error detected (exit=$stats_exit), retrying..."
307+
sleep 10
308+
continue
309+
fi
310+
311+
# Extract total eligible files
312+
total_eligible_files=$(echo "$stats" | jq '.eligible_files_count' || echo "")
313+
314+
# Extract indexed documents count (files__default)
315+
indexed_count=$(echo "$stats" | jq '.vectordb_document_counts.files__default' || echo "")
316+
317+
echo "Total eligible files: $total_eligible_files"
318+
echo "Indexed documents (files__default): $indexed_count"
319+
320+
diff=$((total_eligible_files - indexed_count))
321+
threshold=$((total_eligible_files * 3 / 100))
322+
323+
# Check if difference is within tolerance
324+
if [ $diff -le $threshold ]; then
325+
echo "Indexing within 3% tolerance (diff=$diff, threshold=$threshold)"
326+
success=1
327+
break
328+
else
329+
progress=$((diff * 100 / total_eligible_files))
330+
echo "Outside 3% tolerance: diff=$diff (${progress}%), threshold=$threshold"
331+
fi
332+
333+
# Check if backend is still alive
334+
ccb_alive=$(ps -p $(cat pid.txt) -o cmd= | grep -c "main.py" || echo "0")
335+
if [ "$ccb_alive" -eq 0 ]; then
336+
echo "Error: Context Chat Backend process is not running. Exiting."
337+
exit 1
338+
fi
339+
340+
sleep 10
341+
done
342+
343+
echo "::endgroup::"
344+
345+
if [ $success -ne 1 ]; then
346+
echo "Max attempts reached"
347+
exit 1
348+
fi
323349
324350
- name: Run the prompts
325351
run: |
@@ -409,12 +435,13 @@ jobs:
409435
# list files to trigger mounting of shares
410436
curl -X PROPFIND -H "Depth: 0" -u 'test:test' 'http://localhost:8080/remote.php/webdav/'
411437
412-
- name: Run indexer cron
438+
- name: Show context chat stats for actions changes
413439
run: |
414-
for i in {1..100}; do
415-
php cron.php & # Starting with stable31 we can use -v here for better visibility
440+
for i in {1..20}; do
441+
php -v cron.php &
416442
wait
417443
./occ context_chat:stats
444+
echo '--------------------------------------'
418445
done
419446
420447
- name: Run the prompts again
@@ -494,13 +521,30 @@ jobs:
494521
run: |
495522
cat data/context_chat.log
496523
497-
- name: Show backend logs
524+
- name: Show CCB main app logs
498525
if: always()
499526
run: |
500527
cat context_chat_backend/backend_logs || echo "No main backend logs"
501-
cat context_chat_backend/em_backend_logs || echo "No embedding server logs"
502-
echo '--------------------------------------------------'
503-
tail -v -n +1 context_chat_backend/persistent_storage/logs/* || echo "No logs in logs directory"
528+
529+
- name: Show CCB main app JSON logs
530+
if: always()
531+
run: |
532+
tail -v -n +1 context_chat_backend/persistent_storage/logs/ccb.log* || echo "No logs in logs directory"
533+
534+
- name: Show CCB embedding server logs
535+
if: always()
536+
run: |
537+
cat context_chat_backend/em_backend_logs || echo "No main backend logs"
538+
539+
- name: Show CCB embedding server JSON logs
540+
if: always()
541+
run: |
542+
tail -v -n +1 context_chat_backend/persistent_storage/logs/em_server.log* || echo "No logs in logs directory"
543+
544+
- name: Final stats log
545+
run: |
546+
./occ context_chat:stats
547+
./occ context_chat:stats --json
504548
505549
summary:
506550
permissions:

0 commit comments

Comments
 (0)