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

Cache restore fails after injection while trying to clean up #26

Closed strophy closed 2 months ago

strophy commented 2 months ago

I'm trying to update to v3 of this action (thanks again @aminya) on a small repo handling Go builds. The cache is successfully created on the first run, but fails on restore during the second run with the following error:

Run reproducible-containers/buildkit-cache-dance@v3
  with:
    cache-map: {
    "cache-go-build": "/root/.cache/go-build",
    "go-pkg-mod": "/go/pkg/mod"
  }

    skip-extraction: true
    scratch-dir: scratch
FROM busybox:1
COPY buildstamp buildstamp
RUN --mount=type=cache,target=/root/.cache/go-build     --mount=type=bind,source=.,target=/var/dance-cache     cp -p -R /var/dance-cache/. /root/.cache/go-build || true
FROM busybox:1
COPY buildstamp buildstamp
RUN --mount=type=cache,target=/go/pkg/mod     --mount=type=bind,source=.,target=/var/dance-cache     cp -p -R /var/dance-cache/. /go/pkg/mod || true
[Error: EACCES: permission denied, rmdir 'go-pkg-mod/go.uber.org/atomic@v1.7.0/internal'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'rmdir',
  path: 'go-pkg-mod/go.uber.org/atomic@v1.7.0/internal'
}
Error: EACCES: permission denied, rmdir 'go-pkg-mod/go.uber.org/atomic@v1.7.0/internal'

Maybe we need to sync/flush the filesystem first before delete is possible? Why is it necessary to do this cleanup step, maybe we could just continue without deleting the source dir?

aminya commented 2 months ago

It is failing on this line: https://github.com/reproducible-containers/buildkit-cache-dance/blob/0fc239dcc207d7ce9fd659f4f92fefb84549c182/src/inject-cache.ts#L33

Do you know why the permission is denied? Do you have any special permissions set up? Technically, we can ignore the errors of this line failing because it's just a clean-up and not critical.