reproducible-containers / buildkit-cache-dance

Save `RUN --mount=type=cache` caches on GitHub Actions ( Forked from https://github.com/overmindtech/buildkit-cache-dance )
Apache License 2.0
98 stars 25 forks source link

scratch/buildstamp: No such file or directory #23

Closed mattsmitton closed 1 month ago

mattsmitton commented 3 months ago

I'm running into this in the post inject step, and I'm not sure how to resolve it:

Post job cleanup.
+ : 'Argv0: /home/runner/work/_actions/reproducible-containers/buildkit-cache-dance/v2.1.4/post'
++ dirname /home/runner/work/_actions/reproducible-containers/buildkit-cache-dance/v2.1.4/post
+ dir=/home/runner/work/_actions/reproducible-containers/buildkit-cache-dance/v2.1.4
++ read_action_input skip-extraction
++ /home/runner/work/_actions/reproducible-containers/buildkit-cache-dance/v2.1.4/read-action-input skip-extraction
+ '[' '' == true ']'
+ : 'Prepare Timestamp for Layer Cache Busting'
+ date --iso=ns
++ read_action_input scratch-dir
++ /home/runner/work/_actions/reproducible-containers/buildkit-cache-dance/v2.1.4/read-action-input scratch-dir
+ tee scratch/buildstamp
tee: scratch/buildstamp: No such file or directory
2024-03-16T01:00:08,006374192+00:00
AkihiroSuda commented 3 months ago

Is this a recent regression?

strophy commented 2 months ago

I'm getting this error with the latest v3.1.0 release as well. Config as follows:

      - name: Restore cache
        id: cache
        uses: actions/cache@v4
        with:
          path: |
            build-cache
          key: go-cache-multiarch-${{ hashFiles('go.mod') }}
          restore-keys: |
            go-cache-multiarch-

      - name: Inject cache into docker context
        uses: reproducible-containers/buildkit-cache-dance@v3.1.0
        with:
          cache-map: |
            {
              "build-cache": {
                "target": "/root/.cache/go-build",
                "id": "build-cache"
              }
            }
          skip-extraction: ${{ steps.cache.outputs.cache-hit }}

The action runs fine on my feature-branch, but then when I merge the branch to dev there is a cache miss (due to GitHub cache visibility rules I think):

Cache not found for input keys: go-cache-multiarch-1c9220f278e78c636a60a059136898eb74c5de57b1c39459eefd518ccbaecb45, go-cache-multiarch-

FROM busybox:1
COPY buildstamp buildstamp
RUN --mount=type=cache,target=/root/.cache/go-build,id=build-cache     --mount=type=bind,source=.,target=/var/dance-cache     cp -p -R /var/dance-cache/. /root/.cache/go-build || true

The action workflow runs and does a full build, but fails in the post step:

Post job cleanup.
[Error: ENOENT: no such file or directory, open 'scratch/buildstamp'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'scratch/buildstamp'
}
Error: ENOENT: no such file or directory, open 'scratch/buildstamp'