From 86f73c889b72816ff6755d98591b78785ea5530d Mon Sep 17 00:00:00 2001 From: Hanif Koh Date: Wed, 9 Sep 2026 17:42:56 +0800 Subject: [PATCH] ci: cache compiled objects between runs Every CI leg compiles the whole tree from scratch, 45 to 57 minutes of each build job. Add ccache to the slicer build on all platforms, keyed per leg, restored at the start and saved at the end of the job. Pull requests are meant to restore only; saving is enabled here so a second run on this branch measures a warm cache. --- .github/workflows/build_orca.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 8e1e28db13..d9cdf7ff19 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -76,6 +76,33 @@ jobs: if (-not (Test-Path "$cmakeBin\cmake.exe")) { throw "cmake.exe not found at $cmakeBin" } Add-Content -Path $env:GITHUB_PATH -Value $cmakeBin + # Compiler cache. Objects are keyed on the preprocessed source, the + # compiler binary and the flags, so a leg only ever hits its own entries. + # Pushes save (main keeps the cache warm); pull requests restore it and + # discard what they compiled, so the store does not grow per PR. A failed + # install only costs the caching, not the build. + - name: Compiler cache + id: ccache + if: ${{ !inputs.macos-combine-only }} + continue-on-error: true + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ runner.os }}-${{ inputs.arch || 'amd64' }}${{ runner.os == 'Windows' && format('-{0}', inputs.compiler) || '' }} + max-size: 2G + # TEST: pull requests save too, so a second run on this branch measures + # a warm cache. Restore-only for pull_request before merge. + save: true + + - name: Enable compiler cache + if: ${{ steps.ccache.outcome == 'success' }} + shell: bash + run: | + echo "CMAKE_C_COMPILER_LAUNCHER=ccache" >> "$GITHUB_ENV" + echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> "$GITHUB_ENV" + # Needed for precompiled headers and for headers a fresh checkout + # has just written. + echo "CCACHE_SLOPPINESS=pch_defines,time_macros,include_file_mtime,include_file_ctime" >> "$GITHUB_ENV" + - name: Get the version and date on Ubuntu and macOS if: runner.os != 'Windows' run: | @@ -670,3 +697,8 @@ jobs: asset_name: orca_custom_preset_tests.zip asset_content_type: application/octet-stream max_releases: 1 + + - name: Compiler cache statistics + if: ${{ always() && steps.ccache.outcome == 'success' }} + shell: bash + run: ccache -s -v || ccache -s