diff --git a/.forgejo/workflows/act.yml b/.forgejo/workflows/act.yml index 8ae625ff..206eaae9 100644 --- a/.forgejo/workflows/act.yml +++ b/.forgejo/workflows/act.yml @@ -53,8 +53,8 @@ jobs: - name: unit test run: | - go test -short -v ./act/container - go test -v ./act/artifactcache/... ./act/workflowpattern/... ./act/filecollector/... ./act/common/... ./act/jobparser ./act/model ./act/exprparser ./act/schema + go test -short ./act/container + go test ./act/artifactcache/... ./act/workflowpattern/... ./act/filecollector/... ./act/common/... ./act/jobparser ./act/model ./act/exprparser ./act/schema integration: runs-on: lxc-bookworm @@ -74,5 +74,5 @@ jobs: - name: integration test run: | - go test -v ./act/container - go test -v ./act/runner/... + go test ./act/container + go test ./act/runner/... diff --git a/act/schema/action_schema.json b/act/schema/action_schema.json index 9b1ac8dd..2b2a22f0 100644 --- a/act/schema/action_schema.json +++ b/act/schema/action_schema.json @@ -15,12 +15,18 @@ } }, "inputs": { + "one-of": ["null", "inputs-mapping"] + }, + "inputs-mapping": { "mapping": { "loose-key-type": "non-empty-string", "loose-value-type": "input" } }, "input": { + "one-of": ["null", "input-mapping"] + }, + "input-mapping": { "mapping": { "properties": { "default": "input-default-context" @@ -190,6 +196,7 @@ "steps", "job", "runner", + "vars", "env", "hashFiles(1,255)" ], @@ -205,6 +212,7 @@ "steps", "job", "runner", + "vars", "env", "hashFiles(1,255)" ], @@ -239,6 +247,7 @@ "steps", "job", "runner", + "vars", "env", "always(0,0)", "failure(0,0)", @@ -258,6 +267,7 @@ "steps", "job", "runner", + "vars", "env", "hashFiles(1,255)" ], diff --git a/act/schema/schema.go b/act/schema/schema.go index 71f474db..d452f012 100644 --- a/act/schema/schema.go +++ b/act/schema/schema.go @@ -125,9 +125,10 @@ func (s *Node) checkSingleExpression(exprNode actionlint.ExprNode) error { case actionlint.TokenKindInt: case actionlint.TokenKindFloat: case actionlint.TokenKindString: + case actionlint.TokenKindIdent: return nil default: - return fmt.Errorf("expressions are not allowed here") + return fmt.Errorf("expressions are not allowed in %v", exprNode.Token().Kind) } } diff --git a/act/schema/schema_test.go b/act/schema/schema_test.go index 6c3b1a8b..5941fc40 100644 --- a/act/schema/schema_test.go +++ b/act/schema/schema_test.go @@ -123,12 +123,17 @@ jobs: } func TestActionSchema(t *testing.T) { - var node yaml.Node - err := yaml.Unmarshal([]byte(` + for _, testCase := range []struct { + name string + action string + }{ + { + name: "Expressions", + action: ` name: 'action name' author: 'action authors' description: | - action description + action ${{ env.SOMETHING }} description inputs: url: description: 'url description' @@ -143,13 +148,41 @@ runs: echo "${{ github.action_path }}" env: MYVAR: ${{ vars.VARIABLE }} -`), &node) - if !assert.NoError(t, err) { - return +`, + }, + { + name: "NoInputs", + action: ` +runs: + using: "composite" + steps: + - run: echo OK +`, + }, + { + name: "NoMappingInputs", + action: ` +inputs: + parameter1: + parameter2: +runs: + using: "composite" + steps: + - run: echo OK +`, + }, + } { + t.Run(testCase.name, func(t *testing.T) { + var node yaml.Node + err := yaml.Unmarshal([]byte(testCase.action), &node) + if !assert.NoError(t, err) { + return + } + err = (&Node{ + Definition: "action-root", + Schema: GetActionSchema(), + }).UnmarshalYAML(&node) + assert.NoError(t, err) + }) } - err = (&Node{ - Definition: "action-root", - Schema: GetActionSchema(), - }).UnmarshalYAML(&node) - assert.NoError(t, err) }