ci: gh-actions: add win-mingw build
authorMichael Wallner <mike@php.net>
Sun, 20 Dec 2020 13:39:58 +0000 (14:39 +0100)
committerMichael Wallner <mike@php.net>
Sun, 20 Dec 2020 13:39:58 +0000 (14:39 +0100)
.github/workflows/cmake-build-ci.gen
.github/workflows/cmake-build-ci.yml

index a7e896cfabe9638ef9fd0081e49fd884dd16ae82..d9434506ff3b00037456a7a9dfd696f16079ebf3 100755 (executable)
@@ -26,6 +26,11 @@ const DEF = [
     "CC" => "msvc",
     "CXX" => "msvc",
   ],
+  "mingw" => [ // dummy
+    "ver" => "cur",
+    "CC" => "mingw",
+    "CXX" => "mingw",
+  ]
 ];
 const ENV = [
   "ubuntu-20.04" => [
@@ -82,15 +87,6 @@ const MAP = [
         ]
       ]
     ],
-    "windows-2019" => [
-      'env.CC_VND' => [
-        "msvc" => [
-          'env.CC_VER' => [
-            "cur" => "2019",
-          ],
-        ],
-      ],
-    ],
   ]
 ];
 
@@ -248,12 +244,13 @@ function defaults($os_vnd = DEF["os"]) {
   return "$os_ver, $cc_vnd, $cc_ver";
 }
 
-function env_override($os_vnd) {
+function env_override($os_vnd, $cc_vnd = null) {
+  isset($cc_vnd) or $cc_vnd = DEF[DEF[$os_vnd]];
 ?>
       OS_VND:   <?=$os_vnd?> #
       OS_VER:   <?=DEF[$os_vnd]?> #
-      CC_VND:   <?=DEF[DEF[$os_vnd]]?> #
-      CC_VER:   <?=DEF[DEF[DEF[$os_vnd]]]["ver"]?> #
+      CC_VND:   <?=$cc_vnd?> #
+      CC_VER:   <?=DEF[$cc_vnd]["ver"]?> #
 <?php
 }
 
@@ -369,7 +366,7 @@ jobs:
           fetch-depth: 0
 <?php steps(false); ?>
 
-  # win build
+  # win msvc build
   win-msvc:
     name: win-msvc (<?=DEF["Windows"]?>, <?=DEF[DEF["Windows"]]?>, <?=DEF[DEF[DEF["Windows"]]]["ver"]?>)
     runs-on: <?=DEF["Windows"]?> #
@@ -377,7 +374,7 @@ jobs:
       CMAKE_BUILD_TYPE: "Release"
       BISON_ROOT:       "C:/msys64/usr"
       FLEX_ROOT:        "C:/msys64/usr"
-<?php env_override("Windows")?>
+<?php env_override("Windows", "msvc")?>
     continue-on-error: true
     steps:
       - uses: actions/checkout@v2
@@ -392,6 +389,28 @@ jobs:
             openssh
 <?php steps(false);?>
 
+  # win mingw build (set PATH=%PATH%;c:\msys64\mingw64\bin)
+  win-msvc:
+    name: win-mingw (<?=DEF["Windows"]?>, mingw, <?=DEF["mingw"]["ver"]?>)
+    runs-on: <?=DEF["Windows"]?> #
+    env:
+      CMAKE_BUILD_TYPE: "Release"
+      CMAKE_GENERATOR:  "MinGW Makefiles"
+      BISON_ROOT:       "C:/msys64/usr"
+      FLEX_ROOT:        "C:/msys64/usr"
+<?php env_override("Windows", "mingw")?>
+    continue-on-error: true
+    steps:
+      - uses: actions/checkout@v2
+      - uses: msys2/setup-msys2@v2
+        with:
+          release: false
+          install: >-
+            rsync
+            openssh
+            mingw-w64-x86_64-toolchain
+<?php steps(false);?>
+
   # linux release builds
   release:
     strategy:
index fe858de0150c786bdebea149e7186dcd58cc7302..3919c7a2aeab175a74406b1cb5fb0f86f64fdd11 100644 (file)
@@ -507,7 +507,7 @@ jobs:
             --data-urlencode "level=error" \
             --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}})"
 
-  # win build
+  # win msvc build
   win-msvc:
     name: win-msvc (windows-2019, msvc, cur)
     runs-on: windows-2019 #
@@ -608,6 +608,106 @@ jobs:
             --data-urlencode "level=error" \
             --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}})"
 
+  # win mingw build (set PATH=%PATH%;c:\msys64\mingw64\bin)
+  win-msvc:
+    name: win-mingw (windows-2019, mingw, cur)
+    runs-on: windows-2019 #
+    env:
+      CMAKE_BUILD_TYPE: "Release"
+      CMAKE_GENERATOR:  "MinGW Makefiles"
+      BISON_ROOT:       "C:/msys64/usr"
+      FLEX_ROOT:        "C:/msys64/usr"
+      OS_VND:   Windows #
+      OS_VER:   windows-2019 #
+      CC_VND:   mingw #
+      CC_VER:   cur #
+    continue-on-error: true
+    steps:
+      - uses: actions/checkout@v2
+      - uses: msys2/setup-msys2@v2
+        with:
+          release: false
+          install: >-
+            rsync
+            openssh
+            mingw-w64-x86_64-toolchain
+      - name: Install dependencies (Linux)
+        if: runner.os == 'Linux'
+        run: |
+          sudo apt-get install -my \
+            libevent-dev \
+            libsasl2-dev \
+            libtbb-dev \
+            python3-sphinx \
+            ${INSTALL_MEMCACHED} \
+            ${INSTALL_CC} ${INSTALL_CXX}
+          sudo systemctl stop memcached || true
+      - name: Install dependencies (Mac)
+        if: runner.os == 'macOS'
+        run: |
+          brew install bison flex sphinx-doc ${INSTALL_MEMCACHED}
+          brew services stop memcached || true
+          echo MEMCACHED_BINARY="/usr/local/bin/memcached" >> ${GITHUB_ENV}
+      - name: Build memcached
+        if: runner.os != 'Windows'
+        run: |
+          if test -d memcached
+          then
+            cd memcached
+            ./autogen.sh
+            ./configure CFLAGS="-O2 -pipe" \
+              --prefix=${MEMCACHED_PREFIX} \
+              --enable-sasl \
+              --enable-sasl-pwdb \
+              --disable-coverage \
+              --disable-dependency-tracking \
+              --disable-docs \
+              --disable-extstore \
+              --disable-option-checking \
+              ;
+            make -j2
+            make install
+            cd ..
+            echo MEMCACHED_BINARY="${MEMCACHED_PREFIX}/bin/memcached" >> ${GITHUB_ENV}
+          fi
+      - name: Generate build tree (${{ env.CMAKE_BUILD_TYPE }})
+        run: cmake --config ${{ env.CMAKE_BUILD_TYPE }} -S . -B build
+      - name: Build all with ${{ env.CXX }} ${{ env.CXXFLAGS }}
+        run: cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} -j2
+      - name: Test
+        if: env.BUILD_TESTING == 'ON'
+        run: cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} -j2 --target test
+      - name: Install
+        if: env.BUILD_TESTING == 'ON'
+        run: cmake --install build --config ${{ env.CMAKE_BUILD_TYPE }} --prefix /tmp
+      - name: Failed tests log
+        if: ${{ env.BUILD_TESTING == 'ON' && failure() }}
+        run: cat build/Testing/Temporary/LastTest.log || true
+      - name: Package
+        env:
+          PUSH_ARTIFACTS_ID: ${{ secrets.PUSH_ARTIFACTS_ID }}
+        if: env.CC_VER == 'cur' && env.CMAKE_BUILD_TYPE == 'Release'
+        run: |
+          cmake --config ${{ env.CMAKE_BUILD_TYPE }} -S . -B build
+          cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} -j2 --target package
+          cmake -DCPACK_COMPONENT_INSTALL=ON build
+          cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} -j2 --target package
+          cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} -j2 --target push-artifacts
+      - name: Notify Gitter (success)
+        if: ${{ success() && runner.os != 'Windows'}}
+        run: |
+          REF=$(basename ${GITHUB_REF})
+          curl -sS "${{ secrets.GITTER }}" \
+            --data-urlencode "level=info" \
+            --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}})"
+      - name: Notify Gitter (failure)
+        if: ${{ failure() && runner.os != 'Windows'}}
+        run: |
+          REF=$(basename ${GITHUB_REF})
+          curl -sS "${{ secrets.GITTER }}" \
+            --data-urlencode "level=error" \
+            --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}})"
+
   # linux release builds
   release:
     strategy:
@@ -692,11 +792,6 @@ jobs:
           echo CC="clang-6.0" >> ${GITHUB_ENV}
           echo CXX="clang++-6.0" >> ${GITHUB_ENV}
           echo CXXFLAGS="-stdlib=libc++" >> ${GITHUB_ENV}
-      - name: Prepare environment (for cur msvc on windows-2019)
-        if: (env.OS_VER=='windows-2019') && (env.CC_VND=='msvc') && (env.CC_VER=='cur')
-        run: |
-          echo CC="msvc2019" >> ${GITHUB_ENV}
-          echo CXX="msvc2019" >> ${GITHUB_ENV}
       - name: Install dependencies (Linux)
         if: runner.os == 'Linux'
         run: |