Skip to content

Commit

Permalink
Fix build system and unit test bugs. Improve efficiency of CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
ktchu authored May 8, 2022
2 parents 3977e5d + d8c6744 commit b088a80
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 13 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ concurrency:

jobs:
build-and-test:
name: ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
name: ${{ matrix.os }} - ${{ matrix.arch }} - GTest ${{ matrix.gtest }} - ${{ github.event_name }}

strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
arch: [x64, x86]
gtest: [system, local]

runs-on: ${{ matrix.os }}

Expand All @@ -34,25 +35,34 @@ jobs:
- name: Create Build Directory
run: cmake -E make_directory ${{github.workspace}}/build

- name: Install Packages (ubuntu)
if: runner.os == 'Linux'
- name: Install Packages (ubuntu, GoogleTest installed system-wide)
if: runner.os == 'Linux' && matrix.gtest == 'system'

run: |
sudo apt-get update -qq
sudo apt-get install -y iwyu
sudo apt-get install -y libgtest-dev
- name: Install Packages (macOS)
if: runner.os == 'macOS'
- name: Install Packages (ubuntu, GoogleTest installed locally)
if: runner.os == 'Linux' && matrix.gtest == 'local'

run: |
sudo apt-get update -qq
- name: Install Packages (macOS, GoogleTest installed system-wide)
if: runner.os == 'macOS' && matrix.gtest == 'system'

run: |
brew reinstall gcc
brew install include-what-you-use
brew install googletest
- name: Configure CMake
- name: Install Packages (macOS, GoogleTest installed locally)
if: runner.os == 'macOS'

run: |
cmake -S . -B build
brew reinstall gcc
- name: Configure CMake
run: cmake -S . -B build

- name: Build library and tests
run: cmake --build build --target tests
Expand Down
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# --- Initialization

cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.14)
project(LSMLIB
LANGUAGES C CXX Fortran
VERSION 2.0.0)
Expand Down Expand Up @@ -76,14 +76,18 @@ endif (IWYU)

find_package(GTest)
if (NOT GTest_FOUND)
message("-- Attempting to download GTest...")
message("-- Attempting to fetch GTest from GitHub...")
FetchContent_Declare(
GTest
URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(GTest)
set(GTest_LOCAL True)
set(GTEST_INCLUDE_DIRS ${gtest_SOURCE_DIR}/googletest/include/)
set(GTEST_LIBRARIES GTest::gtest)
set(GTEST_MAIN_LIBRARIES GTest::gtest_main)
endif (NOT GTest_FOUND)

# ------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Level Set Method Library (LSMLIB)

## Announcement

* (May 2022) LSMLIB v2.0.0 is intended to be a stable version of LSMLIB that can serve as
* (May 2022) LSMLIB v2.0.x is intended to be a stable version of LSMLIB that can serve as
a foundation for specialized applications and packages. The library has been refactored
and only includes support for serial computations implemented in C/C++ (the parallel
LSMLIB and Python interfaces have been moved to their own separate codebases and
Expand Down
13 changes: 13 additions & 0 deletions RELEASE-NOTES/RELEASE-NOTES-2.0.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Release Notes: LSMLIB v2.0
==========================

--------------------------------------------------------------------------------------------
v2.0.1 (2022-05-08)
===================

## Enhancements

* Improve robustness of GoogleTest integration.
* Improve coverage and efficiency of CI GitHub Actions workflow.

## Bug Fixes

* Fix header bugs in unit tests.

--------------------------------------------------------------------------------------------
v2.0.0 (2022-05-08)
===================
Expand Down
5 changes: 5 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ set_property(TARGET LSMLIB::lsm PROPERTY

function(add_test_target TEST_PROGRAM SOURCE_FILES)
add_executable(${TEST_PROGRAM} ${SOURCE_FILES})

add_dependencies(${TEST_PROGRAM} LSMLIB::lsm)
if (GTest_LOCAL)
add_dependencies(${TEST_PROGRAM} ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
endif (GTest_LOCAL)

target_include_directories(${TEST_PROGRAM} PUBLIC ${GTEST_INCLUDE_DIRS})
target_link_libraries(
${TEST_PROGRAM}
Expand Down
1 change: 1 addition & 0 deletions tests/geometry/test_find_line_in_tetrahedron.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* for all possible cases of intersection of a line with a tetrahedron.
*/

#include <algorithm> // for std::max
#include <math.h> // for fabs
#include <stdio.h> // for printf

Expand Down
2 changes: 1 addition & 1 deletion tests/toolbox/test_calculus_toolbox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <gtest/gtest-message.h> // for Message
#include <gtest/gtest-test-part.h> // for TestPartResult
#include "gtest/gtest_pred_impl.h" // for SuiteApiResolver, EXPECT_NEAR
#include <gtest/gtest_pred_impl.h> // for SuiteApiResolver, EXPECT_NEAR

#include "lsmlib_config.h"
#include "lsm_calculus_toolbox.h"
Expand Down

0 comments on commit b088a80

Please sign in to comment.