cache icon indicating copy to clipboard operation
cache copied to clipboard

Cache restored on exact key, but cache-hit is false

Open andreiz opened this issue 2 years ago • 2 comments

I am caching the build directory of swift-format. The cache is being restored successfully on the exact key, but the cache-hit variable seems being set to false. Is the code wrong or is there a bug in the action?

      - name: Create swift-format build cache
        id: cache-swift-format
        uses: actions/cache@v3
        with:
          path: .build
          key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
          restore-keys: |
            ${{ runner.os }}-spm-

      - name: build swift-format
        if: steps.cache-swift-format.outputs.cache-hit != 'true'
        run: |
          git clone https://github.com/apple/swift-format.git
          cd swift-format
          swift build --disable-sandbox -c release
          mv .build ..

The output from the latest job:

image

andreiz avatar Jul 24 '23 19:07 andreiz

@andreiz , When the workflow is running for a PR, it can restore cache from the main branch. However, cache hit will be false in this case. There are a couple of more cases mentioned here : https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key

aparna-ravindra avatar Oct 10 '23 05:10 aparna-ravindra

This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days.

github-actions[bot] avatar Apr 27 '24 08:04 github-actions[bot]

This issue was closed because it has been inactive for 5 days since being marked as stale.

github-actions[bot] avatar May 02 '24 08:05 github-actions[bot]