Skip to content

Commit

Permalink
Fix ccache handling
Browse files Browse the repository at this point in the history
Goal: Accumulate ccache for builds on a specific distro and architecture
Problem: Cannot overwrite existing cache. Need to manually delete it beforehand.
  • Loading branch information
rhaschke committed Oct 22, 2024
1 parent 339a808 commit 4ef104c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,15 @@ jobs:
name: debs
path: ${{ env.DEBS_PATH }}

- name: Determine CCACHE_ID
id: ccache-id
run: echo "CCACHE_ID=ccache-${DEB_DISTRO}-$(dpkg --print-architecture)-${ROS_SOURCES}" | tee -a "$GITHUB_OUTPUT"
- name: Restore ccache
id: restore-ccache
uses: actions/cache/restore@v4
env:
CCACHE_ID: "ccache-${{ inputs.DEB_DISTRO || vars.DEB_DISTRO }}-${{ inputs.ROS_SOURCES || vars.ROS_SOURCES }}"
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ env.CCACHE_ID }}-${{ github.run_id }}
restore-keys: |
${{ env.CCACHE_ID }}
key: ${{ steps.ccache-id.outputs.CCACHE_ID }}

- name: Build .deb packages
uses: ubi-agni/ros-builder-action@main
Expand All @@ -181,6 +180,12 @@ jobs:
if: always() # always prepare files for upload
run: find ${{ env.DEBS_PATH }} -name '*[<>:"\\|?*]*' -print -delete

- name: Delete old ccache
if: always() && steps.restore-ccache.outputs.cache-hit
continue-on-error: true
run: gh cache delete "${{ steps.restore-ccache.outputs.cache-primary-key }}"
env:
GH_TOKEN: ${{ github.token }}
- name: Store ccache
uses: actions/cache/save@v4
if: always() # save cache on timeout or cancel too
Expand Down

0 comments on commit 4ef104c

Please sign in to comment.