blob: 137a62d3093d7aac40ea8572ae07fa5d2cc6b815 [file] [log] [blame]
Marc Kupietz5b6a51e2022-04-11 21:23:30 +02001image: metacpan/metacpan-api
2
Marc Kupietz18d78352024-02-20 20:55:54 +01003variables:
4 # Set `CCACHE_BASEDIR` and `CCACHE_DIR` to point `ccache` towards the cached
5 # path on the gitlab-runner. This enables to cache the output of `ccache`
6 # between various runs.
7 CCACHE_BASEDIR: "${CI_PROJECT_DIR}"
8 CCACHE_DIR: "${CI_PROJECT_DIR}/ccache"
9 # Set `ccache` to `content` to prevent rebuilding of the CI/CD containers to
10 # trigger a recreate of the cache. By using `content` the compiler's `mtime`
11 # is not considered as part of the hash.
12 CCACHE_COMPILERCHECK: "content"
13 # Enable caching for `apt-get`.
14 APT_CACHE_DIR: "${CI_PROJECT_DIR}/apt-cache"
15 # Export `noninteractive` frontend to prevent requesting user input.
16 DEBIAN_FRONTEND: "noninteractive"
17 PERL_LOCAL_LIB_ROOT: ./perl5
18 PERL5LIB: ./perl5/lib/perl5
19
Marc Kupietz5b6a51e2022-04-11 21:23:30 +020020build-and-test:
Marc Kupietz10ccb982024-09-12 14:15:13 +020021 rules:
22 - if: $CI_COMMIT_TAG =~ /.+/
23 variables:
24 VID: $CI_COMMIT_TAG
25 - when: manual
26 variables:
27 VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
Marc Kupietz5b6a51e2022-04-11 21:23:30 +020028 stage: build
Marc Kupietz18d78352024-02-20 20:55:54 +010029 cache:
30 # Cache is shared between branches, but has a unique cache per job.
31 key: derekovecs
32 paths:
33 # Note: directories should align with `$APT_CACHE_DIR` and `$CCACHE_DIR`.
34 - apt-cache/
35 - ccache/
36 - perl5/
Marc Kupietz5b6a51e2022-04-11 21:23:30 +020037 before_script:
38 - pwd
39 - source `find .. -name section_helper.sh`
40
41 - start_section install_linux_packages "Installing missing Linux packages"
Marc Kupietz18d78352024-02-20 20:55:54 +010042 - mkdir -pv $APT_CACHE_DIR ccache
43 - 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
44 - ln -s $(which ccache) /usr/local/sbin/gcc
45 - ln -s $(which ccache) /usr/local/sbin/g++
Marc Kupietz5b6a51e2022-04-11 21:23:30 +020046 - end_section install_linux_packages
47
48 - start_section install_rocksdb_static "Building and installing rocksdb-static"
Marc Kupietzd196a6f2024-08-05 22:18:20 +020049 - git clone https://github.com/kupietz/rocksdb.git -b 5.11.fb --single-branch
50 - cd rocksdb
Marc Kupietz3e3e3262022-04-12 23:11:45 +020051 - export PROCS=$(nproc)
Marc Kupietz5b6a51e2022-04-11 21:23:30 +020052 - make -j $PROCS static_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
Marc Kupietz18d78352024-02-20 20:55:54 +010053 - ccache --show-stats
Marc Kupietz5b6a51e2022-04-11 21:23:30 +020054 - make install-static DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
55 - end_section install_rocksdb_static
56
57 - start_section install_rocksdb_shared "Building and installing rocksdb-shared"
58 - make -j $PROCS shared_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
59 - make install-shared DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
60 - ldconfig
61 - cd ..
62 - end_section rocksdb_shared
63
64 - start_section install_collocatordb "Building and installing collocatordb"
Marc Kupietza7afe932022-05-19 09:21:03 +020065 - git clone "https://korap.ids-mannheim.de/gerrit/ids-kl/collocatordb"
Marc Kupietz5b6a51e2022-04-11 21:23:30 +020066 - cd collocatordb
67 - mkdir -p build
68 - cd build
Marc Kupietz18d78352024-02-20 20:55:54 +010069 - cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache ..
Marc Kupietz5b6a51e2022-04-11 21:23:30 +020070 - make
Marc Kupietz18d78352024-02-20 20:55:54 +010071 - ccache --show-stats
Marc Kupietz5b6a51e2022-04-11 21:23:30 +020072 - make install # && ctest --extra-verbose
73 - ldconfig
74 - end_section install_collocatordb
75 - cd ../..
76
77 script:
78 - start_section build_perl_dependencies "Installing Perl dependencies"
Marc Kupietz18d78352024-02-20 20:55:54 +010079 - cpanm -n -l $PERL_LOCAL_LIB_ROOT https://github.com/Akron/Mojolicious-Plugin-Localize.git
80 - cpanm -n -l $PERL_LOCAL_LIB_ROOT --installdeps .
Marc Kupietz5b6a51e2022-04-11 21:23:30 +020081 - end_section build_perl_dependencies
82
83 - start_section build_derekovecs-server "Building DeReKoVecs server"
84 - perl Makefile.PL
85 - make
86 - make install
87 - end_section build_derekovecs-server
88
Marc Kupietz3e3e3262022-04-12 23:11:45 +020089 - start_section run_derekovecs-server "Testing DeReKoVecs server"
90 - prove --verbose t
Marc Kupietz5b6a51e2022-04-11 21:23:30 +020091 - end_section run_derekovecs-server
92
Marc Kupietzddba9082023-11-06 06:59:14 +010093deploy:
94 rules:
95 - if: $CI_COMMIT_TAG =~ /.+/
96 variables:
97 VID: $CI_COMMIT_TAG
98 - when: manual
99 variables:
100 VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
101 stage: deploy
102 before_script:
103 - source `find .. -name section_helper.sh`
104 - start_section install_linux_packages "Installing missing Linux packages"
105 - 'command -v ssh-agent >/dev/null || apt-get install openssh-client -y'
106 - mkdir -p ~/.ssh
107 - chmod 700 ~/.ssh
108 - eval $(ssh-agent -s)
109 - chmod 400 "$SSH_PRIVATE_KEY"
110 - ssh-add "$SSH_PRIVATE_KEY"
111 - end_section install_linux_packages
112 script:
113 - echo "This is a manual job which doesn't start automatically, and the pipeline can complete without it starting."
114 - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $DEPLOY_HOST "cd /opt/korap/derekovecs && git stash && git pull && cpanm --installdeps . && cpanm . && rm -rf _Inline && sudo systemctl restart derekovecs"
Marc Kupietz10ccb982024-09-12 14:15:13 +0200115
116build-docker:
117 image: docker:latest
118 services:
119 - docker:dind
120 rules:
121 - if: $CI_COMMIT_TAG =~ /.+/
122 variables:
123 VID: $CI_COMMIT_TAG
124 - when: manual
125 variables:
126 VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
127 stage: build
128 before_script:
129 - env
130 - apk update
131 - apk add --no-cache git
132 script:
133 - ESCAPED_PWD=$(echo $CI_PROJECT_DIR | sed 's/\//\\\//g')
134 - echo $ESCAPED_PWD
135 - sed -i -e "s/RUN rm -rf example-models//" Dockerfile
136 - cat Dockerfile
137 - docker build -f Dockerfile -t idscorpuslinguistics/derekovecs:$VID-large .
138 - wget https://github.com/slimtoolkit/slim/releases/latest/download/dist_linux.tar.gz
139 - tar zxf dist_linux.tar.gz
140 - export PATH=$(pwd)/dist_linux:$PATH
141 - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock dslim/slim build --include-path /sbin --include-path /usr/local/share/perl5 --env MOJO_CONFIG=/derekovecs/example-models/example-docker.conf --http-probe=true --tag idscorpuslinguistics/derekovecs:tmp idscorpuslinguistics/derekovecs:$VID-large
142 - docker build -f Dockerfile.remove-example-data --tag idscorpuslinguistics/derekovecs:latest --tag idscorpuslinguistics/derekovecs:$VID .
143 - docker save idscorpuslinguistics/derekovecs:$VID | xz -T0 -M16G -9 > derekovecs.tar.xz
144 artifacts:
145 paths:
146 - derekovecs.tar.xz