blob: e98f5e8b212029bb38debcd95247c89b50379bd3 [file] [log] [blame]
Marc Kupietz3d82f562024-03-16 10:19:03 +01001
2stages:
3 - test
4 - build
5 - deploy
6
7variables:
8 VID: $VID
9 DEBIAN_FRONTEND: noninteractive
10 APT_CACHE_DIR: apt-cache
11
12build-and-test-i5:
13 stage: test
14 image: rocker/verse
15 artifacts:
16 paths:
17 - "target/*.i5.xml"
18 - "target/*.zip"
19 cache:
20 - key: DNB4KorAP
21 paths:
22 - apt-cache/
23
24 before_script:
25 - source `find .. -name section_helper.sh`
26 - start_section install_linux_packages "Installing missing Linux packages"
27 - apt-get -o dir::cache::archives="$APT_CACHE_DIR" update
28 - apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y libxml2-utils
29 - end_section install_linux_packages
30
31 script:
32 - start_section checking_i5 "Building and testing I5 files"
33 - make -j $(nproc) test
34 - end_section checking_i5
35
36
37build-krill:
38 image: perl:5.38
Marc Kupietzb169c272024-03-16 12:07:54 +010039 services:
40 - docker:dind
Marc Kupietz3d82f562024-03-16 10:19:03 +010041 stage: build
42 rules:
43 - if: $CI_COMMIT_TAG =~ /.+/
44 variables:
45 VID: $CI_COMMIT_TAG
46 - when: manual
47 variables:
48 VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
49 PERL_LOCAL_LIB_ROOT: ./perl5
50 PERL5LIB: ./perl5/lib/perl5
51 cache:
52 - key: DNB4KorAP
53 paths:
54 - $PERL_LOCAL_LIB_ROOT
55 - perl5/
56 - apt-cache/
57 - key:
58 files:
59 - target/dnb.i5.xml
60 paths:
61 - target/dnb.zip
62 - target/dnb.tree_tagger.zip
63 - target/dnb.ud.zip
64 - target/dnb.cmc.zip
65 - target/dnb.spacy.zip
66 - target/dnb.krill.tar
67 before_script:
68 - source `find .. -name section_helper.sh`
69 - start_section install_linux_packages "Installing missing Linux packages"
70 - mkdir -pv $APT_CACHE_DIR
71 - apt-get -o dir::cache::archives="$APT_CACHE_DIR" update
Marc Kupietzb169c272024-03-16 12:07:54 +010072 - apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y rsync pv jq curl openjdk-17-jre-headless docker.io
Marc Kupietz3d82f562024-03-16 10:19:03 +010073 - end_section install_linux_packages
74
Marc Kupietzb169c272024-03-16 12:07:54 +010075 - start_section install_tree_tagger "Installing TreeTagger"
76 - curl -Ls 'https://gitlab.ids-mannheim.de/KorAP/CoNLL-U-Treetagger/-/jobs/artifacts/master/raw/conllu2treetagger.xz?job=build-docker-image' | docker load
77 - end_section install_tree_tagger
78
Marc Kupietz3d82f562024-03-16 10:19:03 +010079 - start_section install_perl_packages "Installing missing Perl packages"
80 - curl -L https://cpanmin.us | perl - App::cpanminus
81 - cpanm -n -l $PERL_LOCAL_LIB_ROOT File::ShareDir::Install https://github.com/KorAP/KorAP-XML-TEI.git
82 - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/KorAP/KorAP-XML-Krill.git
83 - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/KorAP/KorAP-XML-CoNLL-U.git
84 - end_section install_perl_packages
85
86 script:
87 - export PATH=$PERL_LOCAL_LIB_ROOT/bin:$PATH
88 - start_section building_krill "Building Krill"
Marc Kupietzb169c272024-03-16 12:07:54 +010089 - touch target/*.i5.xml target/*.zip target/*.krill.tar # ignore timestamps in make
90 - make -j $(nproc) target/dnb.tree_tagger.zip
Marc Kupietzfc328622024-03-16 14:31:34 +010091 - make -j $(nproc) target/dnb.ud.zip
Marc Kupietz3d82f562024-03-16 10:19:03 +010092 - make -j $(nproc) krill
93 - ls -l target/*.krill.tar
94 - end_section building_krill
95 artifacts:
96 paths:
Marc Kupietzb169c272024-03-16 12:07:54 +010097 - target/*.krill.tar
98 - target/*.zip
Marc Kupietz3d82f562024-03-16 10:19:03 +010099
100deploy:
101 stage: deploy
102 dependencies:
103 - "build-krill"
104 when: manual
105 image: rocker/verse
106 before_script:
107 - source `find .. -name section_helper.sh`
108 - start_section setup_ssh "Setting up SSH"
109 - apt-get update
110 - apt-get install -y rsync openssh-client
111 - mkdir -p ~/.ssh
112 - chmod 700 ~/.ssh
113 - eval $(ssh-agent -s)
114 - chmod 400 $SSH_PRIVATE_KEY
115 - ssh-add $SSH_PRIVATE_KEY
116 - end_section setup_ssh
117 script:
118 - start_section korapxmlu "Uploading Krill to KorAP instance dnb"
119 - if [ $(ls target/*.krill.tar | wc -l) -lt 1 ]; then echo 'error - less than 1 Krill files found'; false; fi
120 - rm -rf json && mkdir -p json
121 - for f in target/*.krill.tar; do tar -C json -xf $f; done
122 - rsync -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -avz --delete json korap@$DEPLOY_SERVER:/opt/korap/instance-dnb/
123 - end_section korapxmlu
124 - start_section korapxmlr "Indexing data & restarting KorAP instance dnb"
125 - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null korap@$DEPLOY_SERVER "cd /opt/korap/instance-dnb/ &&
126 rm -rf index && mkdir -p index &&
127 docker run -u root --rm -v /opt/korap/instance-dnb:/data:z korap/kustvakt:latest-full Krill-Indexer.jar -c /kustvakt/kustvakt.conf -i /data/json -o /data/index/ && INDEX=./index docker-compose --profile=full -p kyc-ger restart"
128 - end_section korapxmlr
129 - echo "Deploying $VID"
130 - end_section deploy