Skip to content

Commit

Permalink
Merge main.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Ahrenkiel authored and Phil Ahrenkiel committed Dec 29, 2023
2 parents 190c546 + 1d941d3 commit 3a2fa9b
Show file tree
Hide file tree
Showing 28 changed files with 1,615 additions and 577 deletions.
6 changes: 6 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage:
precision: 2
round: nearest
range: "0...100"
ignore:
- "vendor/**/*"
49 changes: 0 additions & 49 deletions .github/workflows/CI_with_Cmake.yml

This file was deleted.

98 changes: 98 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Build and Test

on: push

jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu
os_ver: "22.04"
config: Release
coverage: false
cc: gcc-11
cxx: g++-11
experimental: false
- os: ubuntu
os_ver: "20.04"
config: Release
coverage: false
cc: gcc-10
cxx: g++-10
experimental: false
- os: windows
os_ver: "2022"
config: Release
coverage: false
cc: cl
cxx: cl
experimental: false
- os: macos
os_ver: "12"
config: Release
coverage: false
cc: clang
cxx: clang++
experimental: false
- os: macos
os_ver: "11"
config: Release
coverage: false
cc: clang
cxx: clang++
experimental: true
- os: ubuntu
os_ver: "20.04"
config: Debug
coverage: true
cc: gcc-10
cxx: g++-10
experimental: false
defaults:
run:
shell: bash
name: ${{ matrix.os }}-${{ matrix.os_ver }} ${{ matrix.cxx }} ${{ matrix.config }} coverage=${{ matrix.coverage }}
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
runs-on: ${{ matrix.os }}-${{ matrix.os_ver }}
continue-on-error: ${{ matrix.experimental }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set Project Name
run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
- name: Create Build Directory
run: cmake -E make_directory ${{github.workspace}}/build
- name: Set coverage variables
id: cov
run: |
if ${{matrix.coverage}}; then
echo "COVERAGE=ON" >> $GITHUB_OUTPUT
echo "STATIC_LIB=OFF" >> $GITHUB_OUTPUT
else
echo "COVERAGE=OFF" >> $GITHUB_OUTPUT
echo "STATIC_LIB=ON" >> $GITHUB_OUTPUT
fi
- name: Configure CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE="${{ matrix.config }}" -D${{ env.REPOSITORY_NAME }}_BUILD_TESTING="ON" -D${{ env.REPOSITORY_NAME }}_STATIC_LIB="${{ steps.cov.outputs.STATIC_LIB }}" -D${{ env.REPOSITORY_NAME }}_COVERAGE="${{ steps.cov.outputs.COVERAGE }}"
- name: Build
run: cmake --build build --config ${{ matrix.config }}
- name: Test
run: ctest -C ${{ matrix.config }} --output-on-failure
working-directory: build
- name: Code Coverage Analysis
if: "matrix.coverage"
run: make gcov
working-directory: build
- name: Upload Code Coverage Report
if: "matrix.coverage"
uses: codecov/codecov-action@v3
with:
flags: integration
functionalities: "gcov"
move_coverage_to_trash: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*.o
*.x
*.png
.idea
.vscode
.Rproj.user
*TestToolOutput.csv
!Documentation/**
Expand Down
66 changes: 42 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,53 @@
project(HPWHsim)
cmake_policy(SET CMP0091 NEW)
project(HPWHsim LANGUAGES CXX)
cmake_minimum_required(VERSION 3.7)
cmake_policy(SET CMP0079 NEW) # target_link_libraries() allows use with targets in other directories.

cmake_minimum_required(VERSION 3.5)
# Set a default build type if none was specified
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif ()

enable_testing()
find_package(Git QUIET)

set (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wshadow")
elseif(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
include(CMakeDependentOption)

find_package(Git QUIET)
cmake_dependent_option(${PROJECT_NAME}_BUILD_TESTING "Build ${PROJECT_NAME} testing targets" ON "${PROJECT_NAME}_IS_TOP_LEVEL" OFF)
option(${PROJECT_NAME}_COVERAGE "Add ${PROJECT_NAME} coverage reports" OFF)
#cmake_dependent_option(${PROJECT_NAME}_BUILD_EXAMPLES "Build ${PROJECT_NAME} examples" ON "${PROJECT_NAME}_IS_TOP_LEVEL" OFF)
cmake_dependent_option(${PROJECT_NAME}_WARNINGS_AS_ERRORS "Treat warnings in ${PROJECT_NAME} as errors" ON "${PROJECT_NAME}_IS_TOP_LEVEL" OFF)

if (NOT ${PROJECT_NAME}_STATIC_LIB)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif ()

include(compiler-flags)

# Set up testing/coverage
if (${PROJECT_NAME}_BUILD_TESTING)
enable_testing()
if (${PROJECT_NAME}_COVERAGE)
set(ENABLE_COVERAGE ON CACHE BOOL " " FORCE)
find_package(codecov)
endif ()
endif ()

if (HPWHSIM_ABRIDGED)
add_compile_definitions( HPWH_ABRIDGED)
endif()
add_compile_definitions(HPWH_ABRIDGED)
endif ()

add_subdirectory(vendor)
add_subdirectory(src)

if (NOT HPWHSIM_OMIT_TESTTOOL)
add_subdirectory(test)
endif()
if (${PROJECT_NAME}_BUILD_TESTING)
add_subdirectory(test)
if (${PROJECT_NAME}_COVERAGE)
coverage_evaluate()
endif ()
endif ()
Loading

0 comments on commit 3a2fa9b

Please sign in to comment.