From 0c1445a4b35c2a91bb4e8f4795c4a002f3d209ba Mon Sep 17 00:00:00 2001 From: HybridDog Date: Tue, 3 Jan 2023 15:15:05 +0100 Subject: [PATCH] CI: Decrease compilation times with Ccache I've excluded the docker build since it would probably require a modified Dockerfile. --- .github/workflows/linux.yml | 20 ++++++++++++++++++++ .github/workflows/lua.yml | 10 ++++++++++ util/buildbot/buildwin32.sh | 2 ++ util/buildbot/buildwin64.sh | 2 ++ util/ci/build.sh | 5 +++++ util/ci/build_prometheus_cpp.sh | 5 +++++ 6 files changed, 44 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 121e616ee..5034985b8 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -38,6 +38,10 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} - name: Install deps run: | source ./util/ci/common.sh @@ -59,6 +63,10 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} - name: Install deps run: | source ./util/ci/common.sh @@ -83,6 +91,10 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} - name: Install deps run: | source ./util/ci/common.sh @@ -105,6 +117,10 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} - name: Install deps run: | source ./util/ci/common.sh @@ -131,6 +147,10 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} - name: Install deps run: | source ./util/ci/common.sh diff --git a/.github/workflows/lua.yml b/.github/workflows/lua.yml index ff556908f..731e7054b 100644 --- a/.github/workflows/lua.yml +++ b/.github/workflows/lua.yml @@ -20,6 +20,11 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} + - name: Install deps run: | source ./util/ci/common.sh @@ -44,6 +49,10 @@ jobs: steps: - uses: actions/checkout@v4 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} - uses: leafo/gh-actions-lua@v10 with: luaVersion: "5.1.5" @@ -51,6 +60,7 @@ jobs: - name: Install LuaJIT run: | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" cd $HOME git clone https://github.com/LuaJIT/LuaJIT/ cd LuaJIT diff --git a/util/buildbot/buildwin32.sh b/util/buildbot/buildwin32.sh index 3504505e5..823b1e09b 100755 --- a/util/buildbot/buildwin32.sh +++ b/util/buildbot/buildwin32.sh @@ -62,6 +62,8 @@ cmake_args=( -DENABLE_GETTEXT=1 -DENABLE_LEVELDB=1 ) +# Use ccache if it is available +command -v ccache >/dev/null && cmake_args+=(-DCMAKE_{C,CXX}_COMPILER_LAUNCHER=ccache) add_cmake_libs cmake -S $sourcedir -B build "${cmake_args[@]}" diff --git a/util/buildbot/buildwin64.sh b/util/buildbot/buildwin64.sh index 774a1dfb8..7189b5835 100755 --- a/util/buildbot/buildwin64.sh +++ b/util/buildbot/buildwin64.sh @@ -62,6 +62,8 @@ cmake_args=( -DENABLE_GETTEXT=1 -DENABLE_LEVELDB=1 ) +# Use ccache if it is available +command -v ccache >/dev/null && cmake_args+=(-DCMAKE_{C,CXX}_COMPILER_LAUNCHER=ccache) add_cmake_libs cmake -S $sourcedir -B build "${cmake_args[@]}" diff --git a/util/ci/build.sh b/util/ci/build.sh index 944cc2124..a3ee89cce 100755 --- a/util/ci/build.sh +++ b/util/ci/build.sh @@ -1,6 +1,11 @@ #!/bin/bash -e +# Use ccache if it is available +extra_args=() +command -v ccache >/dev/null && extra_args+=(-DCMAKE_{C,CXX}_COMPILER_LAUNCHER=ccache) + cmake -B build \ + "${extra_args[@]}" \ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \ -DENABLE_LTO=FALSE \ -DRUN_IN_PLACE=TRUE \ diff --git a/util/ci/build_prometheus_cpp.sh b/util/ci/build_prometheus_cpp.sh index f3e4a5559..c94604b4a 100755 --- a/util/ci/build_prometheus_cpp.sh +++ b/util/ci/build_prometheus_cpp.sh @@ -1,10 +1,15 @@ #! /bin/bash -eu +# Use ccache if it is available +extra_args=() +command -v ccache >/dev/null && extra_args+=(-DCMAKE_{C,CXX}_COMPILER_LAUNCHER=ccache) + cd /tmp git clone --recursive https://github.com/jupp0r/prometheus-cpp mkdir prometheus-cpp/build cd prometheus-cpp/build cmake .. \ + "${extra_args[@]}" \ -DCMAKE_INSTALL_PREFIX=/usr/local \ -DCMAKE_BUILD_TYPE=Release \ -DENABLE_TESTING=0