From 44e82955496499a2fa818d4ec5ebd4300f5add40 Mon Sep 17 00:00:00 2001 From: Florian Weik Date: Thu, 21 Sep 2023 20:11:37 +0200 Subject: [PATCH] Fiddle more with gh actions --- .github/workflows/build_cmake.yml | 130 ++++++++++-------------------- 1 file changed, 43 insertions(+), 87 deletions(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index fa89c26..c788b60 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -1,99 +1,55 @@ -name: continuous-integration +name: Linux -on: - push: - branches: - - master - pull_request: - types: [opened, synchronize] +on: [push] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: RelWithDebInfo jobs: - test-docs-build: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - name: Build Doxygen Docs - uses: mattnotmitt/doxygen-action@v1.3.3 + build: - continuous-integration: runs-on: ${{ matrix.os }} - env: - BUILD_TYPE: Debug strategy: - fail-fast: true matrix: os: [macos-10.15, ubuntu-20.04] cxx: [g++-10, clang++] include: - - os: windows-2019 - cxx: msvc + - os: windows-2019 + cxx: msvc steps: - - uses: actions/checkout@v2 - - - name: Cache CMake dependency source code - uses: actions/cache@v2 - env: - cache-name: cache-cmake-dependency-sources - with: - # CMake cache is at ${{github.workspace}}/build/_deps but we only will cache folders ending in '-src' to cache source code - path: ${{github.workspace}}/build/_deps/*-src - # Cache hash is dependent on CMakeLists files anywhere as these can change what's in the cache, as well as cmake modules files - key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} - # it's acceptable to reuse caches for different CMakeLists content if exact match is not available and unlike build caches, we - # don't need to restrict these by OS or compiler as it's only source code that's being cached - restore-keys: | - ${{ env.cache-name }}- - - - name: Cache CMake dependency build objects - uses: actions/cache@v2 - env: - cache-name: cache-cmake-dependency-builds - with: - # CMake cache is at ${{github.workspace}}/build/_deps but we only care about the folders ending in -build or -subbuild - path: | - ${{github.workspace}}/build/_deps/*-build - ${{github.workspace}}/build/_deps/*-subbuild - # Cache hash is dependent on CMakeLists files anywhere as these can change what's in the cache, as well as cmake modules files - key: ${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.cxx }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} - # it's acceptable to reuse caches for different CMakeLists content if exact match is not available - # as long as the OS and Compiler match exactly - restore-keys: | - ${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.cxx }}- - - # when building on master branch and not a pull request, build and test in release mode (optimised build) - - name: Set Build Mode to Release - shell: bash - if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }} - run: echo "BUILD_TYPE=Release" >> $GITHUB_ENV - - - name: Configure CMake - env: - CXX: ${{ matrix.cxx }} - # Use a bash shell so we can use the same syntax for environment variable - # access regardless of the host operating system - shell: bash - working-directory: ${{github.workspace}}/build - # Note the current convention is to use the -S and -B options here to specify source - # and build directories, but this is only available with CMake 3.13 and higher. - # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX:PATH=$GITHUB_WORKSPACE/test_install -DENABLE_TESTS=ON - - - name: Build - working-directory: ${{github.workspace}}/build - shell: bash - # Execute the build. You can specify a specific target with "--target " - run: cmake --build . --config $BUILD_TYPE - - - name: Test - working-directory: ${{github.workspace}}/build - shell: bash - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C $BUILD_TYPE --no-tests=error - - - name: Test Install - working-directory: ${{github.workspace}}/build - shell: bash - # Test install with CMake to the "test_install" directory - run: cmake --install . --config $BUILD_TYPE + - uses: actions/checkout@v2 + + - name: Create Build Environment + # Some projects don't allow in-source building, so create a separate build directory + # We'll use this as our working directory for all subsequent commands + run: cmake -E make_directory ${{runner.workspace}}/build + + - name: Configure CMake + # Use a bash shell so we can use the same syntax for environment variable + # access regardless of the host operating system + shell: bash + working-directory: ${{runner.workspace}}/build + env: + CXX: g++-10 + # Note the current convention is to use the -S and -B options here to specify source + # and build directories, but this is only available with CMake 3.13 and higher. + # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 + # + # We need to source the profile file to make sure conan is in PATH + run: | + cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE + + - name: Build + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute the build. You can specify a specific target with "--target " + run: cmake --build . --config $BUILD_TYPE + + - name: Test + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C $BUILD_TYPE