CI: do not let ccache break the build
The pipeline aborted with "ccache: command not found" at ccache --show-stats.
ccache only makes the build faster, so nothing may depend on it being there:
the compiler symlinks and the cmake launcher options are only set up when it is
actually installed, and printing the statistics can no longer fail the job.
The collocatordb build passed CMAKE_C_COMPILER_LAUNCHER, but collocatordb is
C++, so ccache was never used for it. It sets both launchers now.
Also drops the two `env` calls, which printed all CI variables, including
DOCKER_HUB_PASSWORD and the other secrets, into the job logs.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Change-Id: Ib650cc7d473e837c8a47ee6f0a982d4fb335728f
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fb01be6..6db6f32 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -34,8 +34,9 @@
- 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++
+ # ccache only makes the build faster, it must never be able to make it fail,
+ # so everything that uses it is guarded and CCACHE_OPTS stays empty without it
+ - 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
- end_section install_linux_packages
- start_section install_rocksdb_static "Building and installing rocksdb-static"
@@ -43,7 +44,7 @@
- cd rocksdb
- export PROCS=$(nproc)
- make -j $PROCS static_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
- - ccache --show-stats
+ - command -v ccache > /dev/null && ccache --show-stats || true
- make install-static DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
- end_section install_rocksdb_static
@@ -59,9 +60,9 @@
- cd collocatordb
- mkdir -p build
- cd build
- - cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache ..
+ - cmake $CCACHE_OPTS ..
- make
- - ccache --show-stats
+ - command -v ccache > /dev/null && ccache --show-stats || true
- make install # && ctest --extra-verbose
- ldconfig
- end_section install_collocatordb
@@ -119,7 +120,6 @@
VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
stage: build
before_script:
- - env
- apk update
- apk add --no-cache git
script:
@@ -146,7 +146,6 @@
services:
- docker:dind
script:
- - env
- unxz -c derekovecs.tar.xz | docker load
- echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin
- docker push idscorpuslinguistics/derekovecs:$VID