diff options
author | Earl Warren <contact@earl-warren.org> | 2024-09-15 15:46:01 +0200 |
---|---|---|
committer | Earl Warren <contact@earl-warren.org> | 2024-09-15 15:46:01 +0200 |
commit | a7db265415c1bb3d2b3f58431eceaec4c5749622 (patch) | |
tree | 8be285245b2aa28fd58c110ce786969672170b3f /pkg | |
parent | chore(renovate): disable runner test data (diff) | |
download | forgejo-act-a7db265415c1bb3d2b3f58431eceaec4c5749622.tar.xz forgejo-act-a7db265415c1bb3d2b3f58431eceaec4c5749622.zip |
[FORGEJO] when a workflow decode error happen, log and do not crash
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/model/workflow.go | 2 | ||||
-rw-r--r-- | pkg/model/workflow_test.go | 19 |
2 files changed, 20 insertions, 1 deletions
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 |