mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
fix(jobparser): support workflow_call.inputs
and workflow_call.outputs
(#70)
- Closes #69 - #45 - https://codeberg.org/forgejo/forgejo/issues/6069 Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/70 Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org> Co-authored-by: Michael Kriese <michael.kriese@visualon.de> Co-committed-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
parent
0e99df94b7
commit
54fead51c6
2 changed files with 23 additions and 2 deletions
|
@ -260,7 +260,7 @@ func ParseRawOn(rawOn *yaml.Node) ([]*Event, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
if k != "workflow_dispatch" || act != "inputs" {
|
if isInvalidOnType(k, act) {
|
||||||
return nil, fmt.Errorf("unknown on type: %#v", v)
|
return nil, fmt.Errorf("unknown on type: %#v", v)
|
||||||
}
|
}
|
||||||
acts = nil
|
acts = nil
|
||||||
|
@ -304,6 +304,16 @@ func ParseRawOn(rawOn *yaml.Node) ([]*Event, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isInvalidOnType(onType, subKey string) bool {
|
||||||
|
if onType == "workflow_dispatch" && subKey == "inputs" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if onType == "workflow_call" && (subKey == "inputs" || subKey == "outputs") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// parseMappingNode parse a mapping node and preserve order.
|
// parseMappingNode parse a mapping node and preserve order.
|
||||||
func parseMappingNode[T any](node *yaml.Node) ([]string, []T, error) {
|
func parseMappingNode[T any](node *yaml.Node) ([]string, []T, error) {
|
||||||
if node.Kind != yaml.MappingNode {
|
if node.Kind != yaml.MappingNode {
|
||||||
|
|
|
@ -163,7 +163,7 @@ func TestParseRawOn(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: "on: [pull_request, workflow_dispatch]",
|
input: "on: [pull_request, workflow_dispatch, workflow_call]",
|
||||||
result: []*Event{
|
result: []*Event{
|
||||||
{
|
{
|
||||||
Name: "pull_request",
|
Name: "pull_request",
|
||||||
|
@ -171,6 +171,9 @@ func TestParseRawOn(t *testing.T) {
|
||||||
{
|
{
|
||||||
Name: "workflow_dispatch",
|
Name: "workflow_dispatch",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "workflow_call",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -194,6 +197,14 @@ func TestParseRawOn(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: "on:\n workflow_call:\n inputs:\n test:\n type: string\n outputs:\n output:\n value: something",
|
||||||
|
result: []*Event{
|
||||||
|
{
|
||||||
|
Name: "workflow_call",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, kase := range kases {
|
for _, kase := range kases {
|
||||||
t.Run(kase.input, func(t *testing.T) {
|
t.Run(kase.input, func(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue