chore(refactor): move actions_service.jobParser to actions_module.jobParser

This commit is contained in:
Earl Warren 2025-10-28 20:14:35 +01:00
parent 7fccc2676b
commit 0989a2495e
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
5 changed files with 6 additions and 5 deletions

View file

@ -9,7 +9,7 @@ import (
"code.forgejo.org/forgejo/runner/v11/act/jobparser" "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...) singleWorkflows, err := jobparser.Parse(workflow, false, options...)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -200,7 +200,7 @@ jobs:
}, },
} { } {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
sw, err := jobParser([]byte(testCase.workflow)) sw, err := JobParser([]byte(testCase.workflow))
require.NoError(t, err) require.NoError(t, err)
for i, sw := range sw { for i, sw := range sw {
actual, err := sw.Marshal() actual, err := sw.Marshal()

View file

@ -396,7 +396,7 @@ func handleWorkflows(
Name: dwf.EntryName, Name: dwf.EntryName,
}} }}
} else { } else {
jobs, err = jobParser(dwf.Content, jobparser.WithVars(vars)) jobs, err = actions_module.JobParser(dwf.Content, jobparser.WithVars(vars))
if err != nil { if err != nil {
log.Info("jobparser.Parse: invalid workflow, setting job status to failed: %v", err) log.Info("jobparser.Parse: invalid workflow, setting job status to failed: %v", err)
tr := translation.NewLocale(input.Doer.Language) tr := translation.NewLocale(input.Doer.Language)

View file

@ -14,6 +14,7 @@ import (
"forgejo.org/models/db" "forgejo.org/models/db"
repo_model "forgejo.org/models/repo" repo_model "forgejo.org/models/repo"
"forgejo.org/models/unit" "forgejo.org/models/unit"
actions_module "forgejo.org/modules/actions"
"forgejo.org/modules/log" "forgejo.org/modules/log"
"forgejo.org/modules/timeutil" "forgejo.org/modules/timeutil"
webhook_module "forgejo.org/modules/webhook" 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 // 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 { if err != nil {
return err return err
} }

View file

@ -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 { if err != nil {
return nil, nil, err return nil, nil, err
} }