Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 1 | image: metacpan/metacpan-api |
| 2 | |
Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 3 | variables: |
| 4 | # Set `CCACHE_BASEDIR` and `CCACHE_DIR` to point `ccache` towards the cached |
| 5 | # path on the gitlab-runner. This enables to cache the output of `ccache` |
| 6 | # between various runs. |
| 7 | CCACHE_BASEDIR: "${CI_PROJECT_DIR}" |
| 8 | CCACHE_DIR: "${CI_PROJECT_DIR}/ccache" |
| 9 | # Set `ccache` to `content` to prevent rebuilding of the CI/CD containers to |
| 10 | # trigger a recreate of the cache. By using `content` the compiler's `mtime` |
| 11 | # is not considered as part of the hash. |
| 12 | CCACHE_COMPILERCHECK: "content" |
| 13 | # Enable caching for `apt-get`. |
| 14 | APT_CACHE_DIR: "${CI_PROJECT_DIR}/apt-cache" |
| 15 | # Export `noninteractive` frontend to prevent requesting user input. |
| 16 | DEBIAN_FRONTEND: "noninteractive" |
| 17 | PERL_LOCAL_LIB_ROOT: ./perl5 |
| 18 | PERL5LIB: ./perl5/lib/perl5 |
| 19 | |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 20 | build-and-test: |
Marc Kupietz | 10ccb98 | 2024-09-12 14:15:13 +0200 | [diff] [blame] | 21 | rules: |
| 22 | - if: $CI_COMMIT_TAG =~ /.+/ |
| 23 | variables: |
| 24 | VID: $CI_COMMIT_TAG |
| 25 | - when: manual |
| 26 | variables: |
| 27 | VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 28 | stage: build |
Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 29 | cache: |
| 30 | # Cache is shared between branches, but has a unique cache per job. |
| 31 | key: derekovecs |
| 32 | paths: |
| 33 | # Note: directories should align with `$APT_CACHE_DIR` and `$CCACHE_DIR`. |
| 34 | - apt-cache/ |
| 35 | - ccache/ |
| 36 | - perl5/ |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 37 | before_script: |
| 38 | - pwd |
| 39 | - source `find .. -name section_helper.sh` |
| 40 | |
| 41 | - start_section install_linux_packages "Installing missing Linux packages" |
Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 42 | - mkdir -pv $APT_CACHE_DIR ccache |
| 43 | - apt-get update && apt-get -o dir::cache::archives="$APT_CACHE_DIR" -y install ccache cmake libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev libomp-dev |
| 44 | - ln -s $(which ccache) /usr/local/sbin/gcc |
| 45 | - ln -s $(which ccache) /usr/local/sbin/g++ |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 46 | - end_section install_linux_packages |
| 47 | |
| 48 | - start_section install_rocksdb_static "Building and installing rocksdb-static" |
Marc Kupietz | d196a6f | 2024-08-05 22:18:20 +0200 | [diff] [blame] | 49 | - git clone https://github.com/kupietz/rocksdb.git -b 5.11.fb --single-branch |
| 50 | - cd rocksdb |
Marc Kupietz | 3e3e326 | 2022-04-12 23:11:45 +0200 | [diff] [blame] | 51 | - export PROCS=$(nproc) |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 52 | - make -j $PROCS static_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w |
Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 53 | - ccache --show-stats |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 54 | - make install-static DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w |
| 55 | - end_section install_rocksdb_static |
| 56 | |
| 57 | - start_section install_rocksdb_shared "Building and installing rocksdb-shared" |
| 58 | - make -j $PROCS shared_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w |
| 59 | - make install-shared DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w |
| 60 | - ldconfig |
| 61 | - cd .. |
| 62 | - end_section rocksdb_shared |
| 63 | |
| 64 | - start_section install_collocatordb "Building and installing collocatordb" |
Marc Kupietz | a7afe93 | 2022-05-19 09:21:03 +0200 | [diff] [blame] | 65 | - git clone "https://korap.ids-mannheim.de/gerrit/ids-kl/collocatordb" |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 66 | - cd collocatordb |
| 67 | - mkdir -p build |
| 68 | - cd build |
Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 69 | - cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache .. |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 70 | - make |
Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 71 | - ccache --show-stats |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 72 | - make install # && ctest --extra-verbose |
| 73 | - ldconfig |
| 74 | - end_section install_collocatordb |
| 75 | - cd ../.. |
| 76 | |
| 77 | script: |
| 78 | - start_section build_perl_dependencies "Installing Perl dependencies" |
Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 79 | - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/Akron/Mojolicious-Plugin-Localize.git |
| 80 | - cpanm -n -l $PERL_LOCAL_LIB_ROOT --installdeps . |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 81 | - end_section build_perl_dependencies |
| 82 | |
| 83 | - start_section build_derekovecs-server "Building DeReKoVecs server" |
| 84 | - perl Makefile.PL |
| 85 | - make |
| 86 | - make install |
| 87 | - end_section build_derekovecs-server |
| 88 | |
Marc Kupietz | 3e3e326 | 2022-04-12 23:11:45 +0200 | [diff] [blame] | 89 | - start_section run_derekovecs-server "Testing DeReKoVecs server" |
| 90 | - prove --verbose t |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 91 | - end_section run_derekovecs-server |
| 92 | |
Marc Kupietz | ddba908 | 2023-11-06 06:59:14 +0100 | [diff] [blame] | 93 | deploy: |
| 94 | rules: |
| 95 | - if: $CI_COMMIT_TAG =~ /.+/ |
| 96 | variables: |
| 97 | VID: $CI_COMMIT_TAG |
| 98 | - when: manual |
| 99 | variables: |
| 100 | VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
| 101 | stage: deploy |
| 102 | before_script: |
| 103 | - source `find .. -name section_helper.sh` |
| 104 | - start_section install_linux_packages "Installing missing Linux packages" |
| 105 | - 'command -v ssh-agent >/dev/null || apt-get install openssh-client -y' |
| 106 | - mkdir -p ~/.ssh |
| 107 | - chmod 700 ~/.ssh |
| 108 | - eval $(ssh-agent -s) |
| 109 | - chmod 400 "$SSH_PRIVATE_KEY" |
| 110 | - ssh-add "$SSH_PRIVATE_KEY" |
| 111 | - end_section install_linux_packages |
| 112 | script: |
| 113 | - echo "This is a manual job which doesn't start automatically, and the pipeline can complete without it starting." |
| 114 | - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $DEPLOY_HOST "cd /opt/korap/derekovecs && git stash && git pull && cpanm --installdeps . && cpanm . && rm -rf _Inline && sudo systemctl restart derekovecs" |
Marc Kupietz | 10ccb98 | 2024-09-12 14:15:13 +0200 | [diff] [blame] | 115 | |
| 116 | build-docker: |
| 117 | image: docker:latest |
| 118 | services: |
| 119 | - docker:dind |
| 120 | rules: |
| 121 | - if: $CI_COMMIT_TAG =~ /.+/ |
| 122 | variables: |
| 123 | VID: $CI_COMMIT_TAG |
| 124 | - when: manual |
| 125 | variables: |
| 126 | VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
| 127 | stage: build |
| 128 | before_script: |
| 129 | - env |
| 130 | - apk update |
| 131 | - apk add --no-cache git |
| 132 | script: |
| 133 | - ESCAPED_PWD=$(echo $CI_PROJECT_DIR | sed 's/\//\\\//g') |
| 134 | - echo $ESCAPED_PWD |
| 135 | - sed -i -e "s/RUN rm -rf example-models//" Dockerfile |
| 136 | - cat Dockerfile |
| 137 | - docker build -f Dockerfile -t idscorpuslinguistics/derekovecs:$VID-large . |
| 138 | - wget https://github.com/slimtoolkit/slim/releases/latest/download/dist_linux.tar.gz |
| 139 | - tar zxf dist_linux.tar.gz |
| 140 | - export PATH=$(pwd)/dist_linux:$PATH |
| 141 | - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock dslim/slim build --include-path /sbin --include-path /usr/local/share/perl5 --env MOJO_CONFIG=/derekovecs/example-models/example-docker.conf --http-probe=true --tag idscorpuslinguistics/derekovecs:tmp idscorpuslinguistics/derekovecs:$VID-large |
| 142 | - docker build -f Dockerfile.remove-example-data --tag idscorpuslinguistics/derekovecs:latest --tag idscorpuslinguistics/derekovecs:$VID . |
| 143 | - docker save idscorpuslinguistics/derekovecs:$VID | xz -T0 -M16G -9 > derekovecs.tar.xz |
| 144 | artifacts: |
| 145 | paths: |
| 146 | - derekovecs.tar.xz |