meltwater / drone-cache

A Drone plugin for caching current workspace files between builds to reduce your build times
https://underthehood.meltwater.com/blog/2019/04/10/making-drone-builds-10-times-faster/
Apache License 2.0
338 stars 81 forks source link

Caching absolute directory #241

Open sdarwin opened 1 year ago

sdarwin commented 1 year ago

Describe the bug

It's possible that I am just making a stupid mistake, but here is a description of the problem. Trying to cache a directory that is outside the main source folder using an absolute path.

The workspace is "/drone/src".
Configure the drone-cache mount to be "/drone/cache".

Near the end of the build process, run "ls -al /drone" to observe the directory contents.

 ls -al /drone
total 16
drwxr-xr-x  4 root root 4096 Mar 14 16:26 .
drwxr-xr-x  1 root root 4096 Mar 14 16:25 ..
drwxr-xr-x 12 root root 4096 Mar 14 16:27 cache
drwxr-xr-x 17 root root 4096 Mar 14 16:26 src

So, everything seems to be in place. The final step in the drone pipeline is to run rebuild:

      "name": "rebuild-cache",
      "image": "meltwater/drone-cache",
      "mount": mountpoints
      ... 

mountpoints is a variable that in this case should be ["/drone/cache"]).
Archive format isn't specified, so it's using the default (tar).
The final output of the rebuild shows an error that the directory doesn't exist.

level=error name=drone-cache ts=2023-03-14T16:27:20.348382792Z caller=main.go:628 err="[IMPORTANT] build cache, source </drone/cache>, make sure file or directory exists and readable, lstat /drone/cache: no such file or directory\n"

Expected behavior /drone/cache can be cached and restored correctly.

Should it be working? and are there currently test cases in CI which test the absolute path feature?