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