Test building on Windows with new libxml2. #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: testing-windows | |
on: | |
push: | |
env: | |
BUILD_TYPE: Release | |
MACOSX_DEPLOYMENT_TARGET: 10.15 | |
jobs: | |
os-binaries: | |
name: ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: "Windows Server 2019 MSVC", | |
os: windows-2019, | |
libxml2_dir: '-D "LibXml2_DIR=$ENV{GITHUB_WORKSPACE}/usr/local/libxml2-2.9.10/CMake/"', | |
zlib_dir: '-D "ZLIB_DIR=$ENV{GITHUB_WORKSPACE}/usr/local/ZLIB-1.2.12/CMake/"', | |
cc: "cl", cxx: "cl", | |
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" | |
} | |
- { | |
name: "Ubuntu 20.04 GCC", | |
os: ubuntu-20.04, | |
build_type: "Release", cc: "gcc", cxx: "g++" | |
} | |
- { | |
name: "macOS 13 Clang", | |
os: macos-13, | |
cc: "clang", cxx: "clang++" | |
} | |
steps: | |
- name: Checkout libCellML | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.release.tag_name }} | |
- name: Checkout zlib | |
uses: actions/checkout@v4 | |
if: runner.os == 'Windows' | |
with: | |
repository: CMLibs-Dependencies/zlib | |
path: zlib | |
ref: v1.2.12 | |
- name: Checkout LibXml2 | |
uses: actions/checkout@v4 | |
if: runner.os == 'Windows' | |
with: | |
repository: CMLibs-Dependencies/libxml2 | |
path: libxml2 | |
ref: v2.9.10 | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v2 | |
if: runner.os == 'Windows' | |
- name: Prepare Windows environment | |
if: runner.os == 'Windows' | |
shell: cmake -P {0} | |
run: | | |
# Prepare environment script. | |
set(ACTION_DIR ${CMAKE_CURRENT_BINARY_DIR}) | |
set(WIN_PATH) | |
file(TO_CMAKE_PATH "$ENV{PATH}" ENV_PATH) | |
set(PATH_LIST "") | |
foreach(_PATH ${ENV_PATH}) | |
if (NOT "${_PATH}" MATCHES ".*Strawberry") | |
list(APPEND WIN_PATH "${_PATH}") | |
endif() | |
endforeach() | |
file(TO_NATIVE_PATH "${WIN_PATH}" WIN_PATH) | |
set(ENV{PATH} "${WIN_PATH}") | |
execute_process(COMMAND ${CMAKE_COMMAND} -S "${ACTION_DIR}/zlib" -B "${ACTION_DIR}/build-zlib" -DBUILD_SHARED_LIBS=FALSE -DCMAKE_INSTALL_PREFIX=$ENV{GITHUB_WORKSPACE}/usr/local) | |
execute_process(COMMAND ${CMAKE_COMMAND} --build "${ACTION_DIR}/build-zlib" --config Release | |
WORKING_DIRECTORY "${ACTION_DIR}/build-zlib") | |
execute_process(COMMAND ${CMAKE_COMMAND} --install "${ACTION_DIR}/build-zlib" --config Release | |
WORKING_DIRECTORY "${ACTION_DIR}/build-zlib") | |
execute_process(COMMAND ${CMAKE_COMMAND} -S "${ACTION_DIR}/libxml2" -B "${ACTION_DIR}/build-libxml2" -DCMAKE_PREFIX_PATH=$ENV{GITHUB_WORKSPACE}/usr/local -DCMAKE_INSTALL_PREFIX=$ENV{GITHUB_WORKSPACE}/usr/local -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_ICONV=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_TESTS=OFF -DLIBXML2_WITH_PROGRAMS=OFF | |
RESULT_VARIABLE _RESULT OUTPUT_VARIABLE _OUTPUT ERROR_VARIABLE _ERROR) | |
execute_process(COMMAND ${CMAKE_COMMAND} --build "${ACTION_DIR}/build-libxml2" --config Release | |
WORKING_DIRECTORY "${ACTION_DIR}/build-libxml2") | |
execute_process(COMMAND ${CMAKE_COMMAND} --install "${ACTION_DIR}/build-libxml2" --config Release | |
WORKING_DIRECTORY "${ACTION_DIR}/build-libxml2") | |
- name: Configure | |
shell: cmake -P {0} | |
run: | | |
# Configure library script | |
set(OPTIONAL_ARGUMENTS) | |
set(ENV{CC} ${{ matrix.config.cc }}) | |
set(ENV{CXX} ${{ matrix.config.cxx }}) | |
set(PYTHON_LOCATION $ENV{pythonLocation}) | |
set(ACTION_DIR ${CMAKE_CURRENT_BINARY_DIR}) | |
if (NOT "${{ runner.os }}" STREQUAL "Windows") | |
list(APPEND OPTIONAL_ARGUMENTS -D BUILD_TYPE=$ENV{BUILD_TYPE}) | |
list(APPEND OPTIONAL_ARGUMENTS -D COVERAGE=OFF) | |
list(APPEND OPTIONAL_ARGUMENTS -D CMAKE_PREFIX_PATH=$ENV{GITHUB_WORKSPACE}/usr/local) | |
endif() | |
if ("${{ matrix.config.cc }}" STREQUAL "clang") | |
list(APPEND OPTIONAL_ARGUMENTS -D LLVM_COVERAGE=OFF) | |
endif() | |
if ("${{ matrix.config.os }}" STREQUAL "ubuntu-20.04") | |
list(APPEND OPTIONAL_ARGUMENTS -D PACKAGE_ANY_LINUX=TRUE) | |
endif() | |
execute_process( | |
COMMAND ${CMAKE_COMMAND} | |
-S . | |
-B build | |
${OPTIONAL_ARGUMENTS} | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Configure failed.") | |
endif() | |
- name: Build | |
shell: cmake -P {0} | |
run: | | |
# Build library script | |
include(ProcessorCount) | |
ProcessorCount(N) | |
math(EXPR JOBS "${N} + 1") | |
if ("${{ runner.os }}" STREQUAL "Windows") | |
set(BUILD_COMMMAND msbuild libCellML.sln /t:Build /p:Configuration=$ENV{BUILD_TYPE} /m:${N}) | |
else() | |
set(BUILD_COMMMAND make -j ${JOBS}) | |
endif() | |
set(ACTION_DIR ${CMAKE_CURRENT_BINARY_DIR}) | |
execute_process( | |
COMMAND ${BUILD_COMMMAND} | |
WORKING_DIRECTORY "${ACTION_DIR}/build" | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Build failed.") | |
endif() | |
- name: Test | |
shell: cmake -P {0} | |
run: | | |
# Test library script | |
include(ProcessorCount) | |
ProcessorCount(N) | |
math(EXPR JOBS "${N} + 1") | |
set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON") | |
set(ACTION_DIR ${CMAKE_CURRENT_BINARY_DIR}) | |
execute_process( | |
COMMAND ${CMAKE_CTEST_COMMAND} -j ${JOBS} -C $ENV{BUILD_TYPE} | |
WORKING_DIRECTORY "${ACTION_DIR}/build" | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Tests failed.") | |
endif() | |
- name: Package | |
id: package | |
shell: cmake -P {0} | |
run: | | |
# Package library script | |
set(ACTION_DIR ${CMAKE_CURRENT_BINARY_DIR}) | |
execute_process( | |
COMMAND ${CMAKE_CPACK_COMMAND} -C $ENV{BUILD_TYPE} | |
WORKING_DIRECTORY "${ACTION_DIR}/build" | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Packaging failed.") | |
endif() | |
file(GLOB _DIST_FILES ${ACTION_DIR}/build/dist/*) | |
string(REPLACE ";" "\n" _DIST_FILES "${_DIST_FILES}") | |
file(APPEND $ENV{GITHUB_OUTPUT} "files<<EOF\n${_DIST_FILES}\nEOF") | |
- name: Publish libraries | |
if: needs.setup-jobs.outputs.binaries-destination == 'Publish' | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ${{ steps.package.outputs.files }} | |
tag_name: ${{ github.event.release.tag_name }} | |
- name: Upload libraries as artifacts | |
if: needs.setup-jobs.outputs.binaries-destination == 'Artifact' | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./build/dist/* | |
name: ${{ matrix.config.os }} |