Skip to content

Commit

Permalink
[CI] skip installation step when cache hit (#1978)
Browse files Browse the repository at this point in the history
* [ci] fix, showing cache hit, re-install dependencies

* [ci] fix ci workflow to check the cache-hit output and add restore-key for wider cache range
  • Loading branch information
dacozai committed Feb 25, 2025
1 parent fb00e98 commit 229063f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@

name: Cache
description: 'Caches cargo dependencies'
outputs:
cache-hit:
description: "Cache Hit"
value: ${{ steps.cache.outputs.cache-hit }}
runs:
using: composite
steps:
- uses: actions/cache@v4
id: cache
with:
path: |
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,11 @@ jobs:
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1

- name: Populate cache
- id: populate-cache
uses: ./.github/actions/cache

- name: Download dependencies
if: steps.populate-cache.outputs.cache-hit != 'true'
run: |
# Ensure all dependencies are downloaded - both for our crates and for
# tools we use in CI. We don't care about these tools succeeding for
Expand Down

0 comments on commit 229063f

Please sign in to comment.