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: |
| 21 | stage: build |
Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 22 | cache: |
| 23 | # Cache is shared between branches, but has a unique cache per job. |
| 24 | key: derekovecs |
| 25 | paths: |
| 26 | # Note: directories should align with `$APT_CACHE_DIR` and `$CCACHE_DIR`. |
| 27 | - apt-cache/ |
| 28 | - ccache/ |
| 29 | - perl5/ |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 30 | before_script: |
| 31 | - pwd |
| 32 | - source `find .. -name section_helper.sh` |
| 33 | |
| 34 | - start_section install_linux_packages "Installing missing Linux packages" |
Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 35 | - mkdir -pv $APT_CACHE_DIR ccache |
| 36 | - 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 |
| 37 | - ln -s $(which ccache) /usr/local/sbin/gcc |
| 38 | - ln -s $(which ccache) /usr/local/sbin/g++ |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 39 | - end_section install_linux_packages |
| 40 | |
| 41 | - start_section install_rocksdb_static "Building and installing rocksdb-static" |
Marc Kupietz | d196a6f | 2024-08-05 22:18:20 +0200 | [diff] [blame] | 42 | - git clone https://github.com/kupietz/rocksdb.git -b 5.11.fb --single-branch |
| 43 | - cd rocksdb |
Marc Kupietz | 3e3e326 | 2022-04-12 23:11:45 +0200 | [diff] [blame] | 44 | - export PROCS=$(nproc) |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 45 | - 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] | 46 | - ccache --show-stats |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 47 | - make install-static DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w |
| 48 | - end_section install_rocksdb_static |
| 49 | |
| 50 | - start_section install_rocksdb_shared "Building and installing rocksdb-shared" |
| 51 | - make -j $PROCS shared_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w |
| 52 | - make install-shared DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w |
| 53 | - ldconfig |
| 54 | - cd .. |
| 55 | - end_section rocksdb_shared |
| 56 | |
| 57 | - start_section install_collocatordb "Building and installing collocatordb" |
Marc Kupietz | a7afe93 | 2022-05-19 09:21:03 +0200 | [diff] [blame] | 58 | - git clone "https://korap.ids-mannheim.de/gerrit/ids-kl/collocatordb" |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 59 | - cd collocatordb |
| 60 | - mkdir -p build |
| 61 | - cd build |
Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 62 | - cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache .. |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 63 | - make |
Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 64 | - ccache --show-stats |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 65 | - make install # && ctest --extra-verbose |
| 66 | - ldconfig |
| 67 | - end_section install_collocatordb |
| 68 | - cd ../.. |
| 69 | |
| 70 | script: |
| 71 | - start_section build_perl_dependencies "Installing Perl dependencies" |
Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 72 | - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/Akron/Mojolicious-Plugin-Localize.git |
| 73 | - cpanm -n -l $PERL_LOCAL_LIB_ROOT --installdeps . |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 74 | - end_section build_perl_dependencies |
| 75 | |
| 76 | - start_section build_derekovecs-server "Building DeReKoVecs server" |
| 77 | - perl Makefile.PL |
| 78 | - make |
| 79 | - make install |
| 80 | - end_section build_derekovecs-server |
| 81 | |
Marc Kupietz | 3e3e326 | 2022-04-12 23:11:45 +0200 | [diff] [blame] | 82 | - start_section run_derekovecs-server "Testing DeReKoVecs server" |
| 83 | - prove --verbose t |
Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 84 | - end_section run_derekovecs-server |
| 85 | |
Marc Kupietz | ddba908 | 2023-11-06 06:59:14 +0100 | [diff] [blame] | 86 | deploy: |
| 87 | rules: |
| 88 | - if: $CI_COMMIT_TAG =~ /.+/ |
| 89 | variables: |
| 90 | VID: $CI_COMMIT_TAG |
| 91 | - when: manual |
| 92 | variables: |
| 93 | VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
| 94 | stage: deploy |
| 95 | before_script: |
| 96 | - source `find .. -name section_helper.sh` |
| 97 | - start_section install_linux_packages "Installing missing Linux packages" |
| 98 | - 'command -v ssh-agent >/dev/null || apt-get install openssh-client -y' |
| 99 | - mkdir -p ~/.ssh |
| 100 | - chmod 700 ~/.ssh |
| 101 | - eval $(ssh-agent -s) |
| 102 | - chmod 400 "$SSH_PRIVATE_KEY" |
| 103 | - ssh-add "$SSH_PRIVATE_KEY" |
| 104 | - end_section install_linux_packages |
| 105 | script: |
| 106 | - echo "This is a manual job which doesn't start automatically, and the pipeline can complete without it starting." |
| 107 | - 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] | 108 | |
| 109 | build-docker: |
| 110 | image: docker:latest |
| 111 | services: |
| 112 | - docker:dind |
| 113 | rules: |
| 114 | - if: $CI_COMMIT_TAG =~ /.+/ |
| 115 | variables: |
| 116 | VID: $CI_COMMIT_TAG |
| 117 | - when: manual |
| 118 | variables: |
| 119 | VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
| 120 | stage: build |
| 121 | before_script: |
| 122 | - env |
| 123 | - apk update |
| 124 | - apk add --no-cache git |
| 125 | script: |
Marc Kupietz | 10ccb98 | 2024-09-12 14:15:13 +0200 | [diff] [blame] | 126 | - sed -i -e "s/RUN rm -rf example-models//" Dockerfile |
Marc Kupietz | 10ccb98 | 2024-09-12 14:15:13 +0200 | [diff] [blame] | 127 | - docker build -f Dockerfile -t idscorpuslinguistics/derekovecs:$VID-large . |
| 128 | - wget https://github.com/slimtoolkit/slim/releases/latest/download/dist_linux.tar.gz |
| 129 | - tar zxf dist_linux.tar.gz |
| 130 | - export PATH=$(pwd)/dist_linux:$PATH |
Marc Kupietz | e82c7a0 | 2024-09-13 14:49:26 +0200 | [diff] [blame] | 131 | - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock dslim/slim --in-container build --http-probe-start-wait 10 --include-workdir --include-path /usr/local --env MOJO_CONFIG=/derekovecs/example-models/example-docker.conf --tag idscorpuslinguistics/derekovecs:tmp idscorpuslinguistics/derekovecs:$VID-large |
Marc Kupietz | 10ccb98 | 2024-09-12 14:15:13 +0200 | [diff] [blame] | 132 | - docker build -f Dockerfile.remove-example-data --tag idscorpuslinguistics/derekovecs:latest --tag idscorpuslinguistics/derekovecs:$VID . |
| 133 | - docker save idscorpuslinguistics/derekovecs:$VID | xz -T0 -M16G -9 > derekovecs.tar.xz |
| 134 | artifacts: |
| 135 | paths: |
| 136 | - derekovecs.tar.xz |
Marc Kupietz | a9923bd | 2024-09-13 14:49:45 +0200 | [diff] [blame] | 137 | |
| 138 | upload-docker: |
| 139 | only: |
| 140 | - master |
| 141 | - tags |
| 142 | variables: |
| 143 | VID: $CI_COMMIT_TAG |
| 144 | stage: deploy |
| 145 | image: docker:latest |
| 146 | services: |
| 147 | - docker:dind |
| 148 | script: |
| 149 | - env |
| 150 | - unxz -c derekovecs.tar.xz | docker load |
| 151 | - echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin |
| 152 | - docker push idscorpuslinguistics/derekovecs:$VID |
Marc Kupietz | 46b3528 | 2024-09-13 19:24:52 +0200 | [diff] [blame] | 153 | - docker push idscorpuslinguistics/derekovecs |
Marc Kupietz | a9923bd | 2024-09-13 14:49:45 +0200 | [diff] [blame] | 154 | dependencies: |
| 155 | - build-docker |
| 156 | environment: |
| 157 | name: production |