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 authored Oct 25, 2024
1 parent a927e1e commit 31c90a3
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 @@ -656,10 +656,11 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- 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 31c90a3

Please sign in to comment.