hashFiles fails with Unable to filepath.Walk: lstat /workspace/... #54
Labels
No labels
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: forgejo/runner#54
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Workaround
Description
silently succeeds and displays nothing. But in the log it always fails with
Unable to filepath.Walk: lstat /workspace/...
.Example
https://codeberg.org/Kbin/kbin-core/actions/runs/9
actions/cache#1 is about a similar error.
@rome-user do you confirm that it works for you with
forgejo-runner
? Can you provide a link to a working example? There may be a subtle difference that triggers this issue.I was able to run the workflow locally with.
I attached the logs of
exec
.The logs of the runner you're running locally would help figure out why it does not work in your environment.
Running action on PR: https://codeberg.org/Kbin/kbin-core/pulls/755.
I'm not running my runner locally. I'm using Ubuntu Server 22.04, which runs the
forgejo-runner
, with Docker installed. After I'm also running GitLab on the same server.@earl-warren See attachment for full log. Below a small snippet:
is causing the expression in
to evaluate to an empty string, hence the error message.
cache action: :error::Input required and not supplied: keyto expression that fail to evaluate are only logged server sideThis is a problem in
hashFiles()
I presume?Ps. I do use the official example from GitHub cache action readme file.
Ow I see.. by default your checkout location (part of checkout action) is not
/workspace
I think.. But something like/home/codeberg-runner/.cache
, right.But the cache action expects that working directory is
/workspace
for some reason?I think you're on the right track but that's unexpected: I would assume the evaluation happens with a current working directory that is the workspace. Is
**/yarn.lock
supposed to match./yarn.lock
as well? I can't remember right now.Can you share the
config.yaml
file that you have? If you have any.silently succeeds and displays nothing. But in the log it always fails with
Unable to filepath.Walk: lstat /workspace/...
. You are correct, it does not look where it should. The evaluation does not happen within the container and the workingdir is wrong. The problem goes back to 2.0.4 and maybe before, it is not new.It works when run with
docker exec
because the configuration is set differently.expression that fail to evaluate are only logged server sideto hashFiles fails with Unable to filepath.Walk: lstat /workspace/...Yes, I think so. The error is also more about the folder that doesn't exists (
/workspace/Kbin/kbin-core
according to the error).Sure, it's basically the default config. I can NOT upload files with
yaml
oryml
extension to your issue ticket system... So I changed the extension totxt
.. blehh.Also I see that the
~/.cache/act
folder is used for the cache and checkout actions:Then there is also a
~/.cache/actcache
, only containing a bolt.db file:You are using GitHub Actions (fork) actions. Which by default always use
/workspace
as working directory. Or on disk:/home/runner/work/
, I think.The
hashFiles
expression function is evaluated on the host where the runner resides. But it is given aWorkingDir
that only exists within the container running the job. It is the only use ofWorkingDir
when evaluating expressions.This bug went undetected because it fails in a way that shows as a success instead of a failure. The test that verifies it works claims it does when in reality it aborts and reports success.
Ow.. I see. But then again, Docker shouldn't be aware of the host location on disk. RIght? So the
hashFiles
expression should become Docker aware somehow and search the file within the check-out location inside Docker.If this works, I'm afraid what we might see after this step. Where will the cache be stored for Docker? After the run is completed, the docker container will be stopped/removed. So do we mount the cache folder inside docker, or?
I think it is reasonable to assume the
hashFiles
is evaluated relative to the workspace directory, which is known to the runner because it is mounted within the container by default and can be shared with other contains created by docker actions. I'm not sure I see how it should be implemented properly though.For now I'm afraid you'll need workaround to calculate the hash key. Such as introducing a step before to do that checksum and pass it to the next step.
The cache is stored on the host, that works.
Yup that works:
For others that might need this:
And then I use this:
That being said. I hope this
hashFiles
method can fixed in the future hopefully.I modified the description with @melroy89 workaround and @earl-warren description so others do not need to read the whole thread to figure that out.
Stumbled upon this.
I'm trying to run with
forgejo-runner exec
and hashFiles returns empty:Also, not sure if its related (if its not, I can create a new issue if its a bug):
If a file already exists in the working directory when running forgejo-runner, hashFiles works as expected. If the file has been created in the working directory along the workflow (even different steps) then it doesn't work.
I think that's because hashFiles is evaluated before the job starts running. There is non trivial work to do to implement hashFiles I'm afraid.
@earl-warren When reading the debug output, It writes that evaluates the expression on the time that it executes the step, but I haven't looked at the source to tell for sure. If it is the case I completely understand.
For now I've replaced with the solution mentioned above to use md5sum/sha256sum among the steps.
Using the workflow above:
What I thought it could be related if
hashFiles
isn't being called from the exactly same directory as the container mounts as volume, thus not "seeing" any file created by the steps before it.Hi, I tested actions/cache just now using
forgejo/runner:2.3.0
with rootless docker-in-docker. I can confirm that the issue I closed was not fixed by using forgejo runner.