Skip to content

Commit

Permalink
Update sccache cache each consecutive run
Browse files Browse the repository at this point in the history
- Print sometimes useful cache hit stats after build.

Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
  • Loading branch information
Caellian committed Jan 5, 2025
1 parent 815c539 commit 344be5d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/build-and-test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,16 @@ jobs:
working-directory: /home/runner
run: |
curl -s -L "https://github.com/mozilla/sccache/releases/download/v${{ env.SCCACHE_VERSION }}/sccache-v${{ env.SCCACHE_VERSION }}-x86_64-unknown-linux-musl.tar.gz" \
| tar xvz -C .
| tar xz -C .
chmod +x "sccache-v${{ env.SCCACHE_VERSION }}-x86_64-unknown-linux-musl/sccache"
sudo cp "sccache-v${{ env.SCCACHE_VERSION }}-x86_64-unknown-linux-musl/sccache" "/bin/sccache"
rm -rf "sccache-v${{ env.SCCACHE_VERSION }}-x86_64-unknown-linux-musl"
mkdir .sccache
echo "SCCACHE_DIR=$PWD/.sccache" >> $GITHUB_ENV
if [ "$RUNNER_DEBUG" = "1" ]; then
echo "Running with debug output; cached binary artifacts will be ignored to produce a cleaner build"
echo "SCCACHE_RECACHE=true" >> $GITHUB_ENV
fi
- name: Install clang and libc++
if: matrix.compiler == 'clang'
run: |
Expand All @@ -103,7 +107,9 @@ jobs:
uses: actions/cache@v4
with:
path: "${{ env.SCCACHE_DIR }}"
key: sccache-${{ matrix.os }}-${{ matrix.x11 }}-${{ matrix.wayland }}-${{ matrix.compiler }}-${{ github.ref }}
key: sccache-${{ matrix.os }}-${{ matrix.x11 }}-${{ matrix.wayland }}-${{ matrix.compiler }}-${{ github.ref }}-${{ github.run_id }}
restore-keys: |
sccache-${{ matrix.os }}-${{ matrix.x11 }}-${{ matrix.wayland }}-${{ matrix.compiler }}-${{ github.ref }}
- name: Configure with CMake
run: |
set -x # show the commands we're running
Expand All @@ -119,6 +125,9 @@ jobs:
RSVG_ENABLED=ON
[[ "${{ matrix.os }}" == "ubuntu-20.04"* ]] && RSVG_ENABLED=OFF
# Reset sccache statistics
sccache --zero-stats
mkdir build
cd build
cmake .. -G Ninja \
Expand Down Expand Up @@ -147,6 +156,8 @@ jobs:
-DMAINTAINER_MODE=ON
- name: Compile
run: cmake --build build
- name: Show sccache stats
run: sccache --show-stats
- name: Test
working-directory: build
run: ctest --output-on-failure
4 changes: 2 additions & 2 deletions cmake/CCache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ else()
endif()
endif()

set_property(GLOBAL PROPERTY CMAKE_C_COMPILER_LAUNCHER "${CCACHE_COMMAND}")
set_property(GLOBAL PROPERTY CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_COMMAND}")
set_property(GLOBAL PROPERTY C_COMPILER_LAUNCHER "${CCACHE_COMMAND}")
set_property(GLOBAL PROPERTY CXX_COMPILER_LAUNCHER "${CCACHE_COMMAND}")

0 comments on commit 344be5d

Please sign in to comment.