summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorearl-warren <earl-warren@noreply.code.forgejo.org>2024-09-15 18:35:43 +0200
committerearl-warren <earl-warren@noreply.code.forgejo.org>2024-09-15 18:35:43 +0200
commit98d572ee5811b156dee9f00822fd9611dea40cde (patch)
tree8be285245b2aa28fd58c110ce786969672170b3f
parentchore(renovate): disable runner test data (diff)
parent[FORGEJO] when a workflow decode error happen, log and do not crash (diff)
downloadforgejo-act-98d572ee5811b156dee9f00822fd9611dea40cde.tar.xz
forgejo-act-98d572ee5811b156dee9f00822fd9611dea40cde.zip
Merge pull request '[FORGEJO] when a workflow decode error happen, log and do not crash' (#54) from earl-warren/act:wip-decode-fatal into mainv1.21.3
Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/54 Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
-rw-r--r--.forgejo/workflows/test.yml2
-rw-r--r--pkg/model/workflow.go2
-rw-r--r--pkg/model/workflow_test.go19
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