Skip to content

Commit

Permalink
Merge pull request #63 from luau-project/fix-cmake-eol-on-tests
Browse files Browse the repository at this point in the history
fix: EOL problems running CMake tests on Windows
  • Loading branch information
devernay authored Jun 30, 2024
2 parents 969e38a + eb10724 commit b061f86
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 149 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/msys2-cminpack-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: MSYS2 - Install cminpack on Windows through CMake
run-name: MSYS2 - Build, test and install cminpack on Windows through CMake
on: [push, pull_request]

jobs:
cminpack-MSYS2:
name: cminpack (MSYS2 toolchains + CMake)
runs-on: windows-latest

defaults:
run:
shell: cmd

strategy:
matrix:
CMINPACK_BUILD_SHARED_LIBS: [ 'ON' , 'OFF' ]
CMINPACK_BUILD_TYPE: [ 'Release', 'Debug', 'RelWithDebInfo', 'MinSizeRel' ]
CMINPACK_PRECISION: [ 'd' ] # seems to be the only precision that the current tests reference work
MSYS2_CONFIG:
- { sys: mingw64, env: x86_64 }
- { sys: ucrt64, env: ucrt-x86_64 }
- { sys: clang64, env: clang-x86_64 }

env:
CMINPACK_BUILD_DIR: >-
%RUNNER_TEMP%\cminpack-build-shared-libs-${{ matrix.CMINPACK_BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMINPACK_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }}
CMINPACK_INSTALL_DIR: >-
%RUNNER_TEMP%\cminpack-install-shared-libs-${{ matrix.CMINPACK_BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMINPACK_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }}
MSYS2_PACKAGES_TO_INSTALL: "mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-cc mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-make"

steps:
- name: Checkout repository to cminpack directory
uses: actions/checkout@v4
with:
path: cminpack

# Installing tools from MSYS2 could fail
# on a high number of concurrent jobs.
# So, we keep retrying it for a few times
- name: Install C compiler + GNU Make from MSYS2
shell: pwsh
run: |
$install_succeeded = $false;
$max_tries = 10;
$tries = 0;
while ((-not $install_succeeded) -and ($tries -lt $max_tries))
{
try
{
& C:\msys64\usr\bin\bash.exe -lc "pacman -S ${{ env.MSYS2_PACKAGES_TO_INSTALL }} --noconfirm"
$install_succeeded = $true;
}
catch
{
$tries++;
}
}
if (-not $install_succeeded)
{
Write-Host "Failed to install MSYS2 packages: ${{ env.MSYS2_PACKAGES_TO_INSTALL }}";
exit 1;
}
- name: Place MSYS2 tools in front of system environment PATH variable
run: echo C:\msys64\${{ matrix.MSYS2_CONFIG.sys }}\bin;%PATH% >> %GITHUB_PATH%

- name: Configure cminpack build
run: cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=${{ matrix.CMINPACK_BUILD_SHARED_LIBS }} -DCMAKE_BUILD_TYPE=${{ matrix.CMINPACK_BUILD_TYPE }} -DCMINPACK_PRECISION=${{ matrix.CMINPACK_PRECISION }} -DUSE_BLAS=OFF --install-prefix ${{ env.CMINPACK_INSTALL_DIR }} -S cminpack -B ${{ env.CMINPACK_BUILD_DIR }}

- name: Build cminpack
run: cmake --build ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMINPACK_BUILD_TYPE }}

- name: Test cminpack
run: ctest --test-dir ${{ env.CMINPACK_BUILD_DIR }} --build-config ${{ matrix.CMINPACK_BUILD_TYPE }}

- name: Install cminpack
run: cmake --install ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMINPACK_BUILD_TYPE }}

- name: Delete checkout directory
run: rmdir /S /Q cminpack

- name: Delete build directory
run: rmdir /S /Q ${{ env.CMINPACK_BUILD_DIR }}

- name: Delete install directory
run: rmdir /S /Q ${{ env.CMINPACK_INSTALL_DIR }}
14 changes: 14 additions & 0 deletions .github/workflows/ubuntu-cminpack-install.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Install cminpack on Ubuntu through CMake
run-name: Build, test and install cminpack on Ubuntu through CMake
on: [push, pull_request]

jobs:
cminpack-ubuntu:
name: cminpack (GCC toolchain + CMake)
runs-on: ubuntu-latest

strategy:
matrix:
BUILD_SHARED_LIBS: [ 'ON' , 'OFF' ]
Expand All @@ -15,32 +18,43 @@ jobs:
CMAKE_BUILD_TYPE: 'RelWithDebInfo'
CMINPACK_PRECISION: 'd'
USE_BLAS: 'ON'

env:
CMINPACK_BUILD_DIR: $RUNNER_TEMP/cminpack-build-shared-libs-${{ matrix.BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMAKE_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }}
CMINPACK_INSTALL_DIR: $RUNNER_TEMP/cminpack-install-shared-libs-${{ matrix.BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMAKE_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }}

steps:
- name: Install BLAS
run: sudo apt-get install -y libopenblas-dev
if: ${{ matrix.USE_BLAS == 'ON' }}

- name: Checkout repository to cminpack directory
uses: actions/checkout@v4
with:
path: cminpack

- name: Configure cminpack build
run: cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=${{ matrix.BUILD_SHARED_LIBS }} -DCMAKE_BUILD_TYPE=${{ matrix.CMAKE_BUILD_TYPE }} -DCMINPACK_PRECISION=${{ matrix.CMINPACK_PRECISION }} -DUSE_BLAS=${{ matrix.USE_BLAS }} --install-prefix ${{ env.CMINPACK_INSTALL_DIR }} -S cminpack -B ${{ env.CMINPACK_BUILD_DIR }}

- name: Build cminpack
run: cmake --build ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMAKE_BUILD_TYPE }}

- name: Test cminpack
run: ctest --test-dir ${{ env.CMINPACK_BUILD_DIR }} --build-config ${{ matrix.CMAKE_BUILD_TYPE }}
if: ${{ matrix.USE_BLAS == 'OFF' }}

- name: Test cminpack with BLAS
run: ctest --test-dir ${{ env.CMINPACK_BUILD_DIR }} --build-config ${{ matrix.CMAKE_BUILD_TYPE }} --exclude-regex tlmdifc
if: ${{ matrix.USE_BLAS == 'ON' }}

- name: Install cminpack
run: cmake --install ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMAKE_BUILD_TYPE }}

- name: Delete checkout directory
run: rm -rf $RUNNER_TEMP/cminpack

- name: Delete build directory
run: rm -rf ${{ env.CMINPACK_BUILD_DIR }}

- name: Delete install directory
run: rm -rf ${{ env.CMINPACK_INSTALL_DIR }}
15 changes: 13 additions & 2 deletions .github/workflows/windows-visual-studio-cminpack-install.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,52 @@
name: MSVC - Install cminpack on Windows through CMake
run-name: MSVC - Build, test and install cminpack on Windows through CMake
on: [push, pull_request]

jobs:
cminpack-visual-studio:
name: cminpack (MSVC toolchain + CMake)
runs-on: windows-latest

defaults:
run:
shell: cmd

strategy:
matrix:
ARCH: [ 'x64', 'Win32']
CMINPACK_BUILD_SHARED_LIBS: [ 'ON' , 'OFF' ]
CMINPACK_BUILD_TYPE: [ 'Release', 'Debug', 'RelWithDebInfo', 'MinSizeRel' ]
CMINPACK_PRECISION: [ 'd' ] # seems to be the only precision that the current tests reference work

env:
CMINPACK_BUILD_DIR: >-
%RUNNER_TEMP%\cminpack-build-arch-${{ matrix.ARCH }}-shared-libs-${{ matrix.CMINPACK_BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMINPACK_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }}
CMINPACK_INSTALL_DIR: >-
%RUNNER_TEMP%\cminpack-install-arch-${{ matrix.ARCH }}-shared-libs-${{ matrix.CMINPACK_BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMINPACK_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }}
steps:
- name: Checkout sources with CRLF EOLs for reference test files
run: git config --global core.autocrlf true
- name: Checkout repository to cminpack directory
uses: actions/checkout@v4
with:
path: cminpack

- name: Configure cminpack build
run: cmake -DBUILD_SHARED_LIBS=${{ matrix.CMINPACK_BUILD_SHARED_LIBS }} -DCMAKE_BUILD_TYPE=${{ matrix.CMINPACK_BUILD_TYPE }} -DCMINPACK_PRECISION=${{ matrix.CMINPACK_PRECISION }} -DUSE_BLAS=OFF -A ${{ matrix.ARCH }} --install-prefix ${{ env.CMINPACK_INSTALL_DIR }} -S cminpack -B ${{ env.CMINPACK_BUILD_DIR }}

- name: Build cminpack
run: cmake --build ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMINPACK_BUILD_TYPE }}

- name: Test cminpack
run: ctest --test-dir ${{ env.CMINPACK_BUILD_DIR }} --build-config ${{ matrix.CMINPACK_BUILD_TYPE }}

- name: Install cminpack
run: cmake --install ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMINPACK_BUILD_TYPE }}

- name: Delete checkout directory
run: rmdir /S /Q cminpack

- name: Delete build directory
run: rmdir /S /Q ${{ env.CMINPACK_BUILD_DIR }}

- name: Delete install directory
run: rmdir /S /Q ${{ env.CMINPACK_INSTALL_DIR }}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The name of our project is "CMINPACK". CMakeLists files in this project can
# refer to the root source directory of the project as ${CMINPACK_SOURCE_DIR} and
# to the root binary directory of the project as ${CMINPACK_BINARY_DIR}.
cmake_minimum_required (VERSION 3.5)
cmake_minimum_required (VERSION 3.14)

if (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
Expand Down
Loading

0 comments on commit b061f86

Please sign in to comment.