1---
2name: mingw
3
4on:
5  pull_request:
6    types: [opened, synchronize]
7    paths-ignore:
8      - '**.md'
9      - '.mailmap'
10      - 'ChangeLog*'
11      - 'whatsnew*'
12      - 'LICENSE'
13  push:
14    paths-ignore:
15      - '**.md'
16      - '.mailmap'
17      - 'ChangeLog*'
18      - 'whatsnew*'
19      - 'LICENSE'
20
21jobs:
22  autotools:
23    runs-on: windows-2019
24    if: "!contains(github.event.head_commit.message, 'ci skip')"
25    strategy:
26      fail-fast: false
27      matrix:
28        EVENT_MATRIX:
29          - none
30          - disable-openssl
31          - disable-thread-support
32          - disable-debug-mode
33          - disable-malloc-replacement
34
35    steps:
36      - uses: actions/checkout@v2.0.0
37
38      - name: Cache MinGW
39        id: cache-mingw
40        uses: actions/cache@v1.1.2
41        with:
42          path: D:\a\_temp\msys
43          key: windows-mingw
44
45      - name: Cache Build
46        uses: actions/cache@v1.1.2
47        with:
48          path: build
49          key: mingw-autotools-${{ matrix.EVENT_MATRIX }}-v2
50
51      - uses: numworks/setup-msys2@v1
52        if: steps.cache-mingw.outputs.cache-hit != 'true'
53        with:
54          msystem: MINGW64
55
56      - name: Install Dependes
57        if: steps.cache-mingw.outputs.cache-hit != 'true'
58        run: |
59          msys2do pacman -S --noconfirm mingw-w64-x86_64-gcc autoconf automake libtool mingw-w64-x86_64-openssl
60
61      - name: Build And Test
62        shell: powershell
63        run: |
64          $env:EVENT_CONFIGURE_OPTIONS=""
65          if ( "${{ matrix.EVENT_MATRIX }}" -ne "none" ) {
66            $env:EVENT_CONFIGURE_OPTIONS="--${{ matrix.EVENT_MATRIX }}"
67          }
68          $env:EVENT_TESTS_PARALLEL=1
69          $env:EVENT_BUILD_PARALLEL=10
70
71          $script='
72          export PATH="/mingw64/bin:/usr/bin:/bin:/usr/local/bin:/opt/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:$PATH"
73          ./autogen.sh 2>&1 3>&1
74          [[ $? -ne 0 ]] && exit 1
75          mkdir -p build
76          cd build
77          [[ $? -ne 0 ]] && exit 1
78          LDFLAGS="-L/mingw64/lib" CFLAGS="-I/mingw64/include" ../configure $EVENT_CONFIGURE_OPTIONS 2>&1
79          [[ $? -ne 0 ]] && exit 1
80          make -j $EVENT_BUILD_PARALLEL 2>&1
81          [[ $? -ne 0 ]] && exit 1
82          make verify -j $EVENT_TESTS_PARALLEL 2>&1 '
83          D:\a\_temp\msys\msys64\usr\bin\bash.exe -c $script
84
85      - uses: actions/upload-artifact@v1
86        if: failure()
87        with:
88          name: mingw-${{ matrix.EVENT_MATRIX }}-build
89          path: build
90
91  cmake:
92    runs-on: windows-2019
93    if: "!contains(github.event.head_commit.message, 'ci skip')"
94    strategy:
95      fail-fast: false
96      matrix:
97        EVENT_MATRIX:
98          - NONE
99          - DISABLE_OPENSSL
100          - DISABLE_THREAD_SUPPORT
101          - DISABLE_DEBUG_MODE
102          - DISABLE_MM_REPLACEMENT
103
104    steps:
105      - uses: actions/checkout@v2.0.0
106
107      - name: Cache MinGW
108        id: cache-mingw-cmake
109        uses: actions/cache@v1.1.2
110        with:
111          path: D:\a\_temp\msys
112          key: windows-mingw-cmake
113
114      - name: Cache Build
115        uses: actions/cache@v1.1.2
116        with:
117          path: build
118          key: mingw-cmake-${{ matrix.EVENT_MATRIX }}-v2
119
120      - uses: numworks/setup-msys2@v1
121        if: steps.cache-mingw-cmake.outputs.cache-hit != 'true'
122        with:
123          msystem: MINGW64
124
125      - name: Install Dependes
126        if: steps.cache-mingw-cmake.outputs.cache-hit != 'true'
127        run: |
128          msys2do pacman -S --noconfirm mingw-w64-x86_64-gcc mingw-w64-x86_64-openssl
129
130      - name: Build And Test
131        shell: powershell
132        run: |
133          $EVENT_CONFIGURE_OPTIONS=""
134          if ( "${{ matrix.EVENT_MATRIX }}" -ne "NONE" ) {
135            $EVENT_CONFIGURE_OPTIONS="-DEVENT__${{ matrix.EVENT_MATRIX }}=ON"
136          }
137          $env:PATH="D:\a\_temp\msys\msys64\mingw64\bin;D:\a\_temp\msys\msys64\usr\bin;$env:PATH"
138          mkdir build -ea 0
139          cd build
140          function cmake_configure($retry)
141          {
142            $errcode=0
143            try {
144              cmake .. -G "MSYS Makefiles" $EVENT_CONFIGURE_OPTIONS -DCMAKE_C_FLAGS=-w
145              $errcode=$LastExitCode
146            }
147            catch {
148              $errcode=1
149            }
150            finally {
151              if ($errcode -ne 0) {
152                if ($retry -eq 0) {
153                  $host.SetShouldExit($LastExitCode)
154                } else {
155                  echo "Remove all entries in build directory"
156                  rm -r -fo *
157                  cmake_configure 0
158                }
159              }
160            }
161          }
162          cmake_configure 1
163          cmake --build .
164          ctest -V
165
166      - uses: actions/upload-artifact@v1
167        if: failure()
168        with:
169          name: mingw-${{ matrix.EVENT_MATRIX }}-build
170          path: build
171