cpack
[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 DEF = [
7 "os" => "Linux",
8 "Linux" => "ubuntu-20.04",
9 "Windows" => "windows-2019",
10 "macOS" => "macos-10.15",
11 "ubuntu-20.04" => "gnu",
12 "windows-2019" => "msvc",
13 "macos-10.15" => "clang",
14 "gnu" => [
15 "ver" => "cur",
16 "CC" => "gcc",
17 "CXX" => "g++",
18 ],
19 "clang" => [
20 "ver" => "apple",
21 "CC" => "clang",
22 "CXX" => "clang++",
23 ],
24 "msvc" => [ // dummy
25 "ver" => "cur",
26 "CC" => "msvc",
27 "CXX" => "msvc",
28 ],
29 ];
30 const ENV = [
31 "ubuntu-20.04" => [
32 "gnu" => [
33 "new" => [
34 "INSTALL_CC" => "gcc-10",
35 "INSTALL_CXX" => "g++-10",
36 ]
37 ]
38 ],
39 "ubuntu-18.04" => [
40 "clang" => [
41 "old" => [
42 "CXXFLAGS" => "-stdlib=libc++"
43 ]
44 ]
45 ]
46 ];
47 const MAP = [
48 'env.OS_VER' => [
49 "ubuntu-20.04" => [
50 'env.CC_VND' => [
51 "gnu" => [
52 'env.CC_VER' => [
53 "new" => "-10",
54 "cur" => "-9",
55 "old" => "-8"
56 ]
57 ],
58 "clang" => [
59 'env.CC_VER' => [
60 "new" => "-10",
61 "cur" => "-9",
62 "old" => "-8"
63 ]
64 ]
65 ]
66 ],
67 "ubuntu-18.04" => [
68 'env.CC_VND' => [
69 "gnu" => [
70 'env.CC_VER' => [
71 "new" => "-9",
72 "cur" => "-8",
73 "old" => "-7"
74 ]
75 ],
76 "clang" => [
77 'env.CC_VER' => [
78 "new" => "-9",
79 "cur" => "-8",
80 "old" => "-6.0"
81 ]
82 ]
83 ]
84 ],
85 "windows-2019" => [
86 'env.CC_VND' => [
87 "msvc" => [
88 'env.CC_VER' => [
89 "cur" => "2019",
90 ],
91 ],
92 ],
93 ],
94 ]
95 ];
96
97 /**
98 * @var bool $splat_map false = no splat map, null = default splat map, true = full splat map
99 */
100 function steps_setenv($splat_map = null) {
101 if ($splat_map !== false) {
102 foreach (MAP as $os_is => $os_vers) {
103 foreach ($os_vers as $os_ver => $cc_vnds_) {
104 if (!$splat_map && DEF[DEF["os"]] != $os_ver) continue;
105 foreach ($cc_vnds_ as $cc_vnd_is => $cc_vnds) {
106 foreach ($cc_vnds as $cc_vnd => $cc_vers_) {
107 if (!$splat_map && DEF[DEF[DEF["os"]]] != $cc_vnd) continue;
108 foreach ($cc_vers_ as $cc_ver_is => $cc_vers) {
109 foreach ($cc_vers as $cc_ver => $ver) {
110 if (!$splat_map && DEF[DEF[DEF[DEF["os"]]]]["ver"] != $cc_ver) continue;
111 ?>
112 - name: Prepare environment (<?= "for $cc_ver $cc_vnd on $os_ver" ?>)
113 if: (<?="$os_is=='$os_ver') && ($cc_vnd_is=='$cc_vnd') && ($cc_ver_is=='$cc_ver'"?>)
114 run: |
115 echo CC="<?=DEF[$cc_vnd]["CC"] . $ver?>" >> ${GITHUB_ENV}
116 echo CXX="<?=DEF[$cc_vnd]["CXX"] . $ver?>" >> ${GITHUB_ENV}
117 <?php
118 if (isset(ENV[$os_ver][$cc_vnd][$cc_ver])) {
119 foreach (ENV[$os_ver][$cc_vnd][$cc_ver] as $env => $val) {
120 ?>
121 echo <?=$env?>="<?=$val?>" >> ${GITHUB_ENV}
122 <?php
123 }
124 }
125 }
126 }
127 }
128 }
129 }
130 }
131 }
132 }
133
134 function steps_getdeps() {
135 ?>
136 - name: Install dependencies (Linux)
137 if: runner.os == 'Linux'
138 run: |
139 sudo apt-get install \
140 libevent-dev \
141 libsasl2-dev \
142 libtbb-dev \
143 ${INSTALL_MEMCACHED} \
144 ${INSTALL_CC} ${INSTALL_CXX}
145 sudo systemctl stop memcached || true
146 - name: Install dependencies (Mac)
147 if: runner.os == 'macOS'
148 run: |
149 brew install bison flex ${INSTALL_MEMCACHED}
150 brew services stop memcached || true
151 echo MEMCACHED_BINARY="/usr/local/bin/memcached" >> ${GITHUB_ENV}
152 - name: Build memcached
153 run: |
154 if test -d memcached
155 then
156 cd memcached
157 ./autogen.sh
158 ./configure CFLAGS="-O2 -pipe" \
159 --prefix=${MEMCACHED_PREFIX} \
160 --enable-sasl \
161 --enable-sasl-pwdb \
162 --disable-coverage \
163 --disable-dependency-tracking \
164 --disable-docs \
165 --disable-extstore \
166 --disable-option-checking \
167 ;
168 make -j2
169 make install
170 cd ..
171 echo MEMCACHED_BINARY="${MEMCACHED_PREFIX}/bin/memcached" >> ${GITHUB_ENV}
172 fi
173 <?php
174 }
175
176 function steps_build() {
177 ?>
178 - name: Generate build tree (${{ env.CMAKE_BUILD_TYPE }})
179 run: cmake -S . -B build
180 - name: Build all with ${{ env.CXX }} ${{ env.CXXFLAGS }}
181 run: make -C build -j2 all
182 - name: Test
183 run: make -C build -j2 test
184 - name: Install
185 run: make -C build -j2 install DESTDIR=/tmp
186 - name: Package
187 if: ${{ env.CMAKE_BUILD_TYPE == 'Release' && env.CC_VER == 'cur' }}
188 run: make -C build package
189 - name: Failed tests log
190 if: ${{ failure() }}
191 run: cat build/Testing/Temporary/LastTest.log || true
192 <?php
193 }
194
195 function steps_notify() {
196 ?>
197 - name: Notify Gitter (success)
198 if: ${{ success() }}
199 run: |
200 REF=$(basename ${GITHUB_REF})
201 curl -sS "${{ secrets.GITTER }}" \
202 --data-urlencode "level=info" \
203 --data-urlencode "message=Github [${GITHUB_REPOSITORY}](https://github.com/${GITHUB_REPOSITORY}/commits/${REF}) (${REF}) [success](https://github.com/m6w6/libmemcached/actions/runs/${GITHUB_RUN_ID}) (${ImageOS}/${CC:-${CC_VND}-${CC_VER}})"
204 - name: Notify Gitter (failure)
205 if: ${{ failure() }}
206 run: |
207 REF=$(basename ${GITHUB_REF})
208 curl -sS "${{ secrets.GITTER }}" \
209 --data-urlencode "level=error" \
210 --data-urlencode "message=Github [${GITHUB_REPOSITORY}](https://github.com/${GITHUB_REPOSITORY}/commits/${REF}) (${REF}) [failure](https://github.com/m6w6/libmemcached/actions/runs/${GITHUB_RUN_ID}) (${ImageOS}/${CC:-${CC_VND}-${CC_VER}})"
211 <?php
212 }
213
214 function steps($splat_map = null) {
215 steps_setenv($splat_map);
216 steps_getdeps();
217 steps_build();
218 steps_notify();
219 }
220
221 function defaults() {
222 $os_ver = DEF[DEF["os"]];
223 $cc_vnd = DEF[$os_ver];
224 $cc_ver = DEF[$cc_vnd]["ver"];
225 return "$os_ver, $cc_vnd, $cc_ver";
226 }
227 ?>
228 name: cmake-build-ci
229 on:
230 push:
231 paths:
232 - "include/**"
233 - "src/**"
234 - "test/**"
235 - "CMake*"
236 - ".github/workflows/cmake-build-ci*"
237 branches-ignore:
238 - gh-pages
239 pull_request:
240 branches:
241 - master
242 - v1.x
243 env:
244 # defaults
245 INSTALL_MEMCACHED: memcached
246 CMAKE_BUILD_TYPE: Debug
247 BUILD_TESTING: "ON"
248 ENABLE_SASL: "OFF"
249 ENABLE_HASH_HSIEH: "ON"
250 ENABLE_DTRACE: "OFF"
251 VERBOSE: "ON"
252 OS_VND: <?=DEF["os"]?> #
253 OS_VER: <?=DEF[DEF["os"]]?> #
254 CC_VND: <?=DEF[DEF[DEF["os"]]]?> #
255 CC_VER: <?=DEF[DEF[DEF[DEF["os"]]]]["ver"]?> #
256
257 jobs:
258
259 # new memcached
260 dbg-new:
261 name: dbg-new (<?=defaults()?>)
262 runs-on: <?=DEF[DEF["os"]]?> #
263 env:
264 INSTALL_MEMCACHED:
265 MEMCACHED_PREFIX: /tmp
266 ENABLE_SASL: "ON"
267 CFLAGS: "-O0 --coverage"
268 CXXFLAGS: "-O0 --coverage"
269 steps:
270 - uses: actions/checkout@v2
271 - uses: actions/checkout@v2
272 with:
273 repository: memcached/memcached
274 path: memcached
275 ref: 1.6.7
276 <?php steps(); ?>
277 - uses: codecov/codecov-action@v1.0.13
278
279 # sanitizer build
280 dbg-san:
281 name: dbg-san (<?=defaults()?>)
282 runs-on: <?=DEF[DEF["os"]]?> #
283 env:
284 ENABLE_SANITIZERS: "address;undefined"
285 steps:
286 - uses: actions/checkout@v2
287 <?php steps(); ?>
288
289 # thread sanitizer build
290 dbg-tsan:
291 name: dbg-tsan (<?=defaults()?>)
292 runs-on: <?=DEF[DEF["os"]]?> #
293 env:
294 ENABLE_SANITIZERS: "thread"
295 steps:
296 - uses: actions/checkout@v2
297 <?php steps(); ?>
298
299 # mac build
300 dbg-mac:
301 name: dbg-mac (<?=DEF["macOS"]?>, <?=DEF[DEF["macOS"]]?>, <?=DEF[DEF[DEF["macOS"]]]["ver"]?>)
302 runs-on: <?=DEF["macOS"]?> #
303 env:
304 CFLAGS: -O0 --coverage
305 CXXFLAGS: -O0 --coverage
306 OS_VND: macOS
307 OS_VER: <?=DEF["macOS"]?> #
308 CC_VND: <?=DEF[DEF["macOS"]]?> #
309 CC_VER: <?=DEF[DEF[DEF["macOS"]]]["ver"]?> #
310 continue-on-error: true
311 steps:
312 - uses: actions/checkout@v2
313 <?php steps(false); ?>
314 - uses: codecov/codecov-action@v1.0.13
315
316 # win build
317 win-msvc:
318 name: win-msvc (<?=DEF["Windows"]?>, <?=DEF[DEF["Windows"]]?>, <?=DEF[DEF[DEF["Windows"]]]["ver"]?>)
319 runs-on: <?=DEF["Windows"]?> #
320 env:
321 CMAKE_BUILD_TYPE: Release
322 BUILD_TESTING: "OFF"
323 BISON_ROOT: "C:/msys64/usr"
324 FLEX_ROOT: "C:/msys64/usr"
325 OS_VND: Windows
326 OS_VER: <?=DEF["Windows"]?> #
327 CC_VND: <?=DEF[DEF["Windows"]]?> #
328 CC_VER: <?=DEF[DEF[DEF["Windows"]]]["ver"]?> #
329 continue-on-error: true
330 steps:
331 - uses: actions/checkout@v2
332 - name: Generate build tree (${{ env.CMAKE_BUILD_TYPE }})
333 run: cmake --config ${{ env.CMAKE_BUILD_TYPE }} -S . -B build
334 - name: Build all with ${{ env.CC_VND }}
335 run: cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }}
336 - name: Install
337 run: cmake --install build --prefix installed --config ${{ env.CMAKE_BUILD_TYPE }}
338 - name: Package
339 run: cmake -E chdir build cpack
340
341 # release builds
342 release:
343 strategy:
344 fail-fast: false
345 matrix:
346 os_ver: [ubuntu-20.04, ubuntu-18.04]
347 cc_vnd: [gnu, clang]
348 cc_ver: [new, cur, old]
349 runs-on: ${{ matrix.os_ver }}
350 continue-on-error: ${{ matrix.cc_vnd == 'clang' }}
351 env:
352 CMAKE_BUILD_TYPE: Release
353 OS_VND: Linux
354 OS_VER: ${{ matrix.os_ver }}
355 CC_VND: ${{ matrix.cc_vnd }}
356 CC_VER: ${{ matrix.cc_ver }}
357 steps:
358 - uses: actions/checkout@v2
359 <?php steps(true); ?>