blob: 9a3d737561c4989a3eeba73150a17ff11c33991e [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
39 stage: build
40 rules:
41 - if: $CI_COMMIT_TAG =~ /.+/
42 variables:
43 VID: $CI_COMMIT_TAG
44 - when: manual
45 variables:
46 VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
47 PERL_LOCAL_LIB_ROOT: ./perl5
48 PERL5LIB: ./perl5/lib/perl5
49 cache:
50 - key: DNB4KorAP
51 paths:
52 - $PERL_LOCAL_LIB_ROOT
53 - perl5/
54 - apt-cache/
55 - key:
56 files:
57 - target/dnb.i5.xml
58 paths:
59 - target/dnb.zip
60 - target/dnb.tree_tagger.zip
61 - target/dnb.ud.zip
62 - target/dnb.cmc.zip
63 - target/dnb.spacy.zip
64 - target/dnb.krill.tar
65 before_script:
66 - source `find .. -name section_helper.sh`
67 - start_section install_linux_packages "Installing missing Linux packages"
68 - mkdir -pv $APT_CACHE_DIR
69 - apt-get -o dir::cache::archives="$APT_CACHE_DIR" update
70 - apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y npm rsync pv jq curl openjdk-17-jre-headless
71 - end_section install_linux_packages
72
73 - start_section install_npm_packages "Installing missing Node packages"
74 - npm install -g 'git+https://gitlab.ids-mannheim.de/KorAP/korap-conllu-cmc.git'
75 - end_section install_npm_packages
76
77 - start_section install_perl_packages "Installing missing Perl packages"
78 - curl -L https://cpanmin.us | perl - App::cpanminus
79 - cpanm -n -l $PERL_LOCAL_LIB_ROOT File::ShareDir::Install https://github.com/KorAP/KorAP-XML-TEI.git
80 - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/KorAP/KorAP-XML-Krill.git
81 - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/KorAP/KorAP-XML-CoNLL-U.git
82 - end_section install_perl_packages
83
84 script:
85 - export PATH=$PERL_LOCAL_LIB_ROOT/bin:$PATH
86 - start_section building_krill "Building Krill"
87 - touch *.i5.xml *.zip *.krill.tar # ignore timestamps in make
88 - make -j $(nproc) krill
89 - ls -l target/*.krill.tar
90 - end_section building_krill
91 artifacts:
92 paths:
93 - "target/*.krill.tar"
94 - "target/*.zip"
95
96deploy:
97 stage: deploy
98 dependencies:
99 - "build-krill"
100 when: manual
101 image: rocker/verse
102 before_script:
103 - source `find .. -name section_helper.sh`
104 - start_section setup_ssh "Setting up SSH"
105 - apt-get update
106 - apt-get install -y rsync openssh-client
107 - mkdir -p ~/.ssh
108 - chmod 700 ~/.ssh
109 - eval $(ssh-agent -s)
110 - chmod 400 $SSH_PRIVATE_KEY
111 - ssh-add $SSH_PRIVATE_KEY
112 - end_section setup_ssh
113 script:
114 - start_section korapxmlu "Uploading Krill to KorAP instance dnb"
115 - if [ $(ls target/*.krill.tar | wc -l) -lt 1 ]; then echo 'error - less than 1 Krill files found'; false; fi
116 - rm -rf json && mkdir -p json
117 - for f in target/*.krill.tar; do tar -C json -xf $f; done
118 - rsync -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -avz --delete json korap@$DEPLOY_SERVER:/opt/korap/instance-dnb/
119 - end_section korapxmlu
120 - start_section korapxmlr "Indexing data & restarting KorAP instance dnb"
121 - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null korap@$DEPLOY_SERVER "cd /opt/korap/instance-dnb/ &&
122 rm -rf index && mkdir -p index &&
123 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"
124 - end_section korapxmlr
125 - echo "Deploying $VID"
126 - end_section deploy