libevent/.github/workflows/windows.yml

154 lines
4.9 KiB
YAML
Raw Normal View History

2020-01-21 19:51:48 +08:00
---
name: windows
on:
pull_request:
types: [opened, synchronize]
paths-ignore:
- '**.md'
- '.mailmap'
- 'ChangeLog*'
- 'whatsnew*'
- 'LICENSE'
push:
paths-ignore:
- '**.md'
- '.mailmap'
- 'ChangeLog*'
- 'whatsnew*'
- 'LICENSE'
jobs:
vs2019:
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
2020-01-21 19:51:48 +08:00
strategy:
fail-fast: false
matrix:
os: [windows-2019]
EVENT_MATRIX:
- NONE
- NO_SSL
2020-01-21 19:51:48 +08:00
- 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 Build
uses: actions/cache@v2
2020-01-21 19:51:48 +08:00
with:
path: build
key: ${{ matrix.os }}-${{ matrix.EVENT_MATRIX }}-v4
2020-01-21 19:51:48 +08:00
- name: Prepare vcpkg
uses: lukka/run-vcpkg@v7
id: runvcpkg
with:
vcpkgArguments: zlib:x64-windows openssl:x64-windows mbedtls:x64-windows
vcpkgDirectory: ${{ runner.workspace }}/vcpkg/
vcpkgTriplet: x64-windows
vcpkgGitCommitId: 7bc5b8cdfaf35329c1520b2af8d368e2b1cb78e6
2020-01-21 19:51:48 +08:00
- name: Build
2020-01-21 19:51:48 +08:00
shell: powershell
run: |
$EVENT_BUILD_PARALLEL=10
if ( "${{ matrix.EVENT_MATRIX }}" -eq "LIBRARY_TYPE_STATIC" ) {
2020-05-27 15:29:42 +08:00
$EVENT_CMAKE_OPTIONS="-DEVENT__LIBRARY_TYPE=STATIC -DEVENT__MSVC_STATIC_RUNTIME=OFF"
2020-01-21 19:51:48 +08:00
}
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" ) {
2020-05-27 15:29:42 +08:00
$EVENT_CMAKE_OPTIONS="-DEVENT__LIBRARY_TYPE=STATIC -DEVENT__MSVC_STATIC_RUNTIME=OFF -DEVENT__DISABLE_TESTS=ON -DEVENT__DISABLE_SAMPLES=ON"
2020-01-21 19:51:48 +08:00
}
elseif ( "${{ matrix.EVENT_MATRIX }}" -eq "NO_SSL" ) {
$EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_OPENSSL=ON -DEVENT__DISABLE_MBEDTLS=ON"
}
2020-01-21 19:51:48 +08:00
else {
$EVENT_CMAKE_OPTIONS=""
}
2020-05-28 11:50:49 +08:00
mkdir build -ea 0
2020-01-21 19:51:48 +08:00
cd build
$CMAKE_CMD="cmake -G 'Visual Studio 16 2019' -A x64 -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake .. $EVENT_CMAKE_OPTIONS"
2020-05-28 11:50:49 +08:00
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
cmake --build . -j $EVENT_BUILD_PARALLEL -- /nologo /verbosity:minimal
2020-01-21 19:51:48 +08:00
- name: Test
shell: powershell
run: |
$EVENT_TESTS_PARALLEL=1
2020-01-21 19:51:48 +08:00
cd build
try {
2020-05-28 11:50:49 +08:00
if ("${{ matrix.EVENT_MATRIX }}" -eq "TEST_EXPORT_STATIC") {
python ../test-export/test-export.py static
} elseif ("${{ matrix.EVENT_MATRIX }}" -eq "TEST_EXPORT_SHARED") {
2020-05-28 11:50:49 +08:00
python ../test-export/test-export.py shared
} else {
2020-05-28 11:50:49 +08:00
ctest --output-on-failure -j $EVENT_TESTS_PARALLEL
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
}
} catch {
$host.SetShouldExit($LastExitCode)
2020-01-21 19:51:48 +08:00
}
- uses: actions/upload-artifact@v1
if: failure()
with:
name: ${{ matrix.os }}-${{ matrix.EVENT_MATRIX }}-build
path: build