diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d585d74..5c7959e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -146,7 +146,9 @@ jobs: uses: actions/cache/restore@v4 with: key: deps-${{ matrix.os.name }}-${{ matrix.os.version }}-${{ matrix.compiler.toolset }}-${{ steps.env-info.outputs.compiler-full-version }}-${{ matrix.cpp_version.name }}-${{ matrix.build_type.name }} - path: ${{ github.workspace }}/build/_deps + path: | + ${{ github.workspace }}/build/_deps + ${{ github.workspace }}/build/.iris_deps_build_stamp # Adapt CMP0168; enable caching in CI # https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_FULLY_DISCONNECTED @@ -172,16 +174,38 @@ jobs: -DIRIS_CI=ON \ -S . + - name: Check Deps build time stamp (pre-build) + id: pre-build-check + shell: bash + run: | + if [ -e build/.iris_deps_build_stamp ]; then + echo "deps-timestamp=$(stat -c %Y build/.iris_deps_build_stamp)" >> $GITHUB_OUTPUT + else + echo "deps-timestamp=0" >> $GITHUB_OUTPUT + fi + + - name: Try building Deps + run: | + cmake --build build --config ${{ matrix.build_type.name }} -j${{ env.IRIS_BUILD_JOBS }} --target iris_deps_build_check ${{ matrix.compiler.builder_additional_args }} + + - name: Check Deps build time stamp (post-build) + id: post-build-check + shell: bash + run: | + echo "deps-timestamp=$(stat -c %Y build/.iris_deps_build_stamp)" >> $GITHUB_OUTPUT + - name: Build Tests run: | cmake --build build --config ${{ matrix.build_type.name }} -j${{ env.IRIS_BUILD_JOBS }} ${{ matrix.compiler.builder_additional_args }} - name: Cache CMake Dependencies (save) - if: steps.cache-deps.outputs.cache-hit != 'true' + if: steps.cache-deps.outputs.cache-hit != 'true' || steps.pre-build-check.outputs.deps-timestamp != steps.post-build-check.outputs.deps-timestamp uses: actions/cache/save@v4 with: key: ${{ steps.cache-deps.outputs.cache-primary-key }} - path: ${{ github.workspace }}/build/_deps + path: | + ${{ github.workspace }}/build/_deps + ${{ github.workspace }}/build/.iris_deps_build_stamp - name: Test env: diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fc6928f..0b7b23c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -88,6 +88,16 @@ target_link_libraries(Catch2WithMain PRIVATE iris_cxx_test_external) target_link_libraries(iris_cxx_test INTERFACE Catch2::Catch2WithMain) +if (IRIS_CI) + set(IRIS_DEPS_STAMP "${CMAKE_BINARY_DIR}/.iris_deps_build_stamp") + add_custom_command( + OUTPUT "${IRIS_DEPS_STAMP}" + COMMAND touch "${IRIS_DEPS_STAMP}" + DEPENDS Catch2::Catch2 + COMMENT "Deps is rebuilt" + ) + add_custom_target(iris_deps_build_check ALL DEPENDS "${IRIS_DEPS_STAMP}") +endif() # ----------------------------------------------------------------- # Common CMake utilities for testing