Skip to content

Commit

Permalink
Add consistent nix testing
Browse files Browse the repository at this point in the history
  • Loading branch information
x-mass committed Apr 28, 2024
1 parent bd7ad3b commit 549e798
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 10 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: PR Testing

on:
pull_request:
push:
branches:
- master

concurrency:
# In master we want to run for every commit, in other branches — only for the last one
group: ${{
( github.ref == 'refs/heads/master' && format('{0}/{1}/{2}', github.workflow, github.ref, github.sha) )
||
format('{0}/{1}', github.workflow, github.ref) }}
cancel-in-progress: true

jobs:
handle-syncwith:
name: Call Reusable SyncWith Handler
uses: NilFoundation/ci-cd/.github/workflows/reusable-handle-syncwith.yml@v1.2.0
with:
ci-cd-ref: 'v1.2.0'
secrets: inherit

test-linux:
name: Linux Reusable Crypto3 Testing
needs:
- handle-syncwith
uses: NilFoundation/crypto3/.github/workflows/reusable-submodule-testing-linux.yml@fc033b4fe60244ce95b240adf18a0623961cb9d5
secrets: inherit
with:
submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
check-names: |
block-clang
# Temporarily disable mac tests, they fail.
# test-mac:
# name: Mac Reusable Crypto3 Testing
# needs:
# - handle-syncwith
# uses: NilFoundation/crypto3/.github/workflows/reusable-submodule-testing-mac.yml@fc033b4fe60244ce95b240adf18a0623961cb9d5
# secrets: inherit
# with:
# submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
# check-names: |
# block-clang

publish-results:
name: Publish JUnit results
needs:
- test-linux
# - test-mac
uses: NilFoundation/crypto3/.github/workflows/reusable-publish-result.yml@fc033b4fe60244ce95b240adf18a0623961cb9d5
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,5 @@ cm_deploy(TARGETS ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}
INCLUDE include
NAMESPACE ${CMAKE_WORKSPACE_NAME}::)

if(BUILD_TESTS)
add_subdirectory(test)
endif()
include(CMTest)
cm_add_test_subdirectory(test)
14 changes: 7 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# http://www.boost.org/LICENSE_1_0.txt
#---------------------------------------------------------------------------#

include(CMTest)

if(NOT Boost_UNIT_TEST_FRAMEWORK_FOUND)
cm_find_package(Boost REQUIRED COMPONENTS unit_test_framework)
endif()
Expand All @@ -16,27 +14,29 @@ cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}
${Boost_LIBRARIES})

macro(define_block_cipher_test name)
cm_test(NAME block_${name}_test SOURCES ${name}.cpp)
set(test_name "block_${name}_test")

cm_test(NAME ${test_name} SOURCES ${name}.cpp)

target_include_directories(block_${name}_test PRIVATE
target_include_directories(${test_name} PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>"

${Boost_INCLUDE_DIRS})

if(NOT CMAKE_CXX_STANDARD)
set_target_properties(block_${name}_test PROPERTIES CXX_STANDARD 14)
set_target_properties(${test_name} PROPERTIES CXX_STANDARD 14)
endif()

get_target_property(target_type Boost::unit_test_framework TYPE)
if(target_type STREQUAL "SHARED_LIB")
target_compile_definitions(block_${name}_test PRIVATE BOOST_TEST_DYN_LINK)
target_compile_definitions(${test_name} PRIVATE BOOST_TEST_DYN_LINK)
elseif(target_type STREQUAL "STATIC_LIB")

endif()

string(CONCAT TEST_DATA ${CMAKE_CURRENT_SOURCE_DIR} "/data/" "${name}" ".json")
target_compile_definitions(block_${name}_test PRIVATE TEST_DATA="${TEST_DATA}")
target_compile_definitions(${test_name} PRIVATE TEST_DATA="${TEST_DATA}")
endmacro()

set(TESTS_NAMES
Expand Down

0 comments on commit 549e798

Please sign in to comment.