CI: add a github workflow that also builds on MacOS

Builds collocatordb, installs the perl dependencies and runs the tests on
ubuntu-latest and macos-latest. On MacOS with the perl of homebrew, so that the
modules can be installed without sudo and without running into the system
integrity protection.

Only test.t: server-test.t guesses the pids of the server it started and kills
them, which has no business on a machine it does not own.

The .gitignore ignores everything starting with a dot, so .github needs an
exception like .gitlab-ci.yml and .dockerignore have.

Verified on Linux by running the steps of the job as they are, which is how the
missing make install was found - the tests load the module from the perl
library path, not from the build directory. The MacOS job has not run yet, that
is what it is for.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Change-Id: I9f70f080366f64053663bc4c9a36087aba2f9e4e
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..0ecf48c
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,64 @@
+name: build
+
+on:
+  push:
+  pull_request:
+  workflow_dispatch:
+
+jobs:
+  build:
+    name: ${{ matrix.os }}
+    runs-on: ${{ matrix.os }}
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest, macos-latest]
+
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Install dependencies (Linux)
+        if: runner.os == 'Linux'
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y cmake cpanminus libssl-dev librocksdb-dev libgflags-dev \
+                                  libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
+
+      # The perl of homebrew, so that modules can be installed without sudo and
+      # without running into the system integrity protection.
+      - name: Install dependencies (macOS)
+        if: runner.os == 'macOS'
+        run: |
+          brew install cmake perl cpanminus rocksdb snappy lz4 zstd gflags
+          echo "$(brew --prefix)/opt/perl/bin" >> "$GITHUB_PATH"
+
+      - 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
+
+      - name: Install perl dependencies
+        run: |
+          cpanm -n --local-lib=~/perl5 https://github.com/Akron/Mojolicious-Plugin-Localize.git
+          cpanm -n --local-lib=~/perl5 --installdeps .
+
+      # make install, because the tests load the module from the perl library
+      # path, not from the build directory. local::lib sends it to ~/perl5.
+      - name: Build
+        run: |
+          eval "$(perl -I ~/perl5/lib/perl5 -Mlocal::lib=~/perl5)"
+          perl Makefile.PL
+          make
+          make install
+
+      # Only test.t: server-test.t guesses the pids of the server it started and
+      # kills them, which has no business on a machine it does not own.
+      - name: Test
+        run: |
+          eval "$(perl -I ~/perl5/lib/perl5 -Mlocal::lib=~/perl5)"
+          prove --verbose t/test.t