| 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 | |
| 37 | build-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 |
| Marc Kupietz | fa445da | 2024-03-16 10:46:22 +0100 | [diff] [blame] | 70 | - apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y rsync pv jq curl openjdk-17-jre-headless |
| Marc Kupietz | 3d82f56 | 2024-03-16 10:19:03 +0100 | [diff] [blame] | 71 | - end_section install_linux_packages |
| 72 | |
| Marc Kupietz | 3d82f56 | 2024-03-16 10:19:03 +0100 | [diff] [blame] | 73 | - start_section install_perl_packages "Installing missing Perl packages" |
| 74 | - curl -L https://cpanmin.us | perl - App::cpanminus |
| 75 | - cpanm -n -l $PERL_LOCAL_LIB_ROOT File::ShareDir::Install https://github.com/KorAP/KorAP-XML-TEI.git |
| 76 | - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/KorAP/KorAP-XML-Krill.git |
| 77 | - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/KorAP/KorAP-XML-CoNLL-U.git |
| 78 | - end_section install_perl_packages |
| 79 | |
| 80 | script: |
| 81 | - export PATH=$PERL_LOCAL_LIB_ROOT/bin:$PATH |
| 82 | - start_section building_krill "Building Krill" |
| 83 | - touch *.i5.xml *.zip *.krill.tar # ignore timestamps in make |
| 84 | - make -j $(nproc) krill |
| 85 | - ls -l target/*.krill.tar |
| 86 | - end_section building_krill |
| 87 | artifacts: |
| 88 | paths: |
| 89 | - "target/*.krill.tar" |
| 90 | - "target/*.zip" |
| 91 | |
| 92 | deploy: |
| 93 | stage: deploy |
| 94 | dependencies: |
| 95 | - "build-krill" |
| 96 | when: manual |
| 97 | image: rocker/verse |
| 98 | before_script: |
| 99 | - source `find .. -name section_helper.sh` |
| 100 | - start_section setup_ssh "Setting up SSH" |
| 101 | - apt-get update |
| 102 | - apt-get install -y rsync openssh-client |
| 103 | - mkdir -p ~/.ssh |
| 104 | - chmod 700 ~/.ssh |
| 105 | - eval $(ssh-agent -s) |
| 106 | - chmod 400 $SSH_PRIVATE_KEY |
| 107 | - ssh-add $SSH_PRIVATE_KEY |
| 108 | - end_section setup_ssh |
| 109 | script: |
| 110 | - start_section korapxmlu "Uploading Krill to KorAP instance dnb" |
| 111 | - if [ $(ls target/*.krill.tar | wc -l) -lt 1 ]; then echo 'error - less than 1 Krill files found'; false; fi |
| 112 | - rm -rf json && mkdir -p json |
| 113 | - for f in target/*.krill.tar; do tar -C json -xf $f; done |
| 114 | - rsync -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -avz --delete json korap@$DEPLOY_SERVER:/opt/korap/instance-dnb/ |
| 115 | - end_section korapxmlu |
| 116 | - start_section korapxmlr "Indexing data & restarting KorAP instance dnb" |
| 117 | - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null korap@$DEPLOY_SERVER "cd /opt/korap/instance-dnb/ && |
| 118 | rm -rf index && mkdir -p index && |
| 119 | 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" |
| 120 | - end_section korapxmlr |
| 121 | - echo "Deploying $VID" |
| 122 | - end_section deploy |