blob: 4e6cfb505fa2d01428643db5c55634a5a0212519 [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
Marc Kupietz6d534882024-03-17 16:25:26 +010037build-index:
Marc Kupietz3d82f562024-03-16 10:19:03 +010038 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"
Marc Kupietz420260d2024-03-17 19:14:10 +010076 - docker image inspect korap/conllu2treetagger:latest >/dev/null 2>&1 || curl -Ls 'https://gitlab.ids-mannheim.de/KorAP/CoNLL-U-Treetagger/-/jobs/artifacts/master/raw/conllu2treetagger.xz?job=build-docker-image' | docker load
Marc Kupietzb169c272024-03-16 12:07:54 +010077 - end_section install_tree_tagger
78
Marc Kupietz6d534882024-03-17 16:25:26 +010079 - start_section install_spacy "Installing spaCy"
Marc Kupietz420260d2024-03-17 19:14:10 +010080 - docker image inspect korap/conllu2spacy:latest >/dev/null 2>&1 || curl -Ls https://corpora.ids-mannheim.de/tools/conllu2spacy.tar.xz | docker load
Marc Kupietz6d534882024-03-17 16:25:26 +010081 - end_section install_spacy
82
Marc Kupietz3d82f562024-03-16 10:19:03 +010083 - start_section install_perl_packages "Installing missing Perl packages"
84 - curl -L https://cpanmin.us | perl - App::cpanminus
85 - cpanm -n -l $PERL_LOCAL_LIB_ROOT File::ShareDir::Install https://github.com/KorAP/KorAP-XML-TEI.git
Marc Kupietz61b30ed2024-03-18 07:22:51 +010086 - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/kupietz/KorAP-XML-Krill.git
Marc Kupietz3d82f562024-03-16 10:19:03 +010087 - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/KorAP/KorAP-XML-CoNLL-U.git
88 - end_section install_perl_packages
89
90 script:
91 - export PATH=$PERL_LOCAL_LIB_ROOT/bin:$PATH
Marc Kupietz6d534882024-03-17 16:25:26 +010092 - start_section building_index "Building index"
Marc Kupietz420260d2024-03-17 19:14:10 +010093 - touch target/*.zip # ignore timestamps in make
94 - sleep 1
95 - touch target/*.ud.zip
Marc Kupietz6d534882024-03-17 16:25:26 +010096 - make -j $(nproc) target/dnb.index.tar.xz
Marc Kupietz3d82f562024-03-16 10:19:03 +010097 - end_section building_krill
98 artifacts:
99 paths:
Marc Kupietzb169c272024-03-16 12:07:54 +0100100 - target/*.zip
Marc Kupietz6d534882024-03-17 16:25:26 +0100101 - target/dnb.index.tar.xz
Marc Kupietz3d82f562024-03-16 10:19:03 +0100102
103deploy:
104 stage: deploy
105 dependencies:
Marc Kupietz420260d2024-03-17 19:14:10 +0100106 - "build-index"
Marc Kupietz3d82f562024-03-16 10:19:03 +0100107 when: manual
108 image: rocker/verse
109 before_script:
110 - source `find .. -name section_helper.sh`
111 - start_section setup_ssh "Setting up SSH"
112 - apt-get update
113 - apt-get install -y rsync openssh-client
114 - mkdir -p ~/.ssh
115 - chmod 700 ~/.ssh
116 - eval $(ssh-agent -s)
117 - chmod 400 $SSH_PRIVATE_KEY
118 - ssh-add $SSH_PRIVATE_KEY
119 - end_section setup_ssh
120 script:
121 - start_section korapxmlu "Uploading Krill to KorAP instance dnb"
122 - if [ $(ls target/*.krill.tar | wc -l) -lt 1 ]; then echo 'error - less than 1 Krill files found'; false; fi
123 - rm -rf json && mkdir -p json
124 - for f in target/*.krill.tar; do tar -C json -xf $f; done
125 - rsync -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -avz --delete json korap@$DEPLOY_SERVER:/opt/korap/instance-dnb/
126 - end_section korapxmlu
127 - start_section korapxmlr "Indexing data & restarting KorAP instance dnb"
128 - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null korap@$DEPLOY_SERVER "cd /opt/korap/instance-dnb/ &&
129 rm -rf index && mkdir -p index &&
130 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"
131 - end_section korapxmlr
132 - echo "Deploying $VID"
133 - end_section deploy