https://github.com/cschleiden/actionlint-interpreter
Interpreter for GitHub Actions Expressions
https://github.com/cschleiden/actionlint-interpreter
actions github go
Last synced: 2 months ago
JSON representation
Interpreter for GitHub Actions Expressions
- Host: GitHub
- URL: https://github.com/cschleiden/actionlint-interpreter
- Owner: cschleiden
- License: mit
- Created: 2022-03-14T03:29:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-04T22:32:48.000Z (about 4 years ago)
- Last Synced: 2025-02-06T11:54:49.832Z (over 1 year ago)
- Topics: actions, github, go
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# actionlint-interpreter
Simple expression interpreter for _GitHub Actions Expressions_ operating on the AST produced by https://github.com/rhysd/actionlint.
## Usage
```golang
expression := "input.foo <= input.bar"
// Lex & Parse
lexer := actionlint.NewExprLexer(expression + "}}")
parser := actionlint.NewExprParser()
n, perr := parser.Parse(lexer)
if perr != nil {
panic(perr)
}
// Evaluate expressions
result, err := Evaluate(n, ContextData{
"input": ContextData{
"foo": float64(1),
"bar": float64(2),
},
})
if err != nil {
panic(err)
}
fmt.Println(result.Value)
// Output: true
```
### TODO
Not everything is implemented yet:
#### Context access
- [x] Finish object & array access
- [ ] Wildcard access (`inputs.*.foo`)
#### Functions
- [ ] contains
- [x] startsWith
- [x] endsWith
- [ ] format
- [x] join
- [ ] toJSON
- [x] fromJSON
- [ ] hashFiles
Status check functions:
- [ ] success
- [ ] always
- [ ] cancelled
- [ ] failure