From c433f906bc7a76a66ed019ded77ac2a28a8d858a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 4 Sep 2022 10:27:20 +0200 Subject: [PATCH] use `ccache` for Linux gcc CMake CI builds (#4426) * modernized some CMake invocations * CI-unixish.yml: use `ccache` for Linux gcc CMake builds * CI-unixish-docker.yml: use `ccache` for Linux gcc CMake builds * CI-unixish-docker.yml: enabled CMake build with tests for more images * CI-unixish-docker.yml: adjusted some step checks --- .github/workflows/CI-unixish-docker.yml | 32 +++++++++++++++++++------ .github/workflows/CI-unixish.yml | 31 ++++++++++++++---------- .github/workflows/CI-windows.yml | 10 +++----- .github/workflows/format.yml | 8 +++---- .github/workflows/selfcheck.yml | 8 ++----- 5 files changed, 51 insertions(+), 38 deletions(-) diff --git a/.github/workflows/CI-unixish-docker.yml b/.github/workflows/CI-unixish-docker.yml index 9a2874419..011bc5e01 100644 --- a/.github/workflows/CI-unixish-docker.yml +++ b/.github/workflows/CI-unixish-docker.yml @@ -27,9 +27,11 @@ jobs: if: matrix.image == 'centos:7' run: | yum install -y cmake gcc-c++ make pcre-devel + yum --enablerepo=extras install -y epel-release + yum install -y ccache - name: Install missing software on ubuntu - if: matrix.image != 'centos:7' + if: contains(matrix.image, 'ubuntu') run: | apt-get update apt-get install -y cmake g++ make libxml2-utils libpcre3-dev @@ -40,24 +42,40 @@ jobs: run: | sudo apt-get install qt5-default - # tests require CMake 3.4 + # needs to be called after the package installation since + # - it doesn't call "apt-get update" + # - it doesn't support centos + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + if: matrix.image != 'ubuntu:14.04' # no support for --set-config + with: + key: ${{ github.workflow }}-${{ matrix.image }} + + # tests require CMake 3.9 - no ccache available - name: Test CMake build (no tests) - if: matrix.image != 'ubuntu:22.10' + if: matrix.image == 'ubuntu:14.04' run: | mkdir cmake.output cd cmake.output cmake -G "Unix Makefiles" -DHAVE_RULES=On .. cmake --build . -- -j$(nproc) - cd .. + + # tests require CMake 3.9 - ccache available + - name: Test CMake build (no tests) + if: matrix.image == 'centos:7' || matrix.image == 'ubuntu:16:04' + run: | + mkdir cmake.output + cd cmake.output + cmake -G "Unix Makefiles" -DHAVE_RULES=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache .. + cmake --build . -- -j$(nproc) - name: Test CMake build - if: matrix.image == 'ubuntu:22.10' + if: matrix.image != 'centos:7' && matrix.image != 'ubuntu:14.04' && matrix.image != 'ubuntu:16.04' run: | mkdir cmake.output cd cmake.output cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On .. cmake --build . --target check -- -j$(nproc) - cd .. build_make: @@ -82,7 +100,7 @@ jobs: yum install -y ccache - name: Install missing software on ubuntu - if: matrix.image != 'centos:7' + if: contains(matrix.image, 'ubuntu') run: | apt-get update apt-get install -y g++ make python3 libxml2-utils libpcre3-dev diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 6d51a2898..632de0fc8 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -20,6 +20,12 @@ jobs: steps: - uses: actions/checkout@v2 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + if: contains(matrix.os, 'ubuntu') + with: + key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} + - name: Install missing software on ubuntu if: contains(matrix.os, 'ubuntu') run: | @@ -35,11 +41,8 @@ jobs: - name: CMake build on ubuntu (with GUI / system tinyxml2) if: contains(matrix.os, 'ubuntu') run: | - mkdir cmake.output.tinyxml2 - cd cmake.output.tinyxml2 - cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DUSE_BUNDLED_TINYXML2=Off .. - cmake --build . -- -j$(nproc) - cd .. + cmake -S . -B cmake.output.tinyxml2 -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake --build cmake.output.tinyxml2 -- -j$(nproc) - name: Run CMake test (system tinyxml2) if: contains(matrix.os, 'ubuntu') @@ -58,6 +61,12 @@ jobs: steps: - uses: actions/checkout@v2 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + if: contains(matrix.os, 'ubuntu') + with: + key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} + - name: Install missing software on ubuntu if: contains(matrix.os, 'ubuntu') run: | @@ -73,18 +82,14 @@ jobs: - name: CMake build on ubuntu (with GUI) if: contains(matrix.os, 'ubuntu') run: | - mkdir cmake.output - pushd cmake.output - cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On .. - cmake --build . -- -j$(nproc) + cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake --build cmake.output -- -j$(nproc) - name: CMake build on macos (with GUI) if: contains(matrix.os, 'macos') run: | - mkdir cmake.output - pushd cmake.output - cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DQt5_DIR=$(brew --prefix qt@5)/lib/cmake/Qt5 .. - cmake --build . -- -j$(nproc) + cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DQt5_DIR=$(brew --prefix qt@5)/lib/cmake/Qt5 + cmake --build cmake.output -- -j$(nproc) - name: Run CMake test run: | diff --git a/.github/workflows/CI-windows.yml b/.github/workflows/CI-windows.yml index 8b8ae71cc..74d3575e7 100644 --- a/.github/workflows/CI-windows.yml +++ b/.github/workflows/CI-windows.yml @@ -121,10 +121,8 @@ jobs: - name: Build GUI release (CMake) if: startsWith(matrix.qt_ver, '6') && matrix.arch == 'x64' run: | - md build || exit /b !errorlevel! - cd build || exit /b !errorlevel! - cmake -DBUILD_GUI=On -DWITH_QCHART=On -DUSE_QT6=On .. || exit /b !errorlevel! - cmake --build . --target cppcheck-gui || exit /b !errorlevel! + cmake -S . -B build -DBUILD_GUI=On -DWITH_QCHART=On -DUSE_QT6=On || exit /b !errorlevel! + cmake --build build --target cppcheck-gui || exit /b !errorlevel! # TODO: deploy with Qt6 @@ -135,9 +133,7 @@ jobs: if "${{ matrix.arch }}" == "x86" ( set ARCH=Win32 ) - md build || exit /b !errorlevel! - cd build || exit /b !errorlevel! - cmake -DBUILD_TESTS=On .. || exit /b !errorlevel! + cmake -S . -B build -DBUILD_TESTS=On || exit /b !errorlevel! - name: Build CLI debug configuration using MSBuild if: matrix.qt_ver == '' diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 3b8d1a557..07fbe734d 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -28,12 +28,10 @@ jobs: run: | wget https://github.com/uncrustify/uncrustify/archive/refs/tags/uncrustify-0.72.0.tar.gz tar xzvf uncrustify-0.72.0.tar.gz && cd uncrustify-uncrustify-0.72.0 - mkdir build - cd build - cmake -DCMAKE_BUILD_TYPE=Release .. - cmake --build . -- -j$(nproc) -s + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + cmake --build build -- -j$(nproc) -s mkdir ~/uncrustify - cp uncrustify ~/uncrustify/ + cd build && cp uncrustify ~/uncrustify/ - name: Uncrustify check run: | diff --git a/.github/workflows/selfcheck.yml b/.github/workflows/selfcheck.yml index 6a949c07a..961e751dc 100644 --- a/.github/workflows/selfcheck.yml +++ b/.github/workflows/selfcheck.yml @@ -45,9 +45,7 @@ jobs: - name: CMake run: | - mkdir cmake.output - pushd cmake.output - cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=ON -DWITH_QCHART=ON -DCMAKE_GLOBAL_AUTOGEN_TARGET=On .. + cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=ON -DWITH_QCHART=ON -DCMAKE_GLOBAL_AUTOGEN_TARGET=On - name: Generate dependencies run: | @@ -69,9 +67,7 @@ jobs: # the following steps are duplicated from above since setting up the build node in a parallel step takes longer than the actual steps - name: CMake (no test) run: | - mkdir cmake.output.notest - pushd cmake.output.notest - cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=0 -DBUILD_GUI=ON -DWITH_QCHART=ON -DCMAKE_GLOBAL_AUTOGEN_TARGET=On .. + cmake -S . -B cmake.output.notest -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=0 -DBUILD_GUI=ON -DWITH_QCHART=ON -DCMAKE_GLOBAL_AUTOGEN_TARGET=On - name: Generate dependencies (no test) run: |