setup-java download jdk binary again every time due to not cache tool folder #70

Open
opened 2023-03-23 13:42:54 +00:00 by seepine · 3 comments

And github runner can cache container toolcache folder
https://github.com/actions/setup-java/issues/470#issuecomment-1480814653

And github runner can cache container `toolcache` folder https://github.com/actions/setup-java/issues/470#issuecomment-1480814653
wolfogre added the
kind
bug
label 2023-03-24 01:39:40 +00:00
Collaborator

The runner mounts the act-toolcache volume to /toolcache directory (See 342ad6a51a/pkg/runner/run_context.go (L108))

In my test, the files created by a task will remain in the volume even after the task has finished. If I rerun the task, the file will still be there. The workflow is like:

jobs:
  write-test:
    runs-on: ubuntu-latest
    steps:
      - name: Write
        run: 'echo $GITHUB_SHA >> /toolcache/sha.txt'

      - name: Read
        run: 'cat /toolcache/sha.txt'

I also test thesetup-java action. But it is strange that the setup-java action doesn't seem to write data to the /toolcache directory. I'll test other actions to check if they cache files there.

The runner mounts the `act-toolcache` volume to `/toolcache` directory (See https://gitea.com/gitea/act/src/commit/342ad6a51a1a25b6f3c6e75df3f36efc3806e7e7/pkg/runner/run_context.go#L108) In my test, the files created by a task will remain in the volume even after the task has finished. If I rerun the task, the file will still be there. The workflow is like: ``` yml jobs: write-test: runs-on: ubuntu-latest steps: - name: Write run: 'echo $GITHUB_SHA >> /toolcache/sha.txt' - name: Read run: 'cat /toolcache/sha.txt' ``` I also test the`setup-java` action. But it is strange that the `setup-java` action doesn't seem to write data to the `/toolcache` directory. I'll test other actions to check if they cache files there.
Collaborator

At present, the act-toolcache volume is mounted to /toolcache and the data in /toolcache will be stored persistently. But the problem is that actions don't write data to /toolcache but to /opt/hostedtoolcache (specified by the RUNNER_TOOL_CACHE env, see cfedc518ca/pkg/runner/run_context.go (L236))

Maybe we need to support users to configure the volumes that will be mounted to RUNNER_TOOL_CACHE. Now there is a workaround: set the RUNNER_TOOL_CACHE env manually in the workflow, like this:

jobs:
  build:
    env:
      RUNNER_TOOL_CACHE: /toolcache
...
At present, the `act-toolcache` volume is mounted to `/toolcache` and the data in `/toolcache` will be stored persistently. But the problem is that actions don't write data to `/toolcache` but to `/opt/hostedtoolcache` (specified by the `RUNNER_TOOL_CACHE` env, see https://gitea.com/gitea/act/src/commit/cfedc518ca02fd1aa395ad028a1b369f1ce2e5ed/pkg/runner/run_context.go#L236) Maybe we need to support users to configure the volumes that will be mounted to `RUNNER_TOOL_CACHE`. Now there is a workaround: set the `RUNNER_TOOL_CACHE` env manually in the workflow, like this: ``` yml jobs: build: env: RUNNER_TOOL_CACHE: /toolcache ... ```
Collaborator

My test:

First run (no cache):
7ebc385d5e97c2d5578bfd771be458d

Second run (get from cache):
2c358151b2402ec11879f7782f404f1

act-toolcache volume:
image

My test: First run (no cache): ![7ebc385d5e97c2d5578bfd771be458d](/attachments/c8304749-6288-4120-acd9-fd5b77bf70a6) Second run (get from cache): ![2c358151b2402ec11879f7782f404f1](/attachments/92ffed6f-9374-450b-b607-648d71ce8358) `act-toolcache` volume: ![image](/attachments/727bd5ce-47ad-45d1-9c0b-64b8ca05c349)
Sign in to join this conversation.
There is no content yet.