diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 747a9c0..1181b88 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -5,7 +5,11 @@ name: build on: push: + branches: + - master pull_request: + branches: + - master workflow_dispatch: permissions: @@ -22,12 +26,26 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Cache test assets + uses: actions/cache@v4 + with: + path: build/teaklite2_tests_result.bin + enableCrossOsArchive: true + key: 'baffcd4f805a7480d969401792443a34aa39f813b4f0ae49c6365f1d1f3ce120' + + - name: Download test assets + if: "!hashFiles('build/teaklite2_tests_result.bin')" + run: | + git lfs pull --exclude='' --include='*' + mkdir -p build + mv src/test_verifier/data/teaklite2_tests_result.bin build/teaklite2_tests_result.bin + - name: Configure - run: cmake -B build + run: cmake -B build -DCMAKE_BUILD_TYPE=Debug -DTEAKRA_RUN_TESTS=ON -DTEAKRA_TEST_ASSETS_DIR="$PWD/build" - name: Build - run: cmake --build build --parallel + run: cmake --build build --config Debug --parallel - name: Test working-directory: build - run: ctest --verbose + run: ctest --build-config Debug --verbose diff --git a/.lfsconfig b/.lfsconfig new file mode 100644 index 0000000..2cf1bce --- /dev/null +++ b/.lfsconfig @@ -0,0 +1,2 @@ +[lfs] + fetchexclude = * diff --git a/CMakeLists.txt b/CMakeLists.txt index e220af5..4fc6843 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) if (NOT TEAKRA_TEST_ASSETS_DIR) - set(TEAKRA_TEST_ASSETS_DIR "${CMAKE_CURRENT_BINARY_DIR}") + set(TEAKRA_TEST_ASSETS_DIR "${PROJECT_SOURCE_DIR}/src/test_verifier/data") endif() # External libraries diff --git a/src/test_verifier/CMakeLists.txt b/src/test_verifier/CMakeLists.txt index dd5dd6c..c839883 100644 --- a/src/test_verifier/CMakeLists.txt +++ b/src/test_verifier/CMakeLists.txt @@ -14,24 +14,13 @@ target_compile_options(test_verifier PRIVATE ${TEAKRA_CXX_FLAGS}) set(ASSET_SHA256SUM "baffcd4f805a7480d969401792443a34aa39f813b4f0ae49c6365f1d1f3ce120") if(TEAKRA_RUN_TESTS) message(STATUS "Will run Teakra accuracy tests") - # download fixtures if there is none - if(NOT EXISTS "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result") - message(STATUS "Downloading required samples...") - file(DOWNLOAD - "https://liushuyu.b-cdn.net/teaklite2_tests_result_20181208" - "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result" - EXPECTED_HASH SHA256=${ASSET_SHA256SUM} - SHOW_PROGRESS - ) + # check if provided fixtures are good + file(SHA256 "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result.bin" ASSET_CHECKSUM) + if(ASSET_SHA256SUM STREQUAL ASSET_CHECKSUM) + message(STATUS "Unit test sample looks good.") else() - # check if provided fixtures are good - file(SHA256 "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result" ASSET_CHECKSUM) - if(ASSET_SHA256SUM STREQUAL ASSET_CHECKSUM) - message(STATUS "Unit test sample looks good.") - else() - message(FATAL_ERROR "Unit test sample broken. Please remove the file and re-run CMake.") - endif() + message(FATAL_ERROR "Unit test sample broken. Please download the file using: git lfs pull --exclude='' --include='*'") endif() - add_test(NAME tests COMMAND test_verifier "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result") + add_test(NAME tests COMMAND test_verifier "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result.bin") endif(TEAKRA_RUN_TESTS)