| 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 |
| Marc Kupietz | 96972c6 | 2026-07-31 09:50:14 +0900 | [diff] [blame] | 36 | - apt-get update && apt-get -o dir::cache::archives="$APT_CACHE_DIR" -y install ccache cmake librocksdb-dev libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev libomp-dev |
| Marc Kupietz | 25ab170 | 2026-07-30 16:19:57 +0900 | [diff] [blame] | 37 | # ccache only makes the build faster, it must never be able to make it fail, |
| 38 | # so everything that uses it is guarded and CCACHE_OPTS stays empty without it |
| 39 | - if CCACHE=$(command -v ccache); then ln -sf "$CCACHE" /usr/local/sbin/gcc && ln -sf "$CCACHE" /usr/local/sbin/g++ && CCACHE_OPTS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"; else echo "ccache is not available - building without it"; CCACHE_OPTS=""; fi |
| Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 40 | - end_section install_linux_packages |
| 41 | |
| Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 42 | - start_section install_collocatordb "Building and installing collocatordb" |
| Marc Kupietz | a7afe93 | 2022-05-19 09:21:03 +0200 | [diff] [blame] | 43 | - git clone "https://korap.ids-mannheim.de/gerrit/ids-kl/collocatordb" |
| Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 44 | - cd collocatordb |
| 45 | - mkdir -p build |
| 46 | - cd build |
| Marc Kupietz | 25ab170 | 2026-07-30 16:19:57 +0900 | [diff] [blame] | 47 | - cmake $CCACHE_OPTS .. |
| Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 48 | - make |
| Marc Kupietz | 25ab170 | 2026-07-30 16:19:57 +0900 | [diff] [blame] | 49 | - command -v ccache > /dev/null && ccache --show-stats || true |
| Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 50 | - make install # && ctest --extra-verbose |
| 51 | - ldconfig |
| 52 | - end_section install_collocatordb |
| 53 | - cd ../.. |
| 54 | |
| 55 | script: |
| 56 | - start_section build_perl_dependencies "Installing Perl dependencies" |
| Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 57 | - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/Akron/Mojolicious-Plugin-Localize.git |
| Marc Kupietz | e20daf1 | 2026-07-31 09:55:55 +0900 | [diff] [blame] | 58 | # Devel::CheckLib, which Makefile.PL needs to find libcollocatordb before it |
| 59 | # can tell anybody about the dependencies, comes bundled in inc/ |
| Marc Kupietz | 18d7835 | 2024-02-20 20:55:54 +0100 | [diff] [blame] | 60 | - cpanm -n -l $PERL_LOCAL_LIB_ROOT --installdeps . |
| Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 61 | - end_section build_perl_dependencies |
| 62 | |
| 63 | - start_section build_derekovecs-server "Building DeReKoVecs server" |
| 64 | - perl Makefile.PL |
| 65 | - make |
| 66 | - make install |
| 67 | - end_section build_derekovecs-server |
| 68 | |
| Marc Kupietz | 3e3e326 | 2022-04-12 23:11:45 +0200 | [diff] [blame] | 69 | - start_section run_derekovecs-server "Testing DeReKoVecs server" |
| 70 | - prove --verbose t |
| Marc Kupietz | 5b6a51e | 2022-04-11 21:23:30 +0200 | [diff] [blame] | 71 | - end_section run_derekovecs-server |
| 72 | |
| Marc Kupietz | ddba908 | 2023-11-06 06:59:14 +0100 | [diff] [blame] | 73 | deploy: |
| 74 | rules: |
| 75 | - if: $CI_COMMIT_TAG =~ /.+/ |
| 76 | variables: |
| 77 | VID: $CI_COMMIT_TAG |
| 78 | - when: manual |
| 79 | variables: |
| 80 | VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
| 81 | stage: deploy |
| 82 | before_script: |
| 83 | - source `find .. -name section_helper.sh` |
| 84 | - start_section install_linux_packages "Installing missing Linux packages" |
| 85 | - 'command -v ssh-agent >/dev/null || apt-get install openssh-client -y' |
| 86 | - mkdir -p ~/.ssh |
| 87 | - chmod 700 ~/.ssh |
| 88 | - eval $(ssh-agent -s) |
| 89 | - chmod 400 "$SSH_PRIVATE_KEY" |
| 90 | - ssh-add "$SSH_PRIVATE_KEY" |
| 91 | - end_section install_linux_packages |
| 92 | script: |
| 93 | - echo "This is a manual job which doesn't start automatically, and the pipeline can complete without it starting." |
| 94 | - 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] | 95 | |
| 96 | build-docker: |
| 97 | image: docker:latest |
| Marc Kupietz | 211fff4 | 2026-07-31 10:31:10 +0900 | [diff] [blame] | 98 | variables: |
| 99 | # the mint container has to reach the container it probes |
| 100 | FF_NETWORK_PER_BUILD: "true" |
| Marc Kupietz | 10ccb98 | 2024-09-12 14:15:13 +0200 | [diff] [blame] | 101 | services: |
| Marc Kupietz | 211fff4 | 2026-07-31 10:31:10 +0900 | [diff] [blame] | 102 | - name: docker:dind |
| 103 | command: [--dns=127.0.0.11] |
| Marc Kupietz | 10ccb98 | 2024-09-12 14:15:13 +0200 | [diff] [blame] | 104 | rules: |
| 105 | - if: $CI_COMMIT_TAG =~ /.+/ |
| 106 | variables: |
| 107 | VID: $CI_COMMIT_TAG |
| 108 | - when: manual |
| 109 | variables: |
| 110 | VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
| 111 | stage: build |
| 112 | before_script: |
| Marc Kupietz | 10ccb98 | 2024-09-12 14:15:13 +0200 | [diff] [blame] | 113 | - apk update |
| 114 | - apk add --no-cache git |
| 115 | script: |
| Marc Kupietz | 211fff4 | 2026-07-31 10:31:10 +0900 | [diff] [blame] | 116 | # the http probe needs a model to serve, so keep the example models in the |
| 117 | # large image and remove them further down with Dockerfile.remove-example-data |
| Marc Kupietz | 10ccb98 | 2024-09-12 14:15:13 +0200 | [diff] [blame] | 118 | - sed -i -e "s/RUN rm -rf example-models//" Dockerfile |
| Marc Kupietz | 10ccb98 | 2024-09-12 14:15:13 +0200 | [diff] [blame] | 119 | - docker build -f Dockerfile -t idscorpuslinguistics/derekovecs:$VID-large . |
| Marc Kupietz | 211fff4 | 2026-07-31 10:31:10 +0900 | [diff] [blame] | 120 | - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock mintoolkit/mint --crt-api-version 1.46 build --http-probe=true --http-probe-start-wait 60 --include-workdir=true --include-path=/usr/local --env MOJO_CONFIG=/derekovecs/example-models/example-docker.conf --tag idscorpuslinguistics/derekovecs:tmp idscorpuslinguistics/derekovecs:$VID-large || true |
| Marc Kupietz | 10ccb98 | 2024-09-12 14:15:13 +0200 | [diff] [blame] | 121 | - docker build -f Dockerfile.remove-example-data --tag idscorpuslinguistics/derekovecs:latest --tag idscorpuslinguistics/derekovecs:$VID . |
| Marc Kupietz | 211fff4 | 2026-07-31 10:31:10 +0900 | [diff] [blame] | 122 | - ARTIFACT=derekovecs-${VID}.tar.xz |
| 123 | - docker save idscorpuslinguistics/derekovecs:$VID | xz -T0 -M16G -9 > "$ARTIFACT" |
| Marc Kupietz | 10ccb98 | 2024-09-12 14:15:13 +0200 | [diff] [blame] | 124 | artifacts: |
| 125 | paths: |
| Marc Kupietz | 211fff4 | 2026-07-31 10:31:10 +0900 | [diff] [blame] | 126 | - derekovecs-*.tar.xz |
| Marc Kupietz | a9923bd | 2024-09-13 14:49:45 +0200 | [diff] [blame] | 127 | |
| 128 | upload-docker: |
| Marc Kupietz | a9923bd | 2024-09-13 14:49:45 +0200 | [diff] [blame] | 129 | stage: deploy |
| 130 | image: docker:latest |
| 131 | services: |
| Marc Kupietz | 211fff4 | 2026-07-31 10:31:10 +0900 | [diff] [blame] | 132 | - name: docker:dind |
| 133 | command: [--dns=127.0.0.11] |
| 134 | needs: |
| 135 | - job: build-docker |
| 136 | artifacts: true |
| Marc Kupietz | a9923bd | 2024-09-13 14:49:45 +0200 | [diff] [blame] | 137 | dependencies: |
| 138 | - build-docker |
| Marc Kupietz | 211fff4 | 2026-07-31 10:31:10 +0900 | [diff] [blame] | 139 | rules: |
| 140 | - if: $CI_COMMIT_TAG =~ /^v.+/ |
| 141 | when: manual |
| 142 | - when: never |
| 143 | script: |
| 144 | - apk update |
| 145 | - apk add --no-cache xz |
| 146 | - ARTIFACT=derekovecs-${CI_COMMIT_TAG}.tar.xz |
| 147 | - xz -d -c "$ARTIFACT" | docker load |
| 148 | - echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin |
| 149 | - docker tag idscorpuslinguistics/derekovecs:$CI_COMMIT_TAG idscorpuslinguistics/derekovecs:latest |
| 150 | - docker push idscorpuslinguistics/derekovecs:$CI_COMMIT_TAG |
| 151 | - docker push idscorpuslinguistics/derekovecs:latest |
| Marc Kupietz | a9923bd | 2024-09-13 14:49:45 +0200 | [diff] [blame] | 152 | environment: |
| 153 | name: production |