summaryrefslogtreecommitdiff
path: root/.github/workflows/windows.yml
blob: b30038a09d1ad08bdbad821894e53c17b269a1e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
---
name: windows

on:
  pull_request:
    types: [opened, synchronize]
    paths-ignore:
      - '**.md'
      - '.mailmap'
      - 'ChangeLog*'
      - 'whatsnew*'
      - 'LICENSE'
  push:
    paths-ignore:
      - '**.md'
      - '.mailmap'
      - 'ChangeLog*'
      - 'whatsnew*'
      - 'LICENSE'

jobs:
  vs2017:
    runs-on: ${{ matrix.os }}
    if: "!contains(github.event.head_commit.message, 'ci skip')"
    strategy:
      fail-fast: false
      matrix:
        os: [windows-2016]
        EVENT_MATRIX: [NONE]

    steps:
      - uses: actions/checkout@v2.0.0

      - name: Cache Depends
        id: cache-depends
        uses: actions/cache@v1.0.3
        with:
          path: C:\vcpkg\installed
          key: ${{ matrix.os }}-vcpkg

      - name: Cache Build
        uses: actions/cache@v1.0.3
        with:
          path: build
          key: ${{ matrix.os }}-${{ matrix.EVENT_MATRIX }}-v3

      - name: Install Depends
        if: steps.cache-depends.outputs.cache-hit != 'true'
        shell: powershell
        run: |
          vcpkg install openssl:x64-windows
          vcpkg install zlib:x64-windows

      - name: Build And Test
        shell: powershell
        run: |
          $OPENSSL_ROOT_DIR="C:\vcpkg\installed\x64-windows"
          $EVENT_BUILD_PARALLEL=10
          $EVENT_TESTS_PARALLEL=1
          $env:PATH="$OPENSSL_ROOT_DIR/bin;$env:PATH"

          mkdir build -ea 0
          cd build

          $CMAKE_CMD="cmake -G 'Visual Studio 15 2017 Win64' .."
          function cmake_configure($retry)
          {
            $errcode=0
            try {
              if ($retry -eq 0) {
                echo "[cmake configure retry] $CMAKE_CMD"
              } else {
                echo "[cmake configure] $CMAKE_CMD"
              }
              Invoke-Expression $CMAKE_CMD
              $errcode=$LastExitCode
            }
            catch {
              $errcode=1
            }
            finally {
              if ($errcode -ne 0) {
                if ($retry -eq 0) {
                  $host.SetShouldExit($LastExitCode)
                } else {
                  echo "Remove all entries in build directory"
                  rm -r -fo *
                  cmake_configure 0
                }
              }
            }
          }
          cmake_configure 1

          try {
            cmake --build . -j $EVENT_BUILD_PARALLEL -- /nologo /verbosity:minimal
            if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }

            if ("${{ matrix.EVENT_MATRIX }}" -eq "TEST_EXPORT_STATIC") {
              python ../test-export/test-export.py static
            }
            elseif ("${{ matrix.EVENT_MATRIX }}" -eq "TEST_EXPORT_SHARED") {
              python ../test-export/test-export.py shared
            }
            else {
              ctest --output-on-failure -j $EVENT_TESTS_PARALLEL
              if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
            }
          } catch {
            $host.SetShouldExit($LastExitCode)
          }

      - uses: actions/upload-artifact@v1
        if: failure()
        with:
          name: ${{ matrix.os }}-${{ matrix.EVENT_MATRIX }}-build
          path: build

  vs2019:
    runs-on: ${{ matrix.os }}
    if: "!contains(github.event.head_commit.message, 'ci skip')"
    strategy:
      fail-fast: false
      matrix:
        os: [windows-2019]
        EVENT_MATRIX:
          - NONE
          - LIBRARY_TYPE_STATIC
          - DISABLE_OPENSSL
          - DISABLE_THREAD_SUPPORT
          - DISABLE_DEBUG_MODE
          - DISABLE_MM_REPLACEMENT
          - DUNICODE
          - TEST_EXPORT_SHARED
          - TEST_EXPORT_STATIC

    steps:
      - uses: actions/checkout@v2.0.0

      - name: Cache Depends
        id: cache-depends
        uses: actions/cache@v1.1.0
        with:
          path: C:\vcpkg\installed
          key: ${{ matrix.os }}-vcpkg

      - name: Cache Build
        uses: actions/cache@v1.1.0
        with:
          path: build
          key: ${{ matrix.os }}-${{ matrix.EVENT_MATRIX }}-v3

      - name: Install Depends
        if: steps.cache-depends.outputs.cache-hit != 'true'
        shell: powershell
        run: |
          vcpkg install openssl:x64-windows
          vcpkg install zlib:x64-windows

      - name: Build And Test
        shell: powershell
        run: |
          $OPENSSL_ROOT_DIR="C:\vcpkg\installed\x64-windows"
          $EVENT_BUILD_PARALLEL=10
          $EVENT_TESTS_PARALLEL=1
          $env:PATH="$OPENSSL_ROOT_DIR/bin;$env:PATH"

          if ( "${{ matrix.EVENT_MATRIX }}" -eq "LIBRARY_TYPE_STATIC" ) {
            $EVENT_CMAKE_OPTIONS="-DEVENT__LIBRARY_TYPE=STATIC"
          }
          elseif ( "${{ matrix.EVENT_MATRIX }}" -eq "DISABLE_OPENSSL" ) {
            $EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_OPENSSL=ON"
          }
          elseif ( "${{ matrix.EVENT_MATRIX }}" -eq "DISABLE_THREAD_SUPPORT" ) {
            $EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_THREAD_SUPPORT=ON"
          }
          elseif ( "${{ matrix.EVENT_MATRIX }}" -eq "DISABLE_DEBUG_MODE" ) {
            $EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_DEBUG_MODE=ON"
          }
          elseif ( "${{ matrix.EVENT_MATRIX }}" -eq "DISABLE_MM_REPLACEMENT" ) {
            $EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_MM_REPLACEMENT=ON"
          }
          elseif ( "${{ matrix.EVENT_MATRIX }}" -eq "UNICODE" ) {
            $EVENT_CMAKE_OPTIONS="-DCMAKE_C_FLAGS='-DUNICODE -D_UNICODE'"
          }
          elseif ( "${{ matrix.EVENT_MATRIX }}" -eq "TEST_EXPORT_SHARED" ) {
            $EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_TESTS=ON -DEVENT__DISABLE_SAMPLES=ON"
          }
          elseif ( "${{ matrix.EVENT_MATRIX }}" -eq "TEST_EXPORT_STATIC" ) {
            $EVENT_CMAKE_OPTIONS="-DEVENT__LIBRARY_TYPE=STATIC -DEVENT__DISABLE_TESTS=ON -DEVENT__DISABLE_SAMPLES=ON"
          }
          else {
            $EVENT_CMAKE_OPTIONS=""
          }

          mkdir build -ea 0
          cd build

          if ("${{ matrix.os }}" -eq "windows-2016") {
            $CMAKE_CMD="cmake -G 'Visual Studio 15 2017 Win64' .."
          }
          else { # windows-2019
            $CMAKE_CMD="cmake -G 'Visual Studio 16 2019' -A x64 .. $EVENT_CMAKE_OPTIONS"
          }
          function cmake_configure($retry)
          {
            $errcode=0
            try {
              if ($retry -eq 0) {
                echo "[cmake configure retry] $CMAKE_CMD"
              } else {
                echo "[cmake configure] $CMAKE_CMD"
              }
              Invoke-Expression $CMAKE_CMD
              $errcode=$LastExitCode
            }
            catch {
              $errcode=1
            }
            finally {
              if ($errcode -ne 0) {
                if ($retry -eq 0) {
                  $host.SetShouldExit($LastExitCode)
                } else {
                  echo "Remove all entries in build directory"
                  rm -r -fo *
                  cmake_configure 0
                }
              }
            }
          }
          cmake_configure 1

          try {
            cmake --build . -j $EVENT_BUILD_PARALLEL -- /nologo /verbosity:minimal
            if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }

            if ("${{ matrix.EVENT_MATRIX }}" -eq "TEST_EXPORT_STATIC") {
              python ../test-export/test-export.py static
            }
            elseif ("${{ matrix.EVENT_MATRIX }}" -eq "TEST_EXPORT_SHARED") {
              python ../test-export/test-export.py shared
            }
            else {
              ctest --output-on-failure -j $EVENT_TESTS_PARALLEL
              if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
            }
          } catch {
            $host.SetShouldExit($LastExitCode)
          }

      - uses: actions/upload-artifact@v1
        if: failure()
        with:
          name: ${{ matrix.os }}-${{ matrix.EVENT_MATRIX }}-build
          path: build