8000 `!cache-hit` is `false` when `cache-hit` is `false` · Issue #1262 · actions/cache · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content 8000
!cache-hit is false when cache-hit is false #1262
Closed
@andreasabel

Description

@andreasabel

This is the workflow I caught red-handed: https://github.com/andreasabel/hasktorch/actions/runs/6536754694/job/17749144021

  1. Version: actions/cache@v3 SHA:704facf57e6136b1bc63b828d79edcd491f0ee84 https://github.com/andreasabel/hasktorch/actions/runs/6536754694/job/17749144021
  2. Cache restored from restore-key https://github.com/andreasabel/hasktorch/actions/runs/6536754694/job/17749144021#step:7:4
     Run actions/cache/restore@v3
     with:
       path: ~/.cabal/store
       key: macOS-cabal-3.6.2.0-ghc-9.2.8-plan-813f23bfbcb4c800c8178d743c3df6e501ec38580a651c180dcd99b0abc9319d
       restore-keys: macOS-cabal-3.6.2.0-ghc-9.2.8-
     ...
    Cache restored from key: macOS-cabal-3.6.2.0-ghc-9.2.8-813f23bfbcb4c800c8178d743c3df6e501ec38580a651c180dcd99b0abc9319d
    
    Note that this key is not the primary key, which has an additional -plan before the SHA.
  3. The step "Cache dependencies" (if: !steps.cache.outputs.cache-hit) is skipped", it's code is https://github.com/andreasabel/hasktorch/actions/runs/6536754694/workflow
     - name: Cache dependencies
       if:   ${{ !steps.cache.outputs.cache-hit }}
       uses: actions/cache/save@v3
       with:
         path: ~/.cabal/store
         key: ${{ steps.cache.outputs.cache-primary-key }}

According to the docs, outputs.cache-hit should not be true if the cache was restored with a fallback key.
This is stressed here:

cache/README.md

Lines 63 to 65 in 704facf

* `cache-hit` - A boolean value to indicate an exact match was found for the key.
> **Note** `cache-hit` will only be set to `true` when a cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`.

And again for the restore action:

cache/restore/README.md

Lines 15 to 22 in 704facf

### Outputs
* `cache-hit` - A boolean value to indicate an exact match was found for the key.
* `cache-primary-key` - Cache primary key passed in the input to use in subsequent steps of the workflow.
* `cache-matched-key` - Key of the cache that was restored, it could either be the primary key on cache-hit or a partial/complete match of one of the restore keys.
> **Note**
`cache-hit` will be set to `true` only when cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`.

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0