diff options
-rw-r--r-- | .forgejo/workflows/test.yml | 2 | ||||
-rw-r--r-- | pkg/model/workflow.go | 2 | ||||
-rw-r--r-- | pkg/model/workflow_test.go | 19 |
3 files changed, 21 insertions, 2 deletions
diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 767f63c..59516f3 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -44,5 +44,5 @@ jobs: - name: build without docker run: go build -tags WITHOUT_DOCKER -v ./... - name: test - run: go test -v ./pkg/jobparser + run: go test -v ./pkg/jobparser ./pkg/model # TODO test more packages diff --git a/pkg/model/workflow.go b/pkg/model/workflow.go index a8d167e..7bec766 100644 --- a/pkg/model/workflow.go +++ b/pkg/model/workflow.go @@ -749,7 +749,7 @@ func (w *Workflow) GetJobIDs() []string { } var OnDecodeNodeError = func(node yaml.Node, out interface{}, err error) { - log.Fatalf("Failed to decode node %v into %T: %v", node, out, err) + log.Errorf("Failed to decode node %v into %T: %v", node, out, err) } func decodeNode(node yaml.Node, out interface{}) bool { diff --git a/pkg/model/workflow_test.go b/pkg/model/workflow_test.go index 9f219ee..d253906 100644 --- a/pkg/model/workflow_test.go +++ b/pkg/model/workflow_test.go @@ -153,6 +153,25 @@ jobs: assert.Contains(t, workflow.On(), "pull_request") } +func TestReadWorkflow_DecodeNodeError(t *testing.T) { + yaml := ` +on: + push: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - run: echo + env: + foo: {{ a }} +` + + workflow, err := ReadWorkflow(strings.NewReader(yaml)) + assert.NoError(t, err, "read workflow should succeed") + assert.Nil(t, workflow.GetJob("test").Steps[0].GetEnv()) +} + func TestReadWorkflow_RunsOnLabels(t *testing.T) { yaml := ` name: local-action-docker-url |