| image: gcc |
| |
| 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" |
| |
| build-and-test: |
| stage: build |
| cache: |
| # Cache is shared between branches, but has a unique cache per job. |
| key: dereko2vec |
| paths: |
| # Note: directories should align with `$APT_CACHE_DIR` and `$CCACHE_DIR`. |
| - apt-cache/ |
| - ccache/ |
| |
| 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 librocksdb-dev libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev libomp-dev |
| # ccache only makes the build faster, it must never be able to make it |
| # fail, so it is wired in through compiler symlinks only when it is there |
| - if CCACHE=$(command -v ccache); then ln -sf "$CCACHE" /usr/local/sbin/gcc && ln -sf "$CCACHE" /usr/local/sbin/g++; else echo "ccache is not available - building without it"; fi |
| - end_section install_linux_packages |
| |
| script: |
| # Debian ships the static rocksdb in librocksdb-dev, so install.sh builds |
| # no rocksdb here. --static-binary keeps the artifact a completely static |
| # binary. ccache works through the compiler symlinks set up above. |
| - start_section build_dereko2vec "Building and testing dereko2vec" |
| - scripts/install.sh --skip-deps --static-binary |
| - command -v ccache > /dev/null && ccache --show-stats || true |
| - end_section build_dereko2vec |
| |
| artifacts: |
| paths: |
| - build/dereko2vec |
| |