From 6cd1dc92181efb1592a7082426e67d4eee13edb5 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Sun, 13 Oct 2024 00:54:50 +0200 Subject: [PATCH] Add github ci wokflow Signed-off-by: Christian Parpart --- .github/workflows/main.yml | 68 +++++++++++++++++++++++++++ CMakeLists.txt | 2 +- CMakePresets.json | 1 - include/reflection-cpp/Reflection.hpp | 15 +++--- 4 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..fb2e96b --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,68 @@ +name: Build and Test + +on: + merge_group: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + + # FIXME: We're having a linker error wrt. Catch2 on Windows with MSVC + # windows-msvc: + # name: "Windows - MSVC" + # runs-on: windows-latest + # steps: + # - uses: actions/checkout@v4 + # - name: Install dependencies + # run: choco install ninja + # - name: configure + # run: cmake --preset windows-cl-release + # - name: build + # run: cmake --build --preset windows-cl-release + # - name: test + # run: ctest --preset windows-cl-release -VV + + ubuntu24-clang: + name: "Ubuntu Linux - Clang ${{ matrix.clang_version }}" + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + clang_version: [17, 18] + steps: + - uses: actions/checkout@v4 + - name: Install clang + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh ${{ matrix.clang_version }} + - name: Install ninja + run: sudo apt-get install ninja-build + - name: configure + run: cmake --preset linux-clang-release + - name: build + run: cmake --build --preset linux-clang-release + - name: test + run: ctest --preset linux-clang-release -VV + + ubuntu24-gcc: + name: "Ubuntu Linux - GCC ${{ matrix.gcc_version }}" + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + gcc_version: [13, 14] + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: sudo apt-get install ninja-build g++-${{ matrix.gcc_version }} + - name: configure + run: cmake --preset linux-gcc-release + - name: build + run: cmake --build --preset linux-gcc-release + - name: test + run: ctest --preset linux-gcc-release -VV diff --git a/CMakeLists.txt b/CMakeLists.txt index 06be234..7ca646b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,7 @@ if(BOXED_TESTING) test-reflection-cpp.cpp ) target_compile_features(test-reflection-cpp INTERFACE cxx_std_20) - target_link_libraries(test-reflection-cpp reflection-cpp Catch2::Catch2WithMain) + target_link_libraries(test-reflection-cpp reflection-cpp Catch2::Catch2 Catch2::Catch2WithMain) add_test(test-reflection-cpp ./test-reflection-cpp) endif() message(STATUS "[reflection-cpp] Compile unit tests: ${BOXED_TESTING}") diff --git a/CMakePresets.json b/CMakePresets.json index a87b5ea..8598d80 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -16,7 +16,6 @@ "name": "windows-common", "hidden": true, "inherits": ["common"], - "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", "condition": { "type": "equals", "lhs": "${hostSystemName}", diff --git a/include/reflection-cpp/Reflection.hpp b/include/reflection-cpp/Reflection.hpp index b8e90c7..f515221 100644 --- a/include/reflection-cpp/Reflection.hpp +++ b/include/reflection-cpp/Reflection.hpp @@ -81,7 +81,7 @@ namespace detail constexpr auto joined_arr = []() { constexpr size_t len = (Strs.size() + ... + 0); std::array arr {}; - auto append = [i = 0, &arr](const auto& s) mutable { + auto append = [i = 0u, &arr](const auto& s) mutable { for (auto c: s) arr[i++] = c; }; @@ -356,13 +356,13 @@ consteval std::string_view GetName() #if defined(_MSC_VER) && !defined(__clang__) if constexpr (std::is_member_object_pointer_v) { - using T = remove_member_pointer>::type; + using T = detail::remove_member_pointer>::type; constexpr auto p = P; return detail::get_name_msvc.*p)>(); } else { - using T = remove_member_pointer>::type; + using T = detail::remove_member_pointer>::type; return detail::func_name_msvc(); } #else @@ -384,8 +384,9 @@ consteval auto GetName() str = str.substr(str.rfind("::") + 2); return str.substr(0, str.find('>')); #else + constexpr auto MarkerStart = std::string_view { "E = " }; std::string_view str = REFLECTION_PRETTY_FUNCTION; - str = str.substr(str.rfind("::") + 2 + 15); + str = str.substr(str.rfind(MarkerStart) + MarkerStart.size()); str = str.substr(0, str.find(']')); return str; #endif @@ -396,8 +397,8 @@ std::string Inspect(Object const& object) { return [&](std::index_sequence) { std::string str; - auto onMember = [&str](auto&& name, auto&& value) { - auto onValue = [&str](T&& arg) { + auto const onMember = [&str](Name&& name, Value&& value) { + auto const InspectValue = [&str](T&& arg) { // clang-format off if constexpr (std::is_convertible_v || std::is_convertible_v @@ -410,7 +411,7 @@ std::string Inspect(Object const& object) str += ' '; str += name; str += '='; - onValue(value); + InspectValue(value); }; (onMember(MemberNameOf, std::get(Reflection::ToTuple(object))), ...); return str;