1
1
mirror of https://github.com/nektos/act.git synced 2024-09-21 09:17:23 +03:00

fix: do not error that much (#1137)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
ChristopherHX 2022-04-26 22:14:56 +02:00 committed by GitHub
parent 3f2469bf53
commit 93575124d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -175,11 +175,11 @@ func (impl *interperterImpl) evaluateIndexAccess(indexAccessNode *actionlint.Ind
}
return leftValue.Index(int(rightValue.Int())).Interface(), nil
default:
return nil, fmt.Errorf("Unable to index on non-slice value: %s", leftValue.Kind())
return nil, nil
}
default:
return nil, fmt.Errorf("Unknown index type: %s", rightValue.Kind())
return nil, nil
}
}
@ -260,7 +260,7 @@ func (impl *interperterImpl) getPropertyValue(left reflect.Value, property strin
return values, nil
}
return nil, fmt.Errorf("Unable to dereference '%s' on non-struct '%s'", property, left.Kind())
return nil, nil
}
func (impl *interperterImpl) getMapValue(value reflect.Value) (interface{}, error) {

View File

@ -47,8 +47,12 @@ func TestOperators(t *testing.T) {
{"(false || (false || true))", true, "logical-grouping", ""},
{"github.action", "push", "property-dereference", ""},
{"github['action']", "push", "property-index", ""},
{"github.action[0]", nil, "string-index", "Unable to index on non-slice value: string"},
{"github.action[0]", nil, "string-index", ""},
{"github.action['0']", nil, "string-index", ""},
{"fromJSON('[0,1]')[1]", 1.0, "array-index", ""},
{"fromJSON('[0,1]')[1.1]", nil, "array-index", ""},
// Disabled weird things are happening
// {"fromJSON('[0,1]')['1.1']", nil, "array-index", ""},
{"(github.event.commits.*.author.username)[0]", "someone", "array-index-0", ""},
{"fromJSON('[0,1]')[2]", nil, "array-index-out-of-bounds-0", ""},
{"fromJSON('[0,1]')[34553]", nil, "array-index-out-of-bounds-1", ""},
@ -524,6 +528,9 @@ func TestContexts(t *testing.T) {
name string
}{
{"github.action", "push", "github-context"},
{"github.event.commits[0].message", nil, "github-context-noexist-prop"},
{"fromjson('{\"commits\":[]}').commits[0].message", nil, "github-context-noexist-prop"},
{"github.event.pull_request.labels.*.name", nil, "github-context-noexist-prop"},
{"env.TEST", "value", "env-context"},
{"job.status", "success", "job-context"},
{"steps.step-id.outputs.name", "value", "steps-context"},