Compare commits

..

1 commit

Author SHA1 Message Date
59d8c3cbde
ci: add unit tests Dockerfile 2025-07-15 16:49:34 +03:30
10 changed files with 36 additions and 99 deletions

View file

@ -32,43 +32,8 @@ steps:
fi
exit ${has_fomatting_issues}
---
kind: pipeline
type: docker
name: unit tests
clone:
recursive: true
submodule_update_remote: true
trigger:
branch:
- main
steps:
- name: unit tests
image: unit_tests:latest
pull: if-not-exists
commands:
- |
git submodule update --init --recursive
conan build . \
-c tools.system.package_manager:mode=install \
-s build_type=Release \
-o enable_static_analysis=False \
-o enable_tests=True \
--build=missing
find ./build \
-type f \
-name '*_tests' \
-executable \
-exec sh -c \
'{}' \
\;
---
kind: pipeline
type: docker
name: static analysis
@ -86,12 +51,5 @@ steps:
pull: if-not-exists
privileged: true
commands:
- |
git submodule update --init --recursive
conan build . \
-c tools.system.package_manager:mode=install \
-s build_type=Release \
-o enable_static_analysis=True \
-o enable_tests=True \
--build=missing
- git submodule update --init --recursive
- conan build . -s build_type=Release -o enable_static_analysis=True --build=missing

View file

@ -2,15 +2,29 @@ cmake_minimum_required(VERSION 3.14)
project(Light)
set(CMAKE_CXX_STANDARD 23)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/functions.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/definitions.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/dependencies.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/macros.cmake)
add_option(ENABLE_STATIC_ANALYSIS "Enables clang-tidy static analysis")
add_option(ENABLE_STATIC_ANALYSIS "Performs static analysis via clang-tidy and fails build on failing checks")
if (ENABLE_STATIC_ANALYSIS)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;--warnings-as-errors=*;--allow-no-checks")
endif ()
add_option(ENABLE_TESTS "Enables the building of the test modules")
if(WIN32)
add_compile_definitions(LIGHT_PLATFORM_WINDOWS)
elseif(UNIX)
add_compile_definitions(LIGHT_PLATFORM_LINUX)
endif()
find_package(glfw3 REQUIRED)
find_package(glm REQUIRED)
find_package(spdlog REQUIRED)
find_package(stb REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(EnTT REQUIRED)
find_package(opengl_system REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(lz4 REQUIRED)
add_subdirectory(./modules)
add_subdirectory(./external)

View file

@ -11,13 +11,11 @@ class LightRecipe(ConanFile):
generators = "CMakeDeps"
options = {
"enable_tests": [True, False],
"enable_static_analysis": [True, False],
"export_compile_commands": [True, False],
}
default_options = {
"enable_tests": True,
"export_compile_commands": True,
"enable_static_analysis": False,
}
@ -45,7 +43,6 @@ class LightRecipe(ConanFile):
tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = self.options.export_compile_commands
tc.cache_variables["ENABLE_STATIC_ANALYSIS"] = self.options.enable_static_analysis
tc.cache_variables["ENABLE_TESTS"] = self.options.enable_tests
repo = git.Repo(search_parent_directories=True)
tc.cache_variables["GIT_HASH"] = repo.head.object.hexsha

View file

@ -1,6 +0,0 @@
A bleeding-edge, cross-platform, cross-graphics-api, minimal-dependencies modern game-engine.
Supported Platforms: Windows, Mac, Linux, FreeBSD
Supported GraphicsAPIs: DirectX12-Ultimate, Vulkan 1.4, Metal, OpenGL 4.6
Dependencies: stdlib, meshoptimizer

View file

@ -1,2 +1,4 @@
add_library_module(test test.cpp entrypoint.cpp)
add_test_module(test test.tests.cpp)
add_executable(test_tests ${CMAKE_CURRENT_SOURCE_DIR}/tests/test.cpp)
target_link_libraries(test_tests PRIVATE test)

View file

@ -1,3 +1,6 @@
add_library_module(time timer.cpp)
add_test_module(time timer.tests.cpp)
add_executable(timer_tests ${CMAKE_CURRENT_SOURCE_DIR}/src/timer.tests.cpp)
target_include_directories(timer_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(timer_tests PRIVATE time test)

View file

@ -1,5 +0,0 @@
if(WIN32)
add_compile_definitions(LIGHT_PLATFORM_WINDOWS)
elseif(UNIX)
add_compile_definitions(LIGHT_PLATFORM_LINUX)
endif()

View file

@ -1,9 +0,0 @@
find_package(glfw3 REQUIRED)
find_package(glm REQUIRED)
find_package(spdlog REQUIRED)
find_package(stb REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(EnTT REQUIRED)
find_package(opengl_system REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(lz4 REQUIRED)

View file

@ -1,4 +1,4 @@
function (add_library_module libname)
macro (add_library_module libname)
if ("${ARGN}" STREQUAL "") # Header only library
message("Adding INTERFACE library ${libname}")
add_library(${libname} INTERFACE)
@ -25,9 +25,9 @@ function (add_library_module libname)
target_link_libraries(${libname} PUBLIC base)
endif ()
endif ()
endfunction ()
endmacro ()
function (add_executable_module exename)
macro (add_executable_module exename)
set(source_files)
set(source_directory "${CMAKE_CURRENT_SOURCE_DIR}/src")
foreach (source_file ${ARGN})
@ -36,28 +36,11 @@ function (add_executable_module exename)
message("Adding executable ${exename} with source files: ${source_files}")
add_executable(${exename} ${source_files})
target_include_directories(${exename} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(${exename} PRIVATE base)
endfunction ()
target_include_directories(${exename} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(${exename} PUBLIC base)
endmacro ()
function (add_test_module exename)
if (NOT ${ENABLE_TESTS})
return()
endif ()
set(source_files)
set(source_directory "${CMAKE_CURRENT_SOURCE_DIR}/src")
foreach (source_file ${ARGN})
list(APPEND source_files "${source_directory}/${source_file}")
endforeach ()
message("Adding test executable ${exename}_tests with source files: ${source_files}")
add_executable(${exename}_tests ${source_files})
target_include_directories(${exename} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(${exename}_tests PRIVATE ${exename} base test)
endfunction ()
function (add_option option help)
macro (add_option option help)
option(${option} ${help})
if (${option})
@ -66,4 +49,4 @@ function (add_option option help)
else ()
message(STATUS "${option}: OFF")
endif ()
endfunction ()
endmacro ()