fix(ci): improve ccache persistence across builds
Some checks failed
Build and Test / build (pull_request) Has been cancelled
Some checks failed
Build and Test / build (pull_request) Has been cancelled
Use github.run_id for cache save keys so every build saves its accumulated ccache objects, instead of the previous date-based keys which froze the cache after the first save each day (cache-hit=true prevented re-saving). Restore keys still use branch/main prefixes for warm fallback. Also add ccache-build-main- fallback to release workflow so release builds can bootstrap from the latest main build cache.
This commit is contained in:
@@ -68,16 +68,12 @@ jobs:
|
||||
export PATH="$HOME/.pixi/bin:$PATH"
|
||||
pixi --version
|
||||
|
||||
- name: Compute cache date key
|
||||
id: cache-date
|
||||
run: echo "date=$(date -u +%Y%m%d)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Restore ccache
|
||||
id: ccache-restore
|
||||
uses: https://git.kindred-systems.com/actions/cache.git/restore@v4
|
||||
with:
|
||||
path: /tmp/ccache-kindred-create
|
||||
key: ccache-build-${{ github.ref_name }}-${{ steps.cache-date.outputs.date }}
|
||||
key: ccache-build-${{ github.ref_name }}-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
ccache-build-${{ github.ref_name }}-
|
||||
ccache-build-main-
|
||||
@@ -98,11 +94,11 @@ jobs:
|
||||
run: pixi run ccache -s
|
||||
|
||||
- name: Save ccache
|
||||
if: always() && steps.ccache-restore.outputs.cache-hit != 'true'
|
||||
if: always()
|
||||
uses: https://git.kindred-systems.com/actions/cache.git/save@v4
|
||||
with:
|
||||
path: /tmp/ccache-kindred-create
|
||||
key: ccache-build-${{ github.ref_name }}-${{ steps.cache-date.outputs.date }}
|
||||
key: ccache-build-${{ github.ref_name }}-${{ github.run_id }}
|
||||
|
||||
- name: Run C++ unit tests
|
||||
continue-on-error: true
|
||||
|
||||
@@ -78,18 +78,15 @@ jobs:
|
||||
export PATH="$HOME/.pixi/bin:$PATH"
|
||||
pixi --version
|
||||
|
||||
- name: Compute cache date key
|
||||
id: cache-date
|
||||
run: echo "date=$(date -u +%Y%m%d)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Restore ccache
|
||||
id: ccache-restore
|
||||
uses: https://git.kindred-systems.com/actions/cache.git/restore@v4
|
||||
with:
|
||||
path: /tmp/ccache-kindred-create
|
||||
key: ccache-release-linux-${{ steps.cache-date.outputs.date }}
|
||||
key: ccache-release-linux-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
ccache-release-linux-
|
||||
ccache-build-main-
|
||||
|
||||
- name: Prepare ccache
|
||||
run: |
|
||||
@@ -109,11 +106,11 @@ jobs:
|
||||
run: pixi run ccache -s
|
||||
|
||||
- name: Save ccache
|
||||
if: always() && steps.ccache-restore.outputs.cache-hit != 'true'
|
||||
if: always()
|
||||
uses: https://git.kindred-systems.com/actions/cache.git/save@v4
|
||||
with:
|
||||
path: /tmp/ccache-kindred-create
|
||||
key: ccache-release-linux-${{ steps.cache-date.outputs.date }}
|
||||
key: ccache-release-linux-${{ github.run_id }}
|
||||
|
||||
- name: Clean up intermediate build files
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user