Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add make test-kitodo #63

Merged
merged 18 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions .github/workflows/makefile-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ name: Makefile CI
on:
# Triggers the workflow on push and pull request events but only for pull_requests on the main branch
push:
branches:
- main

pull_request:
branches: [ main ]
branches:
- main

# Allows you to run this workflow manually
workflow_dispatch:
Expand Down Expand Up @@ -37,10 +41,13 @@ jobs:

- name: Start
run: make start

- name: Test
run: make test

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
- name: Test
run: make test

- name: Clean testdata
run: make clean-testdata

- name: Test parallel using multiple workers
run: CONTROLLER_WORKERS=3 make -j test

30 changes: 29 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ COMPOSE_PROFILES ?= with-kitodo-production,with-ocrd-controller
.EXPORT_ALL_VARIABLES:

# conditional assignment operator ?= creates deferred variables only, so use conditionals directly:
ifndef APP_DATA
APP_DATA != source .env && echo $$APP_DATA # ${PWD}/kitodo/data
endif
ifndef APP_KEY
APP_KEY != source .env && echo $$APP_KEY # ./kitodo/.ssh/id_rsa
endif
ifndef APP_PORT
APP_PORT != source .env && echo $$APP_PORT # 8080
endif
ifndef MANAGER_KEYS
MANAGER_KEYS != source .env && echo $$MANAGER_KEYS # ./ocrd/manager/.ssh/authorized_keys
endif
Expand Down Expand Up @@ -144,6 +150,28 @@ config:

status:
docker compose ps


$(APP_DATA)/metadata/testdata-kitodo:
mkdir -p $@/images
for page in {00000009..00000014}; do \
wget -P $@/images https://digital.slub-dresden.de/data/kitodo/LankDres_1760234508/LankDres_1760234508_tif/jpegs/$$page.tif.original.jpg; \
done

test: test-kitodo

test-kitodo: $(APP_DATA)/metadata/testdata-kitodo
# remove ocr directory if exist
rm -rf $(APP_DATA)/metadata/testdata-kitodo/ocr
# wait until Kitodo.Production directory structure is initialized
docker exec -t `docker container ls -qf name=kitodo-app` bash -c "/wait-for-it.sh -t 0 kitodo-app:$$APP_PORT"
# run asynchronous ocr processing, which should return within 5 seconds with exit status 1
timeout --preserve-status 5 docker exec -t `docker container ls -qf name=kitodo-app` bash -c '/usr/local/kitodo/scripts/script_ocr_process_dir.sh "testdata-kitodo" 1'; test $$? = 1
# check with interval of 1 second if ocr folder exists. It fails if the ocr folder is not created within 5 minutes.
timeout 5m bash -c 'until ls $(APP_DATA)/metadata/testdata-kitodo -R | grep -m 1 "00000014.tif.original.xml"; do : sleep 5; done'
markusweigelt marked this conversation as resolved.
Show resolved Hide resolved
# rest if the alto directory and file exist
test -d $(APP_DATA)/metadata/testdata-kitodo/ocr/alto
test -s $(APP_DATA)/metadata/testdata-kitodo/ocr/alto/00000009.tif.original.xml

test test-production test-presentation clean-testdata: NETWORK=ocrd_kitodo_default
# if there is no shell override for MANAGER_DATA, then get it from the .env
Expand Down Expand Up @@ -180,7 +208,7 @@ endef
export HELP
help: ; @eval "$$HELP"

.PHONY: clean clean-testdata prepare prepare-keys prepare-examples build build-kitodo start down config status test help
.PHONY: clean clean-testdata prepare prepare-keys prepare-examples build build-kitodo start down config status test test-kitodo help

# do not search for implicit rules here:
%.zip: ;
Expand Down