Skip to content

Commit

Permalink
Enable nektos/act for local workflow testing (#1)
Browse files Browse the repository at this point in the history
Changes:
+ Update unit test workflow to enable running with nektos/act
+ Add nektos/act config file
+ Always build CPack config
  • Loading branch information
H0R5E authored Nov 26, 2024
1 parent c9942d4 commit 220c8f3
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 69 deletions.
1 change: 1 addition & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-P ubuntu-latest=catthehacker/ubuntu:act-latest
24 changes: 20 additions & 4 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
push:
branches:
- main
env:
CMAKE_VERSION: "3.27.x"
PYTHON_VERSION: "3.13"

jobs:
main:
Expand All @@ -21,14 +24,20 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
python-version: ${{ env.PYTHON_VERSION }}
- uses: abatilo/actions-poetry@v2
- name: Configure runner (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install ninja-build
run: |
sudo apt-get update
sudo apt-get install -yq clang ninja-build xvfb
- name: Configure runner (Windows)
uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: ${{ env.CMAKE_VERSION }}
- name: Install Conan
run: |
poetry install
Expand Down Expand Up @@ -64,10 +73,16 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
python-version: ${{ env.PYTHON_VERSION }}
- uses: abatilo/actions-poetry@v2
- name: Configure runner
run: sudo apt-get install llvm ninja-build
run: |
sudo apt-get update
sudo apt-get install -yq clang llvm ninja-build xvfb
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: ${{ env.CMAKE_VERSION }}
- name: Install Conan
run: |
poetry install
Expand All @@ -92,5 +107,6 @@ jobs:
run: poetry run cmake --build . --config Debug -t coverage-xml
working-directory: build
- uses: codecov/codecov-action@v4
if: ${{ !env.ACT }}
with:
directory: build
126 changes: 61 additions & 65 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
option(ESPEAKNG_BUILD "Build espeak-ng" ON)
option(GCOVR_HTML "Generate HTML code coverage report" OFF)
option(GCOVR_XML "Generate XML code coverage report" OFF)
option(RPM "Create an RPM package" OFF)
option(INNO "Create a inno setup package" OFF)

# conan
find_package(argparse REQUIRED)
Expand All @@ -62,6 +60,9 @@ find_program(GCOVR_PATH gcovr)
# install settings
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)

# packaging
include(CPack)

# debug compiler flags
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
Expand Down Expand Up @@ -90,6 +91,41 @@ endif ()
configure_file(${CMAKE_SOURCE_DIR}/src/pathconfig.h.in
${CMAKE_SOURCE_DIR}/src/pathconfig.h)

# RPATH handling

if (UNIX)

# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)

# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

endif ()

# path to source code
add_subdirectory(app)
add_subdirectory(src)
add_subdirectory(vendor)

# discover test files
file(GLOB test_SRC CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/test/*.cpp"
"${CMAKE_SOURCE_DIR}/test/*.h")

# add tests
add_executable(tests ${test_SRC})
#add_executable(tests "${CMAKE_SOURCE_DIR}/test/game_test.cpp"
# "${CMAKE_SOURCE_DIR}/test/mock.h")
target_link_libraries(tests
game
drawcomponents
soundcomponents
gtest::gtest)

gtest_discover_tests(tests)

# coverage target and compiler flags
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND
CMAKE_BUILD_TYPE STREQUAL "Debug" AND
Expand Down Expand Up @@ -136,44 +172,7 @@ if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "G
COMMENT "Removing build and gcov files."
)

endif ()

# RPATH handling

if (UNIX)

# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)

# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

endif ()

# path to source code
add_subdirectory(app)
add_subdirectory(src)
add_subdirectory(vendor)

# discover test files
file(GLOB test_SRC CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/test/*.cpp"
"${CMAKE_SOURCE_DIR}/test/*.h")

# add tests
add_executable(tests ${test_SRC})
#add_executable(tests "${CMAKE_SOURCE_DIR}/test/game_test.cpp"
# "${CMAKE_SOURCE_DIR}/test/mock.h")
target_link_libraries(tests
game
drawcomponents
soundcomponents
gtest::gtest)

gtest_discover_tests(tests)

# extra install commands
endif()

# Install libs
install(FILES $<TARGET_RUNTIME_DLLS:louis> TYPE BIN)
Expand Down Expand Up @@ -212,32 +211,29 @@ if(NOT TARGET uninstall)
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake)
endif()

if (RPM OR INNO)
# General CPack variables
SET(CPACK_VERBATIM_VARIABLES TRUE)
set(CPACK_PACKAGE_DESCRIPTION "\
A C++ project to create a game for my son to do his work on my computer")
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/packages")
set(CPACK_PACKAGE_VENDOR "Mathew Topper")
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/COPYING)
# CPack setup
SET(CPACK_VERBATIM_VARIABLES TRUE)
set(CPACK_PACKAGE_DESCRIPTION "\
A C++ project to create a game for my son to do his work on my computer")
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/packages")
set(CPACK_PACKAGE_VENDOR "Mathew Topper")
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/COPYING)

if (UNIX)

# RPM
if (RPM AND UNIX)
set(CPACK_PACKAGE_NAME "louis-work")
set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_PACKAGE_RELEASE 1)
endif ()

if (INNO AND WIN32)
set(CPACK_PACKAGE_NAME "Louis Work")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Louis Work")
set(CPACK_GENERATOR "INNOSETUP")
set(CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT ON)
set(CPACK_INNOSETUP_SETUP_ChangesEnvironment ON)
set(CPACK_INNOSETUP_EXTRA_SCRIPTS ${CMAKE_SOURCE_DIR}/cmake/icons.iss)
endif ()
set(CPACK_PACKAGE_NAME "louis-work")
set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_PACKAGE_RELEASE 1)

elseif(WIN32)

include(CPack)
# Inno Setup
set(CPACK_PACKAGE_NAME "Louis Work")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Louis Work")
set(CPACK_GENERATOR "INNOSETUP")
set(CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT ON)
set(CPACK_INNOSETUP_SETUP_ChangesEnvironment ON)
set(CPACK_INNOSETUP_EXTRA_SCRIPTS ${CMAKE_SOURCE_DIR}/cmake/icons.iss)

endif()
endif ()

0 comments on commit 220c8f3

Please sign in to comment.