Skip to content

Commit

Permalink
Save cache if miss rate was 100
Browse files Browse the repository at this point in the history
  • Loading branch information
kuznetsss committed Dec 8, 2023
1 parent 8bd8d28 commit 6da26ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/actions/save_cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ inputs:
ccache_cache_hit:
description: Whether conan cache has been downloaded
required: true
ccache_cache_miss_rate:
description: How many cache misses happened
runs:
using: composite
steps:
Expand All @@ -37,7 +39,7 @@ runs:
key: clio-conan_data-${{ runner.os }}-develop-${{ inputs.conan_hash }}

- name: Save ccache cache
if: ${{ inputs.ccache_cache_hit != 'true' }}
if: ${{ inputs.ccache_cache_hit != 'true' || inputs.ccache_cache_miss_rate == '100.0' }}
uses: actions/cache/save@v3
with:
path: ${{ inputs.ccache_dir }}
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ jobs:
uses: ./.github/actions/build_clio

- name: Show ccache's statistics
run: ccache -s
shell: bash
id: ccache_stats
run: |
ccache -s > /tmp/ccache.stats
miss_rate=$(cat /tmp/ccache.stats | grep 'Misses' | head -n1 | sed 's/.*(\(.*\)%).*/\1/')
echo "miss_rate=${miss_rate}" >> $GITHUB_OUTPUT
cat /tmp/ccache.stats
- name: Strip tests
run: strip build/clio_tests
Expand All @@ -83,6 +89,7 @@ jobs:
conan_cache_hit: ${{ steps.restore_cache.outputs.conan_cache_hit }}
ccache_dir: ${{ env.CCACHE_DIR }}
ccache_cache_hit: ${{ steps.restore_cache.outputs.ccache_cache_hit }}
ccache_cache_miss_rate: ${{ steps.ccache_stats.outputs.miss_rate }}

test:
needs: build
Expand Down

0 comments on commit 6da26ed

Please sign in to comment.