Merge pull request '[FORGEJO] when a workflow decode error happen, log and do not crash' (#54) from earl-warren/act:wip-decode-fatal into main
Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/54 Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
This commit is contained in:
commit
98d572ee58
3 changed files with 21 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue