1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

fix: allow overriding RUNNER_TOOL_CACHE from the config file (#178)

- rc.getToolCache(ctx) is used to figure out RUNNER_TOOL_CACHE and  returns RUNNER_TOOL_CACHE if it is found in the runner config, e.g.
  ```yaml
  container:
    env:
	  RUNNER_TOOL_CACHE: /srv/toolcache
  ```
- store the value in the new `toolCache` data member for containers,  in the same way it is done for host
- GetRunnerContext for containers return `toolCache` instead of a  hard coded string
- add integration test

Closes forgejo/runner#184

Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/178
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-07-13 21:55:02 +00:00 committed by earl-warren
parent d2f668c880
commit 6620cc1d18
9 changed files with 39 additions and 9 deletions

View file

@ -10,7 +10,9 @@ import (
log "github.com/sirupsen/logrus"
)
type LinuxContainerEnvironmentExtensions struct{}
type LinuxContainerEnvironmentExtensions struct {
toolCache string
}
// Resolves the equivalent host path inside the container
// This is required for windows and WSL 2 to translate things like C:\Users\Myproject to /mnt/users/Myproject
@ -74,12 +76,12 @@ func (*LinuxContainerEnvironmentExtensions) JoinPathVariable(paths ...string) st
return strings.Join(paths, ":")
}
func (*LinuxContainerEnvironmentExtensions) GetRunnerContext(ctx context.Context) map[string]interface{} {
func (l *LinuxContainerEnvironmentExtensions) GetRunnerContext(ctx context.Context) map[string]interface{} {
return map[string]interface{}{
"os": "Linux",
"arch": RunnerArch(ctx),
"temp": "/tmp",
"tool_cache": "/opt/hostedtoolcache",
"tool_cache": l.toolCache,
}
}