mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-16 13:32:44 +00:00
ci: save the compiler cache from cancelled and failed builds too (#15668)
This commit is contained in:
@@ -106,6 +106,7 @@ jobs:
|
||||
job-summary: ''
|
||||
|
||||
- name: Restore compiler cache
|
||||
id: ccache_restore
|
||||
if: ${{ steps.ccache.outcome == 'success' }}
|
||||
uses: actions/cache/restore@v6
|
||||
with:
|
||||
@@ -724,31 +725,40 @@ jobs:
|
||||
asset_content_type: application/octet-stream
|
||||
max_releases: 1
|
||||
|
||||
# The build has just touched everything it can use, so an object
|
||||
# untouched for a week is dead, usually orphaned by a flag change.
|
||||
- name: Compiler cache statistics
|
||||
if: ${{ always() && steps.ccache.outcome == 'success' }}
|
||||
shell: bash
|
||||
run: ccache -s -v || ccache -s
|
||||
run: |
|
||||
ccache --evict-older-than 7d
|
||||
ccache -s -v || ccache -s
|
||||
|
||||
# Entries are immutable, so the new one is saved first and the older
|
||||
# ones for this leg on this ref are dropped afterwards: a failed save
|
||||
# leaves the previous entry in place.
|
||||
# leaves the previous entry in place. A cancelled or failed build saves
|
||||
# too, since what it compiled is still valid; a restore that did not
|
||||
# finish does not, since the directory may be a truncated copy.
|
||||
- name: Save compiler cache
|
||||
id: ccache_save
|
||||
if: ${{ steps.ccache.outcome == 'success' && github.event_name != 'pull_request' }}
|
||||
if: ${{ always() && steps.ccache_restore.outcome == 'success' && github.event_name != 'pull_request' }}
|
||||
uses: actions/cache/save@v6
|
||||
with:
|
||||
path: ${{ github.workspace }}/.ccache
|
||||
key: ${{ env.CCACHE_ENTRY }}
|
||||
|
||||
- name: Drop older compiler cache entries
|
||||
if: ${{ steps.ccache_save.outcome == 'success' }}
|
||||
if: ${{ always() && steps.ccache_save.outcome == 'success' }}
|
||||
# A read-only token (fork PRs) cannot delete; that only costs storage.
|
||||
# Older means a lower run id, so two runs finishing close together keep
|
||||
# the newer entry whichever of them cleans up last.
|
||||
continue-on-error: true
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
gh cache list --ref "$GITHUB_REF" --key "ccache-$CCACHE_LEG-" --limit 100 --json id,key \
|
||||
| jq -r --arg keep "$CCACHE_ENTRY" '.[] | select(.key != $keep) | .id' \
|
||||
| jq -r --arg prefix "ccache-$CCACHE_LEG-" --argjson run "$GITHUB_RUN_ID" \
|
||||
'.[] | select((.key | ltrimstr($prefix) | split("-")[0] | tonumber?) < $run) | .id' \
|
||||
| tr -d '\r' \
|
||||
| while read -r id; do gh cache delete "$id"; done
|
||||
|
||||
Reference in New Issue
Block a user