[FORGEJO] when a workflow decode error happen, log and do not crash
This commit is contained in:
parent
d301a5b66a
commit
a7db265415
3 changed files with 21 additions and 2 deletions
|
@ -44,5 +44,5 @@ jobs:
|
||||||
- name: build without docker
|
- name: build without docker
|
||||||
run: go build -tags WITHOUT_DOCKER -v ./...
|
run: go build -tags WITHOUT_DOCKER -v ./...
|
||||||
- name: test
|
- name: test
|
||||||
run: go test -v ./pkg/jobparser
|
run: go test -v ./pkg/jobparser ./pkg/model
|
||||||
# TODO test more packages
|
# TODO test more packages
|
||||||
|
|
|
@ -749,7 +749,7 @@ func (w *Workflow) GetJobIDs() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var OnDecodeNodeError = func(node yaml.Node, out interface{}, err error) {
|
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 {
|
func decodeNode(node yaml.Node, out interface{}) bool {
|
||||||
|
|
|
@ -153,6 +153,25 @@ jobs:
|
||||||
assert.Contains(t, workflow.On(), "pull_request")
|
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) {
|
func TestReadWorkflow_RunsOnLabels(t *testing.T) {
|
||||||
yaml := `
|
yaml := `
|
||||||
name: local-action-docker-url
|
name: local-action-docker-url
|
||||||
|
|
Loading…
Reference in a new issue