mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-22 06:45:03 +01:00
fix: use the happy path for workflow_call (#88)
* not really supported mode
This commit is contained in:
31
cmd/root.go
31
cmd/root.go
@@ -663,7 +663,36 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
|
||||
}
|
||||
}
|
||||
|
||||
r, err := runner.New(config)
|
||||
var r runner.Runner
|
||||
if eventName == "workflow_call" {
|
||||
// Do not use the totally broken code and instead craft a fake caller
|
||||
convertedInputs := make(map[string]interface{})
|
||||
for k, v := range inputs {
|
||||
var raw interface{}
|
||||
if err := yaml.Unmarshal([]byte(v), &raw); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal input %s: %w", k, err)
|
||||
}
|
||||
convertedInputs[k] = raw
|
||||
}
|
||||
r, err = runner.NewReusableWorkflowRunner(&runner.RunContext{
|
||||
Config: config,
|
||||
Name: "_",
|
||||
JobName: "_",
|
||||
Run: &model.Run{
|
||||
JobID: "_",
|
||||
Workflow: &model.Workflow{
|
||||
Jobs: map[string]*model.Job{
|
||||
"_": {
|
||||
Name: "_",
|
||||
With: convertedInputs,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
} else {
|
||||
r, err = runner.New(config)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -82,3 +82,14 @@ func TestFlags(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkflowCall(t *testing.T) {
|
||||
rootCmd := createRootCommand(context.Background(), &Input{}, "")
|
||||
err := newRunCommand(context.Background(), &Input{
|
||||
platforms: []string{"ubuntu-latest=node:16-buster-slim"},
|
||||
workdir: "../pkg/runner/testdata/",
|
||||
workflowsPath: "./workflow_call_inputs/workflow_call_inputs.yml",
|
||||
inputs: []string{"required=required input", "boolean=true"},
|
||||
})(rootCmd, []string{"workflow_call"})
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user