diff --git a/docs/checks.md b/docs/checks.md index ccf82ad8d..219c603f9 100644 --- a/docs/checks.md +++ b/docs/checks.md @@ -1965,9 +1965,6 @@ jobs: runs-on: ubuntu-latest steps: - run: echo "${{ inputs.scheme }}://${{ inputs.host }}:${{ inputs.port }}${{ inputs.path }}" - nested: - # ERROR: Nested workflow call is not allowed - uses: onwer/repo/w.yml@main ``` Output: @@ -1989,21 +1986,13 @@ test.yaml:26:18: input "path" of workflow_call event has the default value "", b | 26 | default: '' | ^~ -test.yaml:35:11: reusable workflow cannot be nested. but this workflow hooks "workflow_call" event at line:2,col:3 [workflow-call] - | -35 | uses: onwer/repo/w.yml@main - | ^~~~~~~~~~~~~~~~~~~~~ ``` -[Playground](https://rhysd.github.io/actionlint#eJx9kc1ugzAQhO99ilVUKSdA/Tn51AfooT/quTKwFBLjdey1KIp499pAIkRLb/CtPTPeIS1uADqyx0pR91lIpSIAaLTx7KZvAFfU2OLlD6BEV9jGcENawPs4BKrg4+15caSSXrGAmtm4K+beoADHttFfM6zJsfh9D79laxSmBbX/3TZkeSPYSxhtxtqLu/uHx/1KWvs2RzvDk0fbb2i/xtlafNKg/IAFX+JJrrfihdFaweLJNxZLAWw9/pF6HXjexYHysaySJjPrtUuiic+9Zp8oyeimTI7RXItN4smw66Im2N2ez3Pv6VQ4DIPIsgWOVUW4QHH/AS1JfNcw7IKFDqbhMaOZd+jCcnSHNrNoKOvSvlVPrWz0D3BGvIY=) -[Playground]() +[Playground](https://rhysd.github.io/actionlint#eJx9kctuwyAQRff9ilFUKSsn6mPFN3TRh7quMB4XUswQGJRGkf+9JjiR5dbdwZnhzmUuOXEDcKDw1Vo6fChpbQYAxvnEsZwBotLY4eUG0GBUwXg25AS8nYtALby/Pk1aWpksC9DMPl4xHz0KiByM+xyhpsji9zv8lp23uFHU/ffaU+AFY89DadHWWtzdPzyuZ9IudTWGEe4ThuOC9kuuzcWLBtU7VHyxJ1kv2RtKc4WA+2QCNgI4JPzD9dzwuIsd1eewGirDQnKxykNSnRynykrGWDxFRn8Ntsqdw66VJljdnk5j7psSOPS92G4nOEeV4QTl/Q9oSvK/+n71A7U5rsA=) Unlike inputs of action, inputs of a workflow must specify their types. actionlint validates input types and checks the default values are correctly typed. For more details, see [the official document][create-reusable-workflow-doc]. -In addition, nested workflow call is not allowed. actionlint checks reusable workflow is not called when the workflow hooks -`workflow_call` event. - ### Check reusable workflow call syntax Example input: diff --git a/rule_expression.go b/rule_expression.go index 0bb9a224d..c09d729aa 100644 --- a/rule_expression.go +++ b/rule_expression.go @@ -922,8 +922,6 @@ func (rule *RuleExpression) checkWorkflowCallOutputs(outputs map[*String]*Workfl var o *ObjectType if j.WorkflowCall != nil { // Outputs are not defined in jobs. section when it is reusable workflow call. - // At the point of writing this comment, reusable workflow cannot be nested. So reaching - // here would cause other error in some other checks. o = NewEmptyObjectType() } else { p := make(map[string]ExprType, len(j.Outputs)) diff --git a/rule_workflow_call.go b/rule_workflow_call.go index 3d9794bc4..f996aec2b 100644 --- a/rule_workflow_call.go +++ b/rule_workflow_call.go @@ -40,10 +40,6 @@ func (rule *RuleWorkflowCall) VisitJobPre(n *Job) error { return nil } - if rule.workflowCallEventPos != nil { - rule.errorf(u.Pos, "reusable workflow cannot be nested. but this workflow hooks \"workflow_call\" event at %s", rule.workflowCallEventPos) - } - if !strings.Contains(u.Value, "${{") && !(checkWorkflowCallUsesLocalFormat(u.Value) || checkWorkflowCallUsesRepoFormat(u.Value)) { rule.errorf(u.Pos, "reusable workflow call %q at \"uses\" is not following the format \"owner/repo/path/to/workflow.yml@ref\" nor \"./path/to/workflow.yml\". see https://docs.github.com/en/actions/learn-github-actions/reusing-workflows for more details", u.Value) } diff --git a/rule_workflow_call_test.go b/rule_workflow_call_test.go index 2d315fbbe..016b15697 100644 --- a/rule_workflow_call_test.go +++ b/rule_workflow_call_test.go @@ -1,7 +1,6 @@ package actionlint import ( - "strings" "testing" ) @@ -56,14 +55,11 @@ func TestRuleWorkflowCallCheckWorkflowCallUsesFormat(t *testing.T) { } } -func TestRuleWorkflowCallCheckCannotCallNestedly(t *testing.T) { +func TestRuleWorkflowCallNestedWorkflowCalls(t *testing.T) { w := &Workflow{ On: []Event{ &WorkflowCallEvent{ - Pos: &Pos{ - Line: 12, - Col: 34, - }, + Pos: &Pos{}, }, }, } @@ -86,17 +82,9 @@ func TestRuleWorkflowCallCheckCannotCallNestedly(t *testing.T) { if err := r.VisitJobPre(j); err != nil { t.Fatal(err) } + errs := r.Errs() - err := r.Errs()[0] - msg := err.Error() - - want := "reusable workflow cannot be nested" - if !strings.Contains(msg, want) { - t.Errorf("error message %q does not contain expected message %q", msg, want) - } - - want = "line:12,col:34" - if !strings.Contains(msg, want) { - t.Errorf("error message %q does not contain proper position %q", msg, want) + if len(errs) > 0 { + t.Fatal("unexpected errors:", errs) } } diff --git a/testdata/err/nested_workflow_call.out b/testdata/err/nested_workflow_call.out deleted file mode 100644 index a43e206d5..000000000 --- a/testdata/err/nested_workflow_call.out +++ /dev/null @@ -1 +0,0 @@ -test.yaml:5:11: reusable workflow cannot be nested. but this workflow hooks "workflow_call" event at line:1,col:5 [workflow-call] diff --git a/testdata/examples/workflow_call_definitions.out b/testdata/examples/workflow_call_definitions.out index 2f3488d4c..49122e047 100644 --- a/testdata/examples/workflow_call_definitions.out +++ b/testdata/examples/workflow_call_definitions.out @@ -2,4 +2,3 @@ test.yaml:9:7: "description" is missing at "host" input of workflow_call event [ test.yaml:16:18: input of workflow_call event "port" is typed as number but its default value ":1234" cannot be parsed as a float number: strconv.ParseFloat: parsing ":1234": invalid syntax [events] test.yaml:21:15: invalid value "object" for input type of workflow_call event. it must be one of "boolean", "number", or "string" [syntax-check] test.yaml:26:18: input "path" of workflow_call event has the default value "", but it is also required. if an input is marked as required, its default value will never be used [events] -test.yaml:35:11: reusable workflow cannot be nested. but this workflow hooks "workflow_call" event at line:2,col:3 [workflow-call] diff --git a/testdata/examples/workflow_call_definitions.yaml b/testdata/examples/workflow_call_definitions.yaml index 96adfe03d..4b1ac4ce7 100644 --- a/testdata/examples/workflow_call_definitions.yaml +++ b/testdata/examples/workflow_call_definitions.yaml @@ -30,6 +30,3 @@ jobs: runs-on: ubuntu-latest steps: - run: echo "${{ inputs.scheme }}://${{ inputs.host }}:${{ inputs.port }}${{ inputs.path }}" - nested: - # ERROR: Nested workflow call is not allowed - uses: onwer/repo/w.yml@main diff --git a/testdata/err/nested_workflow_call.yaml b/testdata/ok/nested_workflow_call.yaml similarity index 100% rename from testdata/err/nested_workflow_call.yaml rename to testdata/ok/nested_workflow_call.yaml