typo
[awesomized/libmemcached] / .github / workflows / cmake-build-ci.gen
index 6b7a35a08da8b8ea2d1b48da296bbc7b84350a5e..310d1eda6c8a7e5f6e9b7002c809c42dea320333 100755 (executable)
@@ -16,7 +16,7 @@ const DEF = [
     "CXX"  => "g++",
   ],
   "clang" => [
-    "ver" => "",
+    "ver" => "apple",
     "CC"  => "clang",
     "CXX"  => "clang++",
   ],
@@ -29,6 +29,14 @@ const APT = [
         "CXX" => "g++-10",
       ]
     ]
+  ],
+  "ubuntu-18.04" => [
+    "clang" => [
+      "old" => [
+        "CC" => "clang-7",
+        "CXX" => "clang-7"
+      ]
+    ]
   ]
 ];
 const MAP = [
@@ -64,7 +72,7 @@ const MAP = [
           'env.CC_VER' => [
             "new"  => "-9",
             "cur"  => "-8",
-            "old"  => "-6.0"
+            "old"  => "-7"
           ]
         ]
       ]
@@ -75,7 +83,7 @@ const MAP = [
 /**
  * @var bool $splat_map false = no splat map, null = default splat map, true = full splat map
  */
-function steps($splat_map = null) {
+function steps_setenv($splat_map = null) {
   if ($splat_map !== false) {
     foreach (MAP as $os_is => $os_vers) {
       foreach ($os_vers as $os_ver => $cc_vnds_) {
@@ -107,13 +115,32 @@ function steps($splat_map = null) {
       }
     }
   }
+}
+
+function steps_getdeps() {
 ?>
-<?=PRE?> - name: Install dependencies
+<?=PRE?> - name: Install dependencies (Linux)
 <?=PRE?>   if: runner.os == 'Linux'
-<?=PRE?>   run: sudo apt-get install libevent-dev libsasl-dev ${INSTALL_MEMCACHED} ${INSTALL_CC} ${INSTALL_CXX}
-<?=PRE?> - name: Generate build tree (${CMAKE_CONFIG_TYPE})
+<?=PRE?>   run: |
+<?=PRE?>     sudo apt-get install \
+<?=PRE?>       libevent-dev \
+<?=PRE?>       libsasl2-dev \
+<?=PRE?>       ${INSTALL_MEMCACHED} \
+<?=PRE?>       ${INSTALL_CC} ${INSTALL_CXX}
+<?=PRE?>     sudo systemctl stop memcached || true
+<?=PRE?> - name: Install dependencies (Mac)
+<?=PRE?>   if: runner.os == 'macOS'
+<?=PRE?>   run: |
+<?=PRE?>     brew install bison flex ${INSTALL_MEMCACHED}
+<?=PRE?>     brew services stop memcached || true
+<?php
+}
+
+function steps_build() {
+?>
+<?=PRE?> - name: Generate build tree (${{ env.CMAKE_CONFIG_TYPE }})
 <?=PRE?>   run: cmake -S . -B build
-<?=PRE?> - name: Build all with ${CXX} ${CXXFLAGS}
+<?=PRE?> - name: Build all with ${{ env.CXX }} ${{ env.CXXFLAGS }}
 <?=PRE?>   run: make -C build -j2 all
 <?=PRE?> - name: Test
 <?=PRE?>   run: make -C build -j2 test
@@ -121,31 +148,43 @@ function steps($splat_map = null) {
 <?=PRE?>   run: make -C build -j2 install DESTDIR=.
 <?=PRE?> - name: Failed tests log
 <?=PRE?>   if: ${{ failure() }}
-<?=PRE?>   run: cat Testing/Temporary/LastTest.log
+<?=PRE?>   run: cat build/Testing/Temporary/LastTest.log || true
 <?php
 }
 
+function steps($splat_map = null) {
+  steps_setenv($splat_map);
+  steps_getdeps();
+  steps_build();
+}
+
+function defaults() {
+  $os_ver = DEF[DEF["os"]];
+  $cc_vnd = DEF[$os_ver];
+  $cc_ver = DEF[$cc_vnd]["ver"];
+  return "$os_ver, $cc_vnd, $cc_ver";
+}
 ?>
 name: cmake-build-ci
-on: 
+on:
   push:
-    paths-ignore: 
+    paths-ignore:
       - "docs/**"
-    branches-ignore: 
+    branches-ignore:
       - gh-pages
       - v1.x
   pull_request:
-    branches: 
+    branches:
       - master
       - v1.x
 env:
   # defaults
   INSTALL_MEMCACHED:  memcached
-  CMAKE_CONFIG_TYPE:  Debug
+  CMAKE_BUILD_TYPE:   Debug
   BUILD_TESTING:      "ON"
-  ENABLE_SASL:        "ON"
+  ENABLE_SASL:        "OFF"
   ENABLE_HASH_HSIEH:  "ON"
-  ENABLE_DTRACE:      "ON"
+  ENABLE_DTRACE:      "OFF"
   VERBOSE:            "ON"
   OS_VND:   <?=DEF["os"]?> #
   OS_VER:   <?=DEF[DEF["os"]]?> #
@@ -153,69 +192,90 @@ env:
   CC_VER:   <?=DEF[DEF[DEF[DEF["os"]]]]["ver"]?> #
 
 jobs:
-  # release builds
-  ci-rel:
-    strategy:
-      matrix:
-        os: [ubuntu-20.04, ubuntu-18.04]
-        compiler_vendor: [gnu, clang]
-        compiler_version: [new, cur, old]
-    runs-on: ${{ matrix.os }}
+
+  # new memcached
+  ci-new:
+    name: ci-dbg (<?=defaults()?>, memcached-1.6)
+    runs-on: <?=DEF[DEF["os"]]?> #
     env:
-      CMAKE_CONFIG_TYPE: Release
-      OS_VND: Linux
-      OS_VER: ${{ matrix.os }}
-      CC_VND: ${{ matrix.compiler_vendor }}
-      CC_VER: ${{ matrix.compiler_version }}
+      INSTALL_MEMCACHED:
+      MEMCACHED_PREFIX: /tmp
+      MEMCACHED_BINARY: /tmp/bin/memcached
+      ENABLE_SASL:      "ON"
     steps:
       - uses: actions/checkout@v2
-<?php steps(true); ?>
+      - uses: actions/checkout@v2
+        with:
+          repository: memcached/memcached
+          path: memcached
+          ref: 1.6.7
+<?php steps_setenv(); ?>
+<?php steps_getdeps(); ?>
+      - name: Build memcached
+        run: |
+          cd memcached
+          ./autogen.sh
+          ./configure CFLAGS="-O2 -pipe" \
+            --prefix=${MEMCACHED_PREFIX} \
+            --enable-sasl \
+            --enable-sasl-pwdb \
+            --disable-docs \
+            --disable-coverage \
+            --disable-dependency-tracking
+          make -j2
+          make install
+          cd ..
+<?php steps_build(); ?>
 
   # sanitizer build
   ci-san:
+    name: ci-dbg (<?=defaults()?>, sanitizers)
     runs-on: <?=DEF[DEF["os"]]?> #
     env:
       ENABLE_SANITIZERS: "address;undefined"
-    steps: 
+    steps:
       - uses: actions/checkout@v2
 <?php steps(); ?>
 
   # coverage build
   ci-cov:
+    name: ci-dbg (<?=defaults()?>, coverage)
     runs-on: <?=DEF[DEF["os"]]?> #
     env:
-      CFLAGS: --coverage
-      CXXFLAGS: --coverage
-    steps: 
+      CFLAGS: -O0 --coverage
+      CXXFLAGS: -O0 --coverage
+    steps:
       - uses: actions/checkout@v2
 <?php steps(); ?>
       - uses: codecov/codecov-action@v1.0.13
 
-  # memcached new
-  ci-new:
-    runs-on: <?=DEF[DEF["os"]]?> #
+  # mac build
+  ci-mac:
+    name: ci-dbg (<?=DEF["macOS"]?>, <?=DEF[DEF["macOS"]]?>, <?=DEF[DEF[DEF["macOS"]]]["ver"]?>)
+    runs-on: <?=DEF["macOS"]?> #
+    continue-on-error: true
     env:
-      INSTALL_MEMCACHED:
-      MEMCACHED_PREFIX: /tmp
-      MEMCACHED_BINARY: /tmp/bin/memcached
-      enable_sasl: yes
-      enable_sasl_pwdb: yes
-      enable_docs: no
-      enable_coverage: no
-      enable_dependency_tracking: no
+      MEMCACHED_BINARY: /usr/local/bin/memcached
     steps:
       - uses: actions/checkout@v2
-      - uses: actions/checkout@v2
-        with:
-          repository: memcached/memcached
-          ref: 1.6.7
-      - name: Build memcached
-        run: |
-          cd memcached
-          ./autogen.sh
-          ./configure CFLAGS="-O2 -pipe" --prefix=${MEMCACHED_PREFIX}
-          make -j2
-          make install
-          cd ..
-<?php steps(); ?>
+<?php steps(false); ?>
 
+  # release builds
+  ci-rel:
+    strategy:
+      fail-fast: false
+      matrix:
+        os_ver: [ubuntu-20.04, ubuntu-18.04]
+        cc_vnd: [gnu, clang]
+        cc_ver: [new, cur, old]
+    runs-on: ${{ matrix.os_ver }}
+    continue-on-error: ${{ matrix.cc_vnd == 'clang' }}
+    env:
+      CMAKE_BUILD_TYPE: Release
+      OS_VND: Linux
+      OS_VER: ${{ matrix.os_ver }}
+      CC_VND: ${{ matrix.cc_vnd }}
+      CC_VER: ${{ matrix.cc_ver }}
+    steps:
+      - uses: actions/checkout@v2
+<?php steps(true); ?>