mirror of https://code.forgejo.org/forgejo/runner
Add runner name to log (#37)
User can get the name of the runner that executed the specified job. ![image](/attachments/61328f68-7223-4345-85c7-ac08781e81db) Co-authored-by: Zettat123 <zettat123@gmail.com> Reviewed-on: https://gitea.com/gitea/act_runner/pulls/37 Reviewed-by: Jason Song <i@wolfogre.com> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Zettat123 <zettat123@noreply.gitea.io> Co-committed-by: Zettat123 <zettat123@noreply.gitea.io>pull/2/head
parent
cbf360f543
commit
ba181d4a50
|
@ -2,3 +2,8 @@ act_runner
|
||||||
.env
|
.env
|
||||||
.runner
|
.runner
|
||||||
coverage.txt
|
coverage.txt
|
||||||
|
/gitea-vet
|
||||||
|
|
||||||
|
# MS VSCode
|
||||||
|
.vscode
|
||||||
|
__debug_bin
|
||||||
|
|
|
@ -65,6 +65,9 @@ func FromEnviron() (Config, error) {
|
||||||
if runner.UUID != "" {
|
if runner.UUID != "" {
|
||||||
cfg.Runner.UUID = runner.UUID
|
cfg.Runner.UUID = runner.UUID
|
||||||
}
|
}
|
||||||
|
if runner.Name != "" {
|
||||||
|
cfg.Runner.Name = runner.Name
|
||||||
|
}
|
||||||
if runner.Token != "" {
|
if runner.Token != "" {
|
||||||
cfg.Runner.Token = runner.Token
|
cfg.Runner.Token = runner.Token
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ func (s *Runner) Run(ctx context.Context, task *runnerv1.Task) error {
|
||||||
env[k] = v
|
env[k] = v
|
||||||
}
|
}
|
||||||
env["ACTIONS_CACHE_URL"] = s.CacheHandler.ExternalURL() + "/"
|
env["ACTIONS_CACHE_URL"] = s.CacheHandler.ExternalURL() + "/"
|
||||||
return NewTask(s.ForgeInstance, task.Id, s.Client, env, s.platformPicker).Run(ctx, task)
|
return NewTask(s.ForgeInstance, task.Id, s.Client, env, s.platformPicker).Run(ctx, task, s.Machine)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Runner) platformPicker(labels []string) string {
|
func (s *Runner) platformPicker(labels []string) string {
|
||||||
|
|
|
@ -112,7 +112,7 @@ func getToken(task *runnerv1.Task) string {
|
||||||
return token
|
return token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Run(ctx context.Context, task *runnerv1.Task) (lastErr error) {
|
func (t *Task) Run(ctx context.Context, task *runnerv1.Task, runnerName string) (lastErr error) {
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
_, exist := globalTaskMap.Load(task.Id)
|
_, exist := globalTaskMap.Load(task.Id)
|
||||||
|
@ -140,7 +140,7 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) (lastErr error) {
|
||||||
}()
|
}()
|
||||||
reporter.RunDaemon()
|
reporter.RunDaemon()
|
||||||
|
|
||||||
reporter.Logf("received task %v of job %v", task.Id, task.Context.Fields["job"].GetStringValue())
|
reporter.Logf("%s received task %v of job %v", runnerName, task.Id, task.Context.Fields["job"].GetStringValue())
|
||||||
|
|
||||||
workflowsPath, err := getWorkflowsPath(t.Input.repoDirectory)
|
workflowsPath, err := getWorkflowsPath(t.Input.repoDirectory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue