mac build
[m6w6/libmemcached] / .github / workflows / cmake-build-ci.gen
1 #!/usr/bin/env php
2 <?php
3
4 echo "# Generated file; do not edit!\n";
5
6 const PRE = " ";
7 const DEF = [
8 "os" => "Linux",
9 "Linux" => "ubuntu-20.04",
10 "macOS" => "macos-10.15",
11 "ubuntu-20.04" => "gnu",
12 "macos-10.15" => "clang",
13 "gnu" => [
14 "ver" => "cur",
15 "CC" => "gcc",
16 "CXX" => "g++",
17 ],
18 "clang" => [
19 "ver" => "apple",
20 "CC" => "clang",
21 "CXX" => "clang++",
22 ],
23 ];
24 const APT = [
25 "ubuntu-20.04" => [
26 "gnu" => [
27 "new" => [
28 "CC" => "gcc-10",
29 "CXX" => "g++-10",
30 ]
31 ]
32 ],
33 "ubuntu-18.04" => [
34 "clang" => [
35 "old" => [
36 "CC" => "clang-7",
37 "CXX" => "clang-7"
38 ]
39 ]
40 ]
41 ];
42 const MAP = [
43 'env.OS_VER' => [
44 "ubuntu-20.04" => [
45 'env.CC_VND' => [
46 "gnu" => [
47 'env.CC_VER' => [
48 "new" => "-10",
49 "cur" => "-9",
50 "old" => "-8"
51 ]
52 ],
53 "clang" => [
54 'env.CC_VER' => [
55 "new" => "-10",
56 "cur" => "-9",
57 "old" => "-8"
58 ]
59 ]
60 ]
61 ],
62 "ubuntu-18.04" => [
63 'env.CC_VND' => [
64 "gnu" => [
65 'env.CC_VER' => [
66 "new" => "-9",
67 "cur" => "-8",
68 "old" => "-7"
69 ]
70 ],
71 "clang" => [
72 'env.CC_VER' => [
73 "new" => "-9",
74 "cur" => "-8",
75 "old" => "-7"
76 ]
77 ]
78 ]
79 ]
80 ]
81 ];
82
83 /**
84 * @var bool $splat_map false = no splat map, null = default splat map, true = full splat map
85 */
86 function steps_setenv($splat_map = null) {
87 if ($splat_map !== false) {
88 foreach (MAP as $os_is => $os_vers) {
89 foreach ($os_vers as $os_ver => $cc_vnds_) {
90 if (!$splat_map && DEF[DEF["os"]] != $os_ver) continue;
91 foreach ($cc_vnds_ as $cc_vnd_is => $cc_vnds) {
92 foreach ($cc_vnds as $cc_vnd => $cc_vers_) {
93 if (!$splat_map && DEF[DEF[DEF["os"]]] != $cc_vnd) continue;
94 foreach ($cc_vers_ as $cc_ver_is => $cc_vers) {
95 foreach ($cc_vers as $cc_ver => $ver) {
96 if (!$splat_map && DEF[DEF[DEF[DEF["os"]]]]["ver"] != $cc_ver) continue;
97 ?>
98 <?=PRE?> - name: Prepare environment (<?= "for $cc_ver $cc_vnd on $os_ver" ?>)
99 <?=PRE?> if: (<?="$os_is=='$os_ver') && ($cc_vnd_is=='$cc_vnd') && ($cc_ver_is=='$cc_ver'"?>)
100 <?=PRE?> run: |
101 <?=PRE?> echo CC=<?=DEF[$cc_vnd]["CC"] . $ver?> >> ${GITHUB_ENV}
102 <?=PRE?> echo CXX=<?=DEF[$cc_vnd]["CXX"] . $ver?> >> ${GITHUB_ENV}
103 <?php
104 if (isset(APT[$os_ver][$cc_vnd][$cc_ver])) {
105 $dep = APT[$os_ver][$cc_vnd][$cc_ver];
106 ?>
107 <?=PRE?> echo INSTALL_CC='<?=$dep["CC"]?>' >> ${GITHUB_ENV}
108 <?=PRE?> echo INSTALL_CXX='<?=$dep["CXX"]?>' >> ${GITHUB_ENV}
109 <?php
110 }
111 }
112 }
113 }
114 }
115 }
116 }
117 }
118 }
119
120 function steps_getdeps() {
121 ?>
122 <?=PRE?> - name: Install dependencies (Linux)
123 <?=PRE?> if: runner.os == 'Linux'
124 <?=PRE?> run: |
125 <?=PRE?> sudo apt-get install \
126 <?=PRE?> libevent-dev \
127 <?=PRE?> libsasl2-dev \
128 <?=PRE?> ${INSTALL_MEMCACHED} \
129 <?=PRE?> ${INSTALL_CC} ${INSTALL_CXX}
130 <?=PRE?> sudo systemctl stop memcached || true
131 <?=PRE?> - name: Install dependencies (Mac)
132 <?=PRE?> if: runner.os == 'macOS'
133 <?=PRE?> run: |
134 <?=PRE?> brew install bison flex ${INSTALL_MEMCACHED}
135 <?=PRE?> brew services stop memcached || true
136 <?php
137 }
138
139 function steps_build() {
140 ?>
141 <?=PRE?> - name: Generate build tree (${{ env.CMAKE_CONFIG_TYPE }})
142 <?=PRE?> run: cmake -S . -B build
143 <?=PRE?> - name: Build all with ${{ env.CXX }} ${{ env.CXXFLAGS }}
144 <?=PRE?> run: make -C build -j2 all
145 <?=PRE?> - name: Test
146 <?=PRE?> run: make -C build -j2 test
147 <?=PRE?> - name: Install
148 <?=PRE?> run: make -C build -j2 install DESTDIR=.
149 <?=PRE?> - name: Failed tests log
150 <?=PRE?> if: ${{ failure() }}
151 <?=PRE?> run: cat build/Testing/Temporary/LastTest.log || true
152 <?php
153 }
154
155 function steps($splat_map = null) {
156 steps_setenv($splat_map);
157 steps_getdeps();
158 steps_build();
159 }
160
161 function defaults() {
162 $os_ver = DEF[DEF["os"]];
163 $cc_vnd = DEF[$os_ver];
164 $cc_ver = DEF[$cc_vnd]["ver"];
165 return "$os_ver, $cc_vnd, $cc_ver";
166 }
167 ?>
168 name: cmake-build-ci
169 on:
170 push:
171 paths-ignore:
172 - "docs/**"
173 branches-ignore:
174 - gh-pages
175 - v1.x
176 pull_request:
177 branches:
178 - master
179 - v1.x
180 env:
181 # defaults
182 INSTALL_MEMCACHED: memcached
183 CMAKE_BUILD_TYPE: Debug
184 BUILD_TESTING: "ON"
185 ENABLE_SASL: "OFF"
186 ENABLE_HASH_HSIEH: "ON"
187 ENABLE_DTRACE: "OFF"
188 VERBOSE: "ON"
189 OS_VND: <?=DEF["os"]?> #
190 OS_VER: <?=DEF[DEF["os"]]?> #
191 CC_VND: <?=DEF[DEF[DEF["os"]]]?> #
192 CC_VER: <?=DEF[DEF[DEF[DEF["os"]]]]["ver"]?> #
193
194 jobs:
195
196 # new memcached
197 ci-new:
198 name: ci-dbg (<?=defaults()?>, memcached-1.6)
199 runs-on: <?=DEF[DEF["os"]]?> #
200 env:
201 INSTALL_MEMCACHED:
202 MEMCACHED_PREFIX: /tmp
203 MEMCACHED_BINARY: /tmp/bin/memcached
204 ENABLE_SASL: "ON"
205 steps:
206 - uses: actions/checkout@v2
207 - uses: actions/checkout@v2
208 with:
209 repository: memcached/memcached
210 path: memcached
211 ref: 1.6.7
212 <?php steps_setenv(); ?>
213 <?php steps_getdeps(); ?>
214 - name: Build memcached
215 run: |
216 cd memcached
217 ./autogen.sh
218 ./configure CFLAGS="-O2 -pipe" \
219 --prefix=${MEMCACHED_PREFIX} \
220 --enable-sasl \
221 --enable-sasl-pwdb \
222 --disable-docs \
223 --disable-coverage \
224 --disable-dependency-tracking
225 make -j2
226 make install
227 cd ..
228 <?php steps_build(); ?>
229
230 # sanitizer build
231 ci-san:
232 name: ci-dbg (<?=defaults()?>, sanitizers)
233 runs-on: <?=DEF[DEF["os"]]?> #
234 env:
235 ENABLE_SANITIZERS: "address;undefined"
236 steps:
237 - uses: actions/checkout@v2
238 <?php steps(); ?>
239
240 # coverage build
241 ci-cov:
242 name: ci-dbg (<?=defaults()?>, coverage)
243 runs-on: <?=DEF[DEF["os"]]?> #
244 env:
245 CFLAGS: -O0 --coverage
246 CXXFLAGS: -O0 --coverage
247 steps:
248 - uses: actions/checkout@v2
249 <?php steps(); ?>
250 - uses: codecov/codecov-action@v1.0.13
251
252 # mac build
253 ci-mac:
254 name: ci-dbg (<?=DEF["macOS"]?>, <?=DEF[DEF["macOS"]]?>, <?=DEF[DEF[DEF["macOS"]]]["ver"]?>)
255 runs-on: <?=DEF["macOS"]?> #
256 continue-on-error: true
257 env:
258 MEMCACHED_BINARY: /usr/local/bin/memcached
259 steps:
260 - uses actions/checkout@v2
261 <?php steps(false); ?>
262
263 # release builds
264 ci-rel:
265 strategy:
266 fail-fast: false
267 matrix:
268 os_ver: [ubuntu-20.04, ubuntu-18.04]
269 cc_vnd: [gnu, clang]
270 cc_ver: [new, cur, old]
271 runs-on: ${{ matrix.os_ver }}
272 continue-on-error: ${{ matrix.cc_vnd == 'clang' }}
273 env:
274 CMAKE_BUILD_TYPE: Release
275 OS_VND: Linux
276 OS_VER: ${{ matrix.os_ver }}
277 CC_VND: ${{ matrix.cc_vnd }}
278 CC_VER: ${{ matrix.cc_ver }}
279 steps:
280 - uses: actions/checkout@v2
281 <?php steps(true); ?>