blob: 3bfddc861e5b60740beddf7418b64266eaef24e2 [file] [log] [blame]
Marc Kupietz08b22ae2026-08-02 09:50:17 +02001name: build
2
3on:
4 push:
5 pull_request:
6 workflow_dispatch:
7
8jobs:
9 build:
10 name: ${{ matrix.os }}
11 runs-on: ${{ matrix.os }}
12 strategy:
13 fail-fast: false
14 matrix:
15 os: [ubuntu-latest, macos-latest]
16
17 steps:
18 - uses: actions/checkout@v4
19
20 - name: Install dependencies (Linux)
21 if: runner.os == 'Linux'
22 run: |
23 sudo apt-get update
24 sudo apt-get install -y cmake librocksdb-dev libgflags-dev libsnappy-dev \
25 zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
26
27 - name: Install dependencies (macOS)
28 if: runner.os == 'macOS'
29 run: brew install cmake rocksdb snappy lz4 zstd gflags
30
31 - name: Build and install collocatordb
32 run: |
33 EXTRA=""
34 [ "$RUNNER_OS" = "macOS" ] && EXTRA="-DCMAKE_PREFIX_PATH=$(brew --prefix)"
35 git clone --depth 1 https://korap.ids-mannheim.de/gerrit/ids-kl/collocatordb
36 cmake -S collocatordb -B collocatordb/build -DCMAKE_INSTALL_PREFIX=/usr/local $EXTRA
37 cmake --build collocatordb/build -j
38 sudo cmake --install collocatordb/build
39 if [ "$RUNNER_OS" = "Linux" ]; then sudo ldconfig; fi
40
41 # The build directory has to be build/ inside the sources, the test looks
42 # for the binary relative to it.
43 - name: Configure
44 run: |
45 EXTRA=""
46 [ "$RUNNER_OS" = "macOS" ] && EXTRA="-DCMAKE_PREFIX_PATH=$(brew --prefix)"
47 cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/usr/local $EXTRA
48
49 - name: Build
50 run: cmake --build build -j
51
52 - name: Test
53 run: ctest --test-dir build --output-on-failure
54
Marc Kupietz592fc792026-08-02 11:45:47 +020055 # The count based part of the test traps on MacOS, while it runs on Linux
56 # with rocksdb 8.9, 10.2 and 11.0. Without a backtrace there is nothing to
57 # go by, so produce one.
58 - name: Backtrace of the crash (macOS)
59 if: failure() && runner.os == 'macOS'
60 run: |
61 D=$(mktemp -d)
62 ./build/dereko2vec -train tests/data/wpd19_10000.w2vinput -output "$D/m.vecs" \
63 -type 3 -save-vocab "$D/m.vocab" -size 50 -window 5 -negative 5 \
64 -threads 4 -iter 1 -min-count 2 -binary 1 > /dev/null 2>&1
65 lldb --batch -o run -o 'bt all' -o quit -- ./build/dereko2vec \
66 -train tests/data/wpd19_10000.w2vinput -output "$D/m.rocksdb" \
67 -type 5 -read-vocab "$D/m.vocab" -threads 8 2>&1 | tail -80
68
Marc Kupietz08b22ae2026-08-02 09:50:17 +020069 # The training writes the memory mappable form of the model, which
70 # derekovecs maps. vecs2mmap does the same for models trained earlier.
71 - name: Check the memory mappable model form
72 run: |
73 ./build/dereko2vec -train tests/data/wpd19_10000.w2vinput -output /tmp/m.vecs \
74 -type 3 -size 50 -window 5 -negative 5 -threads 2 -iter 1 -min-count 5 -binary 1
75 echo "written by the training:"
76 ls -l /tmp/m.vecs.vecs /tmp/m.vecs.words
77 rm /tmp/m.vecs.vecs /tmp/m.vecs.words
78 ./build/vecs2mmap /tmp/m.vecs
79 echo "written by vecs2mmap:"
80 ls -l /tmp/m.vecs.vecs /tmp/m.vecs.words
81
82 - name: Install
83 run: |
84 sudo cmake --install build
85 dereko2vec 2>&1 | head -1
86 vecs2mmap -h | head -1