Skip to content

Commit e15a7c4

Browse files
committed
move to services layer
1 parent f820e9b commit e15a7c4

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

routers/api/actions/runner/runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (s *Service) FetchTask(
156156
// if the task version in request is not equal to the version in db,
157157
// it means there may still be some tasks not be assgined.
158158
// try to pick a task for the runner that send the request.
159-
if t, ok, err := pickTask(ctx, runner); err != nil {
159+
if t, ok, err := actions_service.PickTask(ctx, runner); err != nil {
160160
log.Error("pick task failed: %v", err)
161161
return nil, status.Errorf(codes.Internal, "pick task: %v", err)
162162
} else if ok {

routers/api/actions/runner/utils.go renamed to services/actions/task.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Copyright 2022 The Gitea Authors. All rights reserved.
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
package runner
4+
package actions
55

66
import (
77
"context"
@@ -10,13 +10,12 @@ import (
1010
actions_model "code.gitea.io/gitea/models/actions"
1111
"code.gitea.io/gitea/models/db"
1212
secret_model "code.gitea.io/gitea/models/secret"
13-
actions_service "code.gitea.io/gitea/services/actions"
1413

1514
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
1615
"google.golang.org/protobuf/types/known/structpb"
1716
)
1817

19-
func pickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv1.Task, bool, error) {
18+
func PickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv1.Task, bool, error) {
2019
var (
2120
task *runnerv1.Task
2221
job *actions_model.ActionRunJob
@@ -74,26 +73,26 @@ func pickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv
7473
return nil, false, nil
7574
}
7675

77-
actions_service.CreateCommitStatus(ctx, job)
76+
CreateCommitStatus(ctx, job)
7877

7978
return task, true, nil
8079
}
8180

8281
func generateTaskContext(t *actions_model.ActionTask) (*structpb.Struct, error) {
83-
giteaRuntimeToken, err := actions_service.CreateAuthorizationToken(t.ID, t.Job.RunID, t.JobID)
82+
giteaRuntimeToken, err := CreateAuthorizationToken(t.ID, t.Job.RunID, t.JobID)
8483
if err != nil {
8584
return nil, err
8685
}
8786

88-
gitCtx := actions_service.GenerateGiteaContext(t.Job.Run, t.Job)
87+
gitCtx := GenerateGiteaContext(t.Job.Run, t.Job)
8988
gitCtx["token"] = t.Token
9089
gitCtx["gitea_runtime_token"] = giteaRuntimeToken
9190

9291
return structpb.NewStruct(gitCtx)
9392
}
9493

9594
func findTaskNeeds(ctx context.Context, taskJob *actions_model.ActionRunJob) (map[string]*runnerv1.TaskNeed, error) {
96-
taskNeeds, err := actions_service.FindTaskNeeds(ctx, taskJob)
95+
taskNeeds, err := FindTaskNeeds(ctx, taskJob)
9796
if err != nil {
9897
return nil, err
9998
}

0 commit comments

Comments
 (0)