From 7bad1b787ff1991e852476c5515ade16a785f9fd Mon Sep 17 00:00:00 2001 From: forbes Date: Sat, 31 Jan 2026 20:21:42 -0600 Subject: [PATCH] ci: add ccache persistence via actions/cache for build and release workflows - Move CCACHE_DIR inside workspace for actions/cache compatibility - Add CCACHE_BASEDIR for portable cache entries across workspaces - Add cache restore step with fallback keys (branch -> main) - Add cache save step (runs even on test/packaging failure) - Enhance ccache diagnostics with pre/post build stats and cache size - Release builds fall back to main branch build cache for warm starts --- .gitea/workflows/build.yml | 32 ++++++++++++++++++++++++++++++-- .gitea/workflows/release.yml | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 4265b59650..43d7c6df5f 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -13,11 +13,12 @@ jobs: runs-on: app-builder env: - CCACHE_DIR: ${{ github.workspace }}/../.ccache-kindred-create + CCACHE_DIR: ${{ github.workspace }}/.ccache CCACHE_COMPRESS: "true" CCACHE_COMPRESSLEVEL: "6" CCACHE_MAXSIZE: "4G" CCACHE_SLOPPINESS: "include_file_ctime,include_file_mtime,pch_defines,time_macros" + CCACHE_BASEDIR: ${{ github.workspace }} steps: - name: Trust FreeIPA CA certificate @@ -64,12 +65,26 @@ jobs: fi pixi --version + - name: Restore ccache + id: ccache-restore + uses: https://github.com/actions/cache/restore@v4 + with: + path: ${{ github.workspace }}/.ccache + key: ccache-build-${{ github.ref_name }}-${{ github.sha }} + restore-keys: | + ccache-build-${{ github.ref_name }}- + ccache-build-main- + - name: Prepare ccache shell: bash run: | mkdir -p $CCACHE_DIR pixi run ccache -z + echo "=== ccache configuration ===" pixi run ccache -p + echo "" + echo "=== ccache status before build ===" + pixi run ccache -s - name: Configure (CMake) shell: bash @@ -80,7 +95,20 @@ jobs: run: pixi run cmake --build build/release -j$(nproc) - name: Show ccache statistics - run: pixi run ccache -s + shell: bash + run: | + echo "=== ccache statistics after build ===" + pixi run ccache -s + echo "" + echo "=== ccache cache directory size ===" + du -sh $CCACHE_DIR + + - name: Save ccache + if: always() + uses: https://github.com/actions/cache/save@v4 + with: + path: ${{ github.workspace }}/.ccache + key: ccache-build-${{ github.ref_name }}-${{ github.sha }} - name: Run C++ unit tests shell: bash diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index e5de16aa2a..72792bd6a9 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -16,11 +16,12 @@ jobs: runs-on: app-builder env: - CCACHE_DIR: ${{ github.workspace }}/../.ccache-kindred-create + CCACHE_DIR: ${{ github.workspace }}/.ccache CCACHE_COMPRESS: "true" CCACHE_COMPRESSLEVEL: "6" CCACHE_MAXSIZE: "4G" CCACHE_SLOPPINESS: "include_file_ctime,include_file_mtime,pch_defines,time_macros" + CCACHE_BASEDIR: ${{ github.workspace }} BUILD_TAG: ${{ github.ref_name || inputs.tag }} MAKE_INSTALLER: "true" CFLAGS: "-O3" @@ -72,11 +73,26 @@ jobs: fi pixi --version + - name: Restore ccache + id: ccache-restore + uses: https://github.com/actions/cache/restore@v4 + with: + path: ${{ github.workspace }}/.ccache + key: ccache-release-${{ github.ref_name }}-${{ github.sha }} + restore-keys: | + ccache-release- + ccache-build-main- + - name: Prepare ccache shell: bash run: | mkdir -p $CCACHE_DIR pixi run ccache -z + echo "=== ccache configuration ===" + pixi run ccache -p + echo "" + echo "=== ccache status before build ===" + pixi run ccache -s - name: Write version info run: python3 package/scripts/write_version_info.py ../freecad_version.txt @@ -88,7 +104,20 @@ jobs: pixi run -e package create_bundle - name: Show ccache statistics - run: pixi run ccache -s + shell: bash + run: | + echo "=== ccache statistics after build ===" + pixi run ccache -s + echo "" + echo "=== ccache cache directory size ===" + du -sh $CCACHE_DIR + + - name: Save ccache + if: always() + uses: https://github.com/actions/cache/save@v4 + with: + path: ${{ github.workspace }}/.ccache + key: ccache-release-${{ github.ref_name }}-${{ github.sha }} - name: Build .deb package shell: bash