From 6c4cf020f95b17178c028f81b293fd64d48c3192 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Mon, 20 Jan 2025 14:37:55 +0100 Subject: [PATCH] Make GitHub Actions compile cover compilation with MSVC on Windows --- .github/workflows/windows-build.yml | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 .github/workflows/windows-build.yml diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml new file mode 100644 index 00000000..851b2483 --- /dev/null +++ b/.github/workflows/windows-build.yml @@ -0,0 +1,116 @@ +# __ __ _ +# ___\ \/ /_ __ __ _| |_ +# / _ \\ /| '_ \ / _` | __| +# | __// \| |_) | (_| | |_ +# \___/_/\_\ .__/ \__,_|\__| +# |_| XML parser +# +# Copyright (c) 2025 Sebastian Pipping +# Licensed under the MIT license: +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to permit +# persons to whom the Software is furnished to do so, subject to the +# following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +# USE OR OTHER DEALINGS IN THE SOFTWARE. + +name: Build on Windows + +on: + pull_request: + push: + schedule: + - cron: '0 2 * * 5' # Every Friday at 2am + workflow_dispatch: + +permissions: + contents: read + +jobs: + windows_build: + name: Build on Windows (${{ matrix.runs-on }}, ${{ matrix.cmake_platform }}, ${{ matrix.expat_char_type }}) + strategy: + fail-fast: false + matrix: + include: + - runs-on: windows-2019 + cmake_build_type: Debug + cmake_generator: Visual Studio 16 2019 + cmake_platform: Win32 + expat_char_type: char + expat_dll: libexpatd.dll + - runs-on: windows-2022 + cmake_build_type: Debug + cmake_generator: Visual Studio 17 2022 + cmake_platform: x64 + expat_char_type: wchar_t + expat_dll: libexpatwd.dll + defaults: + run: + shell: bash + runs-on: "${{ matrix.runs-on }}" + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2 + + - name: Configure + env: + cmake_build_type: ${{ matrix.cmake_build_type }} + cmake_generator: ${{ matrix.cmake_generator }} + cmake_platform: ${{ matrix.cmake_platform }} + expat_char_type: ${{ matrix.expat_char_type }} + run: |- + cmake_args=( + -A "${cmake_platform}" + -G "${cmake_generator}" + -DCMAKE_BUILD_TYPE="${cmake_build_type}" + -DEXPAT_CHAR_TYPE="${expat_char_type}" + -DEXPAT_WARNINGS_AS_ERRORS=ON + -Wdev + -Wdeprecated + ) + set -x + cd expat + mkdir build + cmake -S . -B build "${cmake_args[@]}" + + - name: Build + env: + cmake_build_type: ${{ matrix.cmake_build_type }} + run: |- + msbuild_args=( + -m + -property:Configuration="${cmake_build_type}" + ) + set -x + cd expat/build + MSBuild.exe "${msbuild_args[@]}" expat.sln + + - name: Run tests + env: + cmake_build_type: ${{ matrix.cmake_build_type }} + expat_dll: ${{ matrix.expat_dll }} + run: |- + ctest_args=( + --build-config "${cmake_build_type}" + --output-on-failure + --parallel 2 + ) + set -x + cd expat/build + cp -v "${cmake_build_type}/${expat_dll}" "tests/${cmake_build_type}/" + ctest "${ctest_args[@]}"