0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-10-16 16:54:33 -04:00

Refactor ActionRunJob parsing into a reusable function (#35623)

Use a helper method around the jobparser for parsing a single job
structure from an ActionRunJob

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
ChristopherHX
2025-10-11 21:58:36 +02:00
committed by GitHub
parent b029ad431b
commit 25c4eb1659
4 changed files with 27 additions and 19 deletions

View File

@@ -21,7 +21,6 @@ import (
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
lru "github.com/hashicorp/golang-lru/v2"
"github.com/nektos/act/pkg/jobparser"
"google.golang.org/protobuf/types/known/timestamppb"
"xorm.io/builder"
)
@@ -278,13 +277,10 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
return nil, false, err
}
parsedWorkflows, err := jobparser.Parse(job.WorkflowPayload)
workflowJob, err := job.ParseJob()
if err != nil {
return nil, false, fmt.Errorf("parse workflow of job %d: %w", job.ID, err)
} else if len(parsedWorkflows) != 1 {
return nil, false, fmt.Errorf("workflow of job %d: not single workflow", job.ID)
return nil, false, fmt.Errorf("load job %d: %w", job.ID, err)
}
_, workflowJob := parsedWorkflows[0].Job()
if _, err := e.Insert(task); err != nil {
return nil, false, err