From db3b18b36de9afba74aec3e6d929de8588ef259f Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Fri, 9 May 2025 10:05:07 -0400 Subject: [PATCH] build: Add new SKIP_BUILD_TESTS option to allow the build time test to be skipped and run later on ci: run and check Qt Tests post build --- .github/actions/run-tests/action.yml | 20 +++++++++++++++++++- .github/workflows/continuous-integration.yml | 2 +- src/unittests/CMakeLists.txt | 16 ++++++++++------ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index c31a982e2..f7b8ab665 100644 --- a/.github/actions/run-tests/action.yml +++ b/.github/actions/run-tests/action.yml @@ -15,8 +15,22 @@ runs: using: "composite" steps: - - name: Unit tests + - name: unittests id: unittests + env: + QT_QPA_PLATFORM: offscreen + run: | + ctest --test-dir "build/src/unittests" --output-on-failure + result=$? + + if [ $result -ne 0 ]; then + echo "Unit tests failed with code: $result" >> $GITHUB_STEP_SUMMARY + fi + shell: bash + continue-on-error: true + + - name: legacytests + id: legacytests env: QT_QPA_PLATFORM: offscreen run: | @@ -35,8 +49,11 @@ runs: pass="✅ Pass" fail="❌ Fail" unittests_outcome="${{ steps.unittests.outcome }}" + legacytests_outcome="${{ steps.legacytests.outcome }}" unittests=$( [ "$unittests_outcome" = "success" ] && echo $pass || echo $fail ) + legacytests=$( [ "$legacytests_outcome" = "success" ] && echo $pass || echo $fail ) echo "unittests=$unittests" >> $GITHUB_OUTPUT + echo "legacytests=$legacytests" >> $GITHUB_OUTPUT shell: bash - name: Summary row @@ -47,6 +64,7 @@ runs: row="" row+="| ${{ inputs.job }} " row+="| ${{ steps.results.outputs.unittests }} " + row+="| ${{ steps.results.outputs.legacytests }} " echo "$row" > $file echo "file=$file" > $GITHUB_OUTPUT diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index d34ec040a..5fdf403d4 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -28,7 +28,7 @@ env: GIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} PACKAGE_PREFIX: "deskflow" PACKAGE_PATH: ./dist - CMAKE_CONFIGURE: "cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=ON" + CMAKE_CONFIGURE: "cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DSKIP_BUILD_TESTS=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON" jobs: # Always run this job, even if not on PR, since other jobs need it. diff --git a/src/unittests/CMakeLists.txt b/src/unittests/CMakeLists.txt index b45e9ecd8..b8882ac3a 100644 --- a/src/unittests/CMakeLists.txt +++ b/src/unittests/CMakeLists.txt @@ -66,9 +66,13 @@ else() set(guiApp deskflow) endif() -add_custom_target(run_tests ALL DEPENDS ${PROJECT_TESTS} ${guiApp}) -add_custom_command ( - TARGET run_tests - POST_BUILD - COMMAND ${qPA_Platform} ${CMAKE_CTEST_COMMAND} --test-dir "${CMAKE_BINARY_DIR}/src/unittests" --output-on-failure -) +option(SKIP_BUILD_TESTS "Skip build time test" OFF) + +if(NOT SKIP_BUILD_TESTS) + add_custom_target(run_tests ALL DEPENDS ${PROJECT_TESTS} ${guiApp}) + add_custom_command ( + TARGET run_tests + POST_BUILD + COMMAND ${qPA_Platform} ${CMAKE_CTEST_COMMAND} --test-dir "${CMAKE_BINARY_DIR}/src/unittests" --output-on-failure + ) +endif()