actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.39k stars 1.17k forks source link

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

Closed andreiz closed 2 months ago

andreiz commented 1 year ago

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
aparna-ravindra commented 9 months ago

@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

github-actions[bot] commented 3 months ago

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] commented 2 months ago

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