Skip to content

Commit

Permalink
CI: Add MSVC runner that builds with root CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
mmuetzel committed Nov 3, 2023
1 parent 391392d commit 13ada8e
Showing 1 changed file with 179 additions and 0 deletions.
179 changes: 179 additions & 0 deletions .github/workflows/root-cmakelists.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,182 @@ jobs:
printf "::group::\033[0;32m==>\033[0m Executing example\n"
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo
echo "::endgroup::"
msvc:
# For available GitHub-hosted runners, see:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
runs-on: windows-latest

name: msvc (${{ matrix.openmp }} OpenMP)

defaults:
run:
# Use bash as default shell
shell: bash -el {0}

strategy:
# Allow other runners in the matrix to continue if some fail
fail-fast: false

env:
CHERE_INVOKING: 1

steps:
- name: get CPU name
shell: pwsh
run : |
Get-CIMInstance -Class Win32_Processor | Select-Object -Property Name
- name: checkout repository
uses: actions/checkout@v3

- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true

- name: cache conda packages
id: conda-cache
uses: actions/cache/restore@v3
with:
path: C:/Miniconda/envs/test
key: conda:msvc

- name: install packages with conda
if: ${{ steps.conda-cache.outputs.cache-hit != 'true' }}
run: |
echo ${{ steps.conda-cache.outputs.cache-hit }}
conda info
conda list
conda install -y -c intel mkl-devel
conda install -y -c conda-forge --override-channels ccache
- name: save conda cache
if: ${{ steps.conda-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v3
with:
path: C:/Miniconda/envs/test
key: ${{ steps.conda-cache.outputs.cache-primary-key }}

- name: install libraries from MSYS2
uses: msys2/setup-msys2@v2
with:
update: true

# Use pre-installed version to save disc space on partition with source.
release: false

install: >-
mingw-w64-ucrt-x86_64-gmp
mingw-w64-ucrt-x86_64-mpfr
msystem: UCRT64

- name: setup build environment
# get packages from MSYS2
# Copy only relevant parts to avoid picking up headers and libraries
# that are thought for MinGW only.
run: |
mkdir -p ./dependencies/{bin,lib,include}
# GMP
cp C:/msys64/ucrt64/bin/libgmp*.dll ./dependencies/bin/
cp C:/msys64/ucrt64/include/gmp.h ./dependencies/include/
cp C:/msys64/ucrt64/lib/libgmp.dll.a ./dependencies/lib/gmp.lib
# MPFR
cp C:/msys64/ucrt64/bin/libmpfr*.dll ./dependencies/bin/
cp C:/msys64/ucrt64/include/mpf2mpfr.h ./dependencies/include/
cp C:/msys64/ucrt64/include/mpfr.h ./dependencies/include/
cp C:/msys64/ucrt64/lib/libmpfr.dll.a ./dependencies/lib/mpfr.lib
# run-time dependencies
cp C:/msys64/ucrt64/bin/libgcc_s_seh*.dll ./dependencies/bin/
cp C:/msys64/ucrt64/bin/libwinpthread*.dll ./dependencies/bin/
# create environment variable for easier access
echo "CCACHE=C:/Miniconda/envs/test/Library/bin/ccache.exe" >> ${GITHUB_ENV}
- name: prepare ccache
# create key with human readable timestamp
# used in action/cache/restore and action/cache/save steps
id: ccache-prepare
shell: msys2 {0}
run: |
echo "ccachedir=$(cygpath -m $(${CCACHE} -k cache_dir))" >> $GITHUB_OUTPUT
echo "key=ccache:msvc:root:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT
- name: restore ccache
# Setup the GitHub cache used to maintain the ccache from one job to the next
uses: actions/cache/restore@v3
with:
path: ${{ steps.ccache-prepare.outputs.ccachedir }}
key: ${{ steps.ccache-prepare.outputs.key }}
# Prefer caches from the same branch. Fall back to caches from the dev branch.
restore-keys: |
ccache:msvc:root:${{ github.ref }}
ccache:msvc:root:
- name: configure ccache
# Limit the maximum size and switch on compression to avoid exceeding the total disk or cache quota.
run: |
test -d ${{ steps.ccache-prepare.outputs.ccachedir }} || mkdir -p ${{ steps.ccache-prepare.outputs.ccachedir }}
echo "max_size = 250M" > ${{ steps.ccache-prepare.outputs.ccachedir }}/ccache.conf
echo "compression = true" >> ${{ steps.ccache-prepare.outputs.ccachedir }}/ccache.conf
${CCACHE} -p
${CCACHE} -s
- name: setup MSVC toolchain
uses: ilammy/msvc-dev-cmd@v1

- name: build libraries
run: |
printf "::group:: \033[0;32m==>\033[0m Configuring\n"
mkdir -p ${GITHUB_WORKSPACE}/build && cd ${GITHUB_WORKSPACE}/build
cmake -G"Ninja Multi-Config" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX=".." \
-DCMAKE_PREFIX_PATH="C:/Miniconda/envs/test/Library;${GITHUB_WORKSPACE}/dependencies" \
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_Fortran_COMPILER_LAUNCHER="ccache" \
-DNFORTRAN=ON \
-DBLA_VENDOR="All" \
..
echo "::endgroup::"
printf "::group:: \033[0;32m==>\033[0m Building\n"
cmake --build . --config Release
echo "::endgroup::"
# FIXME: Build and run tests and demos

- name: ccache status
continue-on-error: true
run: ${CCACHE} -s

- name: save ccache
# Save the cache after we are done (successfully) building
# This helps to retain the ccache even if the subsequent steps are failing.
uses: actions/cache/save@v3
with:
path: ${{ steps.ccache-prepare.outputs.ccachedir }}
key: ${{ steps.ccache-prepare.outputs.key }}

- name: install
run: |
printf "\033[0;32m==>\033[0m Installing libraries\n"
cd ${GITHUB_WORKSPACE}/build
cmake --install .
- name: build example
run: |
cd ${GITHUB_WORKSPACE}/Example/build
printf "::group::\033[0;32m==>\033[0m Configuring example\n"
cmake \
-DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/lib/cmake;C:/Miniconda/envs/test/Library;${GITHUB_WORKSPACE}/dependencies" \
-DBLA_VENDOR="All" \
${{ matrix.openmp-cmake-flags }} \
..
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Building example\n"
cmake --build . --config Release
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Executing example\n"
PATH="${GITHUB_WORKSPACE}/bin;${GITHUB_WORKSPACE}/dependencies/bin;${PATH}" ./Release/my_demo
echo "::endgroup::"

0 comments on commit 13ada8e

Please sign in to comment.