| image: metacpan/metacpan-api |
| |
| variables: |
| # Set `CCACHE_BASEDIR` and `CCACHE_DIR` to point `ccache` towards the cached |
| # path on the gitlab-runner. This enables to cache the output of `ccache` |
| # between various runs. |
| CCACHE_BASEDIR: "${CI_PROJECT_DIR}" |
| CCACHE_DIR: "${CI_PROJECT_DIR}/ccache" |
| # Set `ccache` to `content` to prevent rebuilding of the CI/CD containers to |
| # trigger a recreate of the cache. By using `content` the compiler's `mtime` |
| # is not considered as part of the hash. |
| CCACHE_COMPILERCHECK: "content" |
| # Enable caching for `apt-get`. |
| APT_CACHE_DIR: "${CI_PROJECT_DIR}/apt-cache" |
| # Export `noninteractive` frontend to prevent requesting user input. |
| DEBIAN_FRONTEND: "noninteractive" |
| PERL_LOCAL_LIB_ROOT: ./perl5 |
| PERL5LIB: ./perl5/lib/perl5 |
| |
| build-and-test: |
| stage: build |
| cache: |
| # Cache is shared between branches, but has a unique cache per job. |
| key: derekovecs |
| paths: |
| # Note: directories should align with `$APT_CACHE_DIR` and `$CCACHE_DIR`. |
| - apt-cache/ |
| - ccache/ |
| - perl5/ |
| before_script: |
| - pwd |
| - source `find .. -name section_helper.sh` |
| |
| - start_section install_linux_packages "Installing missing Linux packages" |
| - mkdir -pv $APT_CACHE_DIR ccache |
| - 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 |
| - ln -s $(which ccache) /usr/local/sbin/gcc |
| - ln -s $(which ccache) /usr/local/sbin/g++ |
| - end_section install_linux_packages |
| |
| - start_section install_rocksdb_static "Building and installing rocksdb-static" |
| - git clone https://github.com/kupietz/rocksdb.git -b 5.11.fb --single-branch |
| - cd rocksdb |
| - export PROCS=$(nproc) |
| - make -j $PROCS static_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w |
| - ccache --show-stats |
| - make install-static DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w |
| - end_section install_rocksdb_static |
| |
| - start_section install_rocksdb_shared "Building and installing rocksdb-shared" |
| - make -j $PROCS shared_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w |
| - make install-shared DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w |
| - ldconfig |
| - cd .. |
| - end_section rocksdb_shared |
| |
| - start_section install_collocatordb "Building and installing collocatordb" |
| - git clone "https://korap.ids-mannheim.de/gerrit/ids-kl/collocatordb" |
| - cd collocatordb |
| - mkdir -p build |
| - cd build |
| - cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache .. |
| - make |
| - ccache --show-stats |
| - make install # && ctest --extra-verbose |
| - ldconfig |
| - end_section install_collocatordb |
| - cd ../.. |
| |
| script: |
| - start_section build_perl_dependencies "Installing Perl dependencies" |
| - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/Akron/Mojolicious-Plugin-Localize.git |
| - cpanm -n -l $PERL_LOCAL_LIB_ROOT --installdeps . |
| - end_section build_perl_dependencies |
| |
| - start_section build_derekovecs-server "Building DeReKoVecs server" |
| - perl Makefile.PL |
| - make |
| - make install |
| - end_section build_derekovecs-server |
| |
| - start_section run_derekovecs-server "Testing DeReKoVecs server" |
| - prove --verbose t |
| - end_section run_derekovecs-server |
| |
| deploy: |
| rules: |
| - if: $CI_COMMIT_TAG =~ /.+/ |
| variables: |
| VID: $CI_COMMIT_TAG |
| - when: manual |
| variables: |
| VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
| stage: deploy |
| before_script: |
| - source `find .. -name section_helper.sh` |
| - start_section install_linux_packages "Installing missing Linux packages" |
| - 'command -v ssh-agent >/dev/null || apt-get install openssh-client -y' |
| - mkdir -p ~/.ssh |
| - chmod 700 ~/.ssh |
| - eval $(ssh-agent -s) |
| - chmod 400 "$SSH_PRIVATE_KEY" |
| - ssh-add "$SSH_PRIVATE_KEY" |
| - end_section install_linux_packages |
| script: |
| - echo "This is a manual job which doesn't start automatically, and the pipeline can complete without it starting." |
| - 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" |