diff --git a/.github/workflows/publish-results.yml b/.github/workflows/publish-results.yml new file mode 100644 index 0000000..4b7b9f3 --- /dev/null +++ b/.github/workflows/publish-results.yml @@ -0,0 +1,13 @@ +# Needed to publish test results in fork +name: Testing Callback + +on: + workflow_run: + workflows: ["PR Testing"] + types: + - completed + +jobs: + call-reusable-workflow: + name: Call Reusable Testing Callback Workflow + uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-publish-result.yml@v1 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..4fd0c71 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,24 @@ +name: PR Testing + +on: + pull_request: + types: + - opened + - synchronize + +jobs: + handle-syncwith: + name: Call Reusable SyncWith Handler + uses: NilFoundation/ci-cd/.github/workflows/reusable-handle-syncwith.yml@v1 + with: + ci-cd-ref: 'v1' + secrets: inherit + + matrix-test: + name: Call Reusable Crypto3 Testing + needs: + - handle-syncwith + uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-testing.yml@v1 + with: + submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }} + secrets: inherit diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6b60c8b..9f6ec8d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,26 +18,40 @@ cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} ${Boost_LIBRARIES}) macro(define_codec_test name) - cm_test(NAME codec_${name}_test SOURCES ${name}.cpp) + set(test_name "codec_${name}_test") - target_include_directories(codec_${name}_test PRIVATE + set(additional_args "") + if(ENABLE_JUNIT_TEST_OUTPUT) + set(TEST_RESULTS_DIR "${CMAKE_CURRENT_BINARY_DIR}/junit_results") + set(TEST_LOGS_DIR "${TEST_RESULTS_DIR}/logs") + file(MAKE_DIRECTORY ${TEST_LOGS_DIR}) + + set(additional_args "--log_format=JUNIT" + "--log_sink=${TEST_LOGS_DIR}/${test_name}.xml") + endif() + + cm_test(NAME ${test_name} SOURCES ${name}.cpp ARGS ${additional_args}) + + target_include_directories(${test_name} PRIVATE "$" "$" ${Boost_INCLUDE_DIRS}) if(NOT CMAKE_CXX_STANDARD) - set_target_properties(codec_${name}_test PROPERTIES + set_target_properties(${test_name} PROPERTIES CXX_STANDARD 14 CXX_STANDARD_REQUIRED TRUE) endif() get_target_property(target_type Boost::unit_test_framework TYPE) if(target_type STREQUAL "SHARED_LIB") - target_compile_definitions(codec_${name}_test PRIVATE BOOST_TEST_DYN_LINK) + target_compile_definitions(${test_name} PRIVATE BOOST_TEST_DYN_LINK) elseif(target_type STREQUAL "STATIC_LIB") endif() + + target_compile_definitions(${test_name} PRIVATE TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data/") endmacro() set(TESTS_NAMES "hex" "base") diff --git a/test/base.cpp b/test/base.cpp index 1c95f84..8e57b20 100644 --- a/test/base.cpp +++ b/test/base.cpp @@ -61,7 +61,7 @@ namespace boost { } // namespace test_tools } // namespace boost -const char *test_data = "data/base.json"; +std::string test_data = std::string(TEST_DATA_DIR) + R"(base.json)"; boost::property_tree::ptree base_data(const char *child_name) { boost::property_tree::ptree root_data; diff --git a/test/hex.cpp b/test/hex.cpp index eb6a71e..3ec59ac 100644 --- a/test/hex.cpp +++ b/test/hex.cpp @@ -59,7 +59,7 @@ namespace boost { } // namespace test_tools } -const char *test_data = "data/hex.json"; +std::string test_data = std::string(TEST_DATA_DIR) + R"(hex.json)"; boost::property_tree::ptree mode_data(const char *mode) { boost::property_tree::ptree root_data;