From a1fc2b3ca73c68bf90c81532d42a302670de71ec Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Fri, 22 Mar 2024 02:30:31 +0000 Subject: [PATCH] Improve the explanation of `workdir_parent` config (#519) Fix #512 act_runner adds a '/' before the path (see https://gitea.com/gitea/act_runner/src/commit/5977042b86f22454d51c8027a009cb0a40337e52/internal/app/run/runner.go#L186) . So `workdir_parent` doesn't need to have the prefix '/'. If `workdir_parent` has the prefix '/', errors will occur when reading files from the job container. Reviewed-on: https://gitea.com/gitea/act_runner/pulls/519 Reviewed-by: Jason Song Co-authored-by: Zettat123 Co-committed-by: Zettat123 --- internal/app/run/runner.go | 2 +- internal/pkg/config/config.example.yaml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go index 5bf3672..35bca48 100644 --- a/internal/app/run/runner.go +++ b/internal/app/run/runner.go @@ -183,7 +183,7 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. runnerConfig := &runner.Config{ // On Linux, Workdir will be like "///" // On Windows, Workdir will be like "\\\" - Workdir: filepath.FromSlash(fmt.Sprintf("/%s/%s", r.cfg.Container.WorkdirParent, preset.Repository)), + Workdir: filepath.FromSlash(fmt.Sprintf("/%s/%s", strings.TrimLeft(r.cfg.Container.WorkdirParent, "/"), preset.Repository)), BindWorkdir: false, ActionCacheDir: filepath.FromSlash(r.cfg.Host.WorkdirParent), diff --git a/internal/pkg/config/config.example.yaml b/internal/pkg/config/config.example.yaml index 00b5fd1..a1b2985 100644 --- a/internal/pkg/config/config.example.yaml +++ b/internal/pkg/config/config.example.yaml @@ -63,6 +63,9 @@ container: # And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway). options: # The parent directory of a job's working directory. + # NOTE: There is no need to add the first '/' of the path as act_runner will add it automatically. + # If the path starts with '/', the '/' will be trimmed. + # For example, if the parent directory is /path/to/my/dir, workdir_parent should be path/to/my/dir # If it's empty, /workspace will be used. workdir_parent: # Volumes (including bind mounts) can be mounted to containers. Glob syntax is supported, see https://github.com/gobwas/glob