diff --git a/services/actions/job_parser.go b/modules/actions/job_parser.go similarity index 93% rename from services/actions/job_parser.go rename to modules/actions/job_parser.go index 8c880977d1..6360902b9a 100644 --- a/services/actions/job_parser.go +++ b/modules/actions/job_parser.go @@ -9,7 +9,7 @@ import ( "code.forgejo.org/forgejo/runner/v11/act/jobparser" ) -func jobParser(workflow []byte, options ...jobparser.ParseOption) ([]*jobparser.SingleWorkflow, error) { +func JobParser(workflow []byte, options ...jobparser.ParseOption) ([]*jobparser.SingleWorkflow, error) { singleWorkflows, err := jobparser.Parse(workflow, false, options...) if err != nil { return nil, err diff --git a/services/actions/job_parser_test.go b/modules/actions/job_parser_test.go similarity index 98% rename from services/actions/job_parser_test.go rename to modules/actions/job_parser_test.go index 9c1361d74e..82bce3da13 100644 --- a/services/actions/job_parser_test.go +++ b/modules/actions/job_parser_test.go @@ -200,7 +200,7 @@ jobs: }, } { t.Run(testCase.name, func(t *testing.T) { - sw, err := jobParser([]byte(testCase.workflow)) + sw, err := JobParser([]byte(testCase.workflow)) require.NoError(t, err) for i, sw := range sw { actual, err := sw.Marshal() diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index 2fc89e221d..e093643222 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -396,7 +396,7 @@ func handleWorkflows( Name: dwf.EntryName, }} } else { - jobs, err = jobParser(dwf.Content, jobparser.WithVars(vars)) + jobs, err = actions_module.JobParser(dwf.Content, jobparser.WithVars(vars)) if err != nil { log.Info("jobparser.Parse: invalid workflow, setting job status to failed: %v", err) tr := translation.NewLocale(input.Doer.Language) diff --git a/services/actions/schedule_tasks.go b/services/actions/schedule_tasks.go index e7dad2d948..dfaeaae59b 100644 --- a/services/actions/schedule_tasks.go +++ b/services/actions/schedule_tasks.go @@ -14,6 +14,7 @@ import ( "forgejo.org/models/db" repo_model "forgejo.org/models/repo" "forgejo.org/models/unit" + actions_module "forgejo.org/modules/actions" "forgejo.org/modules/log" "forgejo.org/modules/timeutil" webhook_module "forgejo.org/modules/webhook" @@ -168,7 +169,7 @@ func CreateScheduleTask(ctx context.Context, cron *actions_model.ActionSchedule) } // Parse the workflow specification from the cron schedule - workflows, err := jobParser(cron.Content, jobparser.WithVars(vars)) + workflows, err := actions_module.JobParser(cron.Content, jobparser.WithVars(vars)) if err != nil { return err } diff --git a/services/actions/workflows.go b/services/actions/workflows.go index 4c0a097452..1e4d92fa2f 100644 --- a/services/actions/workflows.go +++ b/services/actions/workflows.go @@ -155,7 +155,7 @@ func (entry *Workflow) Dispatch(ctx context.Context, inputGetter InputValueGette } } - jobs, err := jobParser(content, jobparser.WithVars(vars), jobparser.WithInputs(inputsAny)) + jobs, err := actions.JobParser(content, jobparser.WithVars(vars), jobparser.WithInputs(inputsAny)) if err != nil { return nil, nil, err }