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
This commit is contained in:
forbes
2026-01-31 20:21:42 -06:00
parent b7fdccc99a
commit 7bad1b787f
2 changed files with 61 additions and 4 deletions

View File

@@ -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

View File

@@ -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