Install everything with one script, and use it in the CI

scripts/install.sh runs the whole installation: the packages of the
distribution, rocksdb where there is none or none with the static
library, collocatordb, and dereko2vec with the fast static link, tested
and installed below /usr/local. Options: --shared, --skip-deps,
--skip-tests, --static-binary, --prefix, --rocksdb-prefix,
--rocksdb-version, -j.

The GitHub workflow (Ubuntu, MacOS) and the GitLab CI (Debian, with the
completely static binary as the artifact) now call it instead of
repeating the steps.

build-rocksdb.sh passes the homebrew prefix to cmake on MacOS, so that
the compression libraries are found.

Change-Id: Idbe7d7e598001d91aef8aaba045ac1ace61bf92a
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 3bfddc8..6f634da 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -17,44 +17,27 @@
     steps:
       - uses: actions/checkout@v4
 
-      - name: Install dependencies (Linux)
+      # Deps, collocatordb and dereko2vec, with rocksdb and collocatordb
+      # linked statically. The distribution brings the static rocksdb on both,
+      # so no rocksdb is built.
+      - name: Install everything (Linux)
         if: runner.os == 'Linux'
-        run: |
-          sudo apt-get update
-          sudo apt-get install -y cmake librocksdb-dev libgflags-dev libsnappy-dev \
-                                  zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
+        run: scripts/install.sh
 
-      - name: Install dependencies (macOS)
+      # The count based part of the test traps on MacOS, while it runs on
+      # Linux. So the tests are a step of their own there, with a backtrace
+      # below when they fail, instead of failing the installation.
+      - name: Install everything (macOS)
         if: runner.os == 'macOS'
-        run: brew install cmake rocksdb snappy lz4 zstd gflags
+        run: scripts/install.sh --skip-tests
 
-      - name: Build and install collocatordb
-        run: |
-          EXTRA=""
-          [ "$RUNNER_OS" = "macOS" ] && EXTRA="-DCMAKE_PREFIX_PATH=$(brew --prefix)"
-          git clone --depth 1 https://korap.ids-mannheim.de/gerrit/ids-kl/collocatordb
-          cmake -S collocatordb -B collocatordb/build -DCMAKE_INSTALL_PREFIX=/usr/local $EXTRA
-          cmake --build collocatordb/build -j
-          sudo cmake --install collocatordb/build
-          if [ "$RUNNER_OS" = "Linux" ]; then sudo ldconfig; fi
-
-      # The build directory has to be build/ inside the sources, the test looks
-      # for the binary relative to it.
-      - name: Configure
-        run: |
-          EXTRA=""
-          [ "$RUNNER_OS" = "macOS" ] && EXTRA="-DCMAKE_PREFIX_PATH=$(brew --prefix)"
-          cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/usr/local $EXTRA
-
-      - name: Build
-        run: cmake --build build -j
-
-      - name: Test
+      - name: Test (macOS)
+        if: runner.os == 'macOS'
         run: ctest --test-dir build --output-on-failure
 
-      # The count based part of the test traps on MacOS, while it runs on Linux
-      # with rocksdb 8.9, 10.2 and 11.0. Without a backtrace there is nothing to
-      # go by, so produce one.
+      # The count based part of the test traps on MacOS, while it runs on
+      # Linux with rocksdb 8.9, 10.2 and 11.0. Without a backtrace there is
+      # nothing to go by, so produce one.
       - name: Backtrace of the crash (macOS)
         if: failure() && runner.os == 'macOS'
         run: |
@@ -79,8 +62,8 @@
           echo "written by vecs2mmap:"
           ls -l /tmp/m.vecs.vecs /tmp/m.vecs.words
 
-      - name: Install
+      # install.sh has already installed; make sure the installed binaries run
+      - name: Smoke test of the installed binaries
         run: |
-          sudo cmake --install build
           dereko2vec 2>&1 | head -1
           vecs2mmap -h | head -1