| Marc Kupietz | 3d82f56 | 2024-03-16 10:19:03 +0100 | [diff] [blame] | 1 | |
| 2 | stages: |
| 3 | - test |
| 4 | - build |
| 5 | - deploy |
| 6 | |
| 7 | variables: |
| 8 | VID: $VID |
| 9 | DEBIAN_FRONTEND: noninteractive |
| 10 | APT_CACHE_DIR: apt-cache |
| 11 | |
| 12 | build-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 Kupietz | 6d53488 | 2024-03-17 16:25:26 +0100 | [diff] [blame] | 37 | build-index: |
| Marc Kupietz | 3d82f56 | 2024-03-16 10:19:03 +0100 | [diff] [blame] | 38 | image: perl:5.38 |
| Marc Kupietz | b169c27 | 2024-03-16 12:07:54 +0100 | [diff] [blame] | 39 | services: |
| 40 | - docker:dind |
| Marc Kupietz | 3d82f56 | 2024-03-16 10:19:03 +0100 | [diff] [blame] | 41 | 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 Kupietz | b169c27 | 2024-03-16 12:07:54 +0100 | [diff] [blame] | 72 | - apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y rsync pv jq curl openjdk-17-jre-headless docker.io |
| Marc Kupietz | 3d82f56 | 2024-03-16 10:19:03 +0100 | [diff] [blame] | 73 | - end_section install_linux_packages |
| 74 | |
| Marc Kupietz | b169c27 | 2024-03-16 12:07:54 +0100 | [diff] [blame] | 75 | - start_section install_tree_tagger "Installing TreeTagger" |
| Marc Kupietz | 420260d | 2024-03-17 19:14:10 +0100 | [diff] [blame] | 76 | - 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 Kupietz | b169c27 | 2024-03-16 12:07:54 +0100 | [diff] [blame] | 77 | - end_section install_tree_tagger |
| 78 | |
| Marc Kupietz | 6d53488 | 2024-03-17 16:25:26 +0100 | [diff] [blame] | 79 | - start_section install_spacy "Installing spaCy" |
| Marc Kupietz | 420260d | 2024-03-17 19:14:10 +0100 | [diff] [blame] | 80 | - docker image inspect korap/conllu2spacy:latest >/dev/null 2>&1 || curl -Ls https://corpora.ids-mannheim.de/tools/conllu2spacy.tar.xz | docker load |
| Marc Kupietz | 6d53488 | 2024-03-17 16:25:26 +0100 | [diff] [blame] | 81 | - end_section install_spacy |
| 82 | |
| Marc Kupietz | 3d82f56 | 2024-03-16 10:19:03 +0100 | [diff] [blame] | 83 | - 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 Kupietz | 61b30ed | 2024-03-18 07:22:51 +0100 | [diff] [blame^] | 86 | - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/kupietz/KorAP-XML-Krill.git |
| Marc Kupietz | 3d82f56 | 2024-03-16 10:19:03 +0100 | [diff] [blame] | 87 | - 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 Kupietz | 6d53488 | 2024-03-17 16:25:26 +0100 | [diff] [blame] | 92 | - start_section building_index "Building index" |
| Marc Kupietz | 420260d | 2024-03-17 19:14:10 +0100 | [diff] [blame] | 93 | - touch target/*.zip # ignore timestamps in make |
| 94 | - sleep 1 |
| 95 | - touch target/*.ud.zip |
| Marc Kupietz | 6d53488 | 2024-03-17 16:25:26 +0100 | [diff] [blame] | 96 | - make -j $(nproc) target/dnb.index.tar.xz |
| Marc Kupietz | 3d82f56 | 2024-03-16 10:19:03 +0100 | [diff] [blame] | 97 | - end_section building_krill |
| 98 | artifacts: |
| 99 | paths: |
| Marc Kupietz | b169c27 | 2024-03-16 12:07:54 +0100 | [diff] [blame] | 100 | - target/*.zip |
| Marc Kupietz | 6d53488 | 2024-03-17 16:25:26 +0100 | [diff] [blame] | 101 | - target/dnb.index.tar.xz |
| Marc Kupietz | 3d82f56 | 2024-03-16 10:19:03 +0100 | [diff] [blame] | 102 | |
| 103 | deploy: |
| 104 | stage: deploy |
| 105 | dependencies: |
| Marc Kupietz | 420260d | 2024-03-17 19:14:10 +0100 | [diff] [blame] | 106 | - "build-index" |
| Marc Kupietz | 3d82f56 | 2024-03-16 10:19:03 +0100 | [diff] [blame] | 107 | 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 |