-
Notifications
You must be signed in to change notification settings - Fork 3
115 lines (89 loc) · 4.1 KB
/
test-ci.yml
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
name: Test 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
# Allows you to run this workflow manually
workflow_dispatch:
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- name: Remove unwanted to provide more disk space
# https://github.com/marketplace/actions/maximize-build-disk-space
# https://github.com/actions/runner-images/issues/2840
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare
run: |
ssh-keygen -t rsa -q -f ~/.ssh/id_rsa -P '' -C 'Host'
# Rename example .env file
mv .env.example .env
sed -i "s/\${MONITOR_DB_ROOT_USER:-root}:\${MONITOR_DB_ROOT_PASSWORD:-root_password}/root:root_password/g" docker-compose.yml
# Remove carriage returns in file
sed -i 's/\r$//' .env
# Set environment variables from .env file
set -a; source .env; set +a
# Generate ssh keys
mkdir -p ./ocrd/manager/.ssh
ssh-keygen -t rsa -q -f $MANAGER_KEY -P '' -C 'OCR-D Manager'
# Create authorized_keys file with public key of host
cp ~/.ssh/id_rsa.pub ./ocrd/manager/.ssh/authorized_keys
# Create controller directories
mkdir -p ./ocrd/controller/.ssh/ ./ocrd/controller/models ./ocrd/controller/data
# Download necessary files from master of OCR-D Controller repository
wget -O .env.ocrd-controller https://raw.githubusercontent.com/slub/ocrd_controller/master/.env.example
wget -O docker-compose-controller.yml https://raw.githubusercontent.com/slub/ocrd_controller/master/docker-compose.yml
# TODO checkout OCR-D Controller directly
# Remove carriage returns in file
sed -i 's/\r$//' .env.ocrd-controller
# Set environment variables from .env.ocrd-controller file
set -a; source .env.ocrd-controller; set +a
# Add public key of OCR-D Manager
cp ${MANAGER_KEY}.pub ${CONTROLLER_KEYS}
# Download controller model
mkdir -p ./ocrd/controller/models/ocrd-resources/ocrd-tesserocr-recognize/
wget -O ${CONTROLLER_MODELS}/ocrd-resources/ocrd-tesserocr-recognize/frak2021.traineddata https://ub-backup.bib.uni-mannheim.de/~stweil/tesstrain/frak2021/tessdata_best/frak2021-0.905.traineddata
# TODO checkout OCR-D Monitor directly and extend ocrd-database
cat >> docker-compose-database.yml << EOF
services:
ocrd-database:
image: "mongo:latest"
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: root_password
EOF
- name: Build OCR-D Manager
run: docker compose build
- name: Install nvidia-container-runtime
run: |
curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker
- name: Start OCR-D Controller
run: docker compose --env-file=.env.ocrd-controller -f docker-compose-controller.yml up -d
- name: Start OCR-D Manager & OCR-D Database
run: docker compose -f docker-compose.yml -f docker-compose-database.yml up -d
- name: Test
run: |
cat >> ~/.ssh/config << EOF
Host *
UpdateHostKeys yes
EOF
make test
- name: Setup upterm session when failure
if: ${{ failure() && github.event_name == 'workflow_dispatch' }}
uses: lhotari/action-upterm@v1