Skip to content

Commit

Permalink
first good version.
Browse files Browse the repository at this point in the history
Signed-off-by: Chao Li <[email protected]>
  • Loading branch information
evanchaoli committed Jul 29, 2020
1 parent e1a326d commit 3adf9a3
Showing 1 changed file with 54 additions and 11 deletions.
65 changes: 54 additions & 11 deletions 064-gate/proposal.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,70 @@ For the above use case 2, `gate` can be used like:

- gate: no-release-gate
condition: no-release in ((.:mr_info.labels))
fail: false
nofail: true
```
## Step definition
Step `gate` takes a name for description of the gate, and takes the following
parameters:

* `condition` a boolean expression. when `condition` is true, abort the build.
* `fail` if `fail` is true, fail the build `condition` is true; otherwise abort the build
with succeeded result.
* `nofail` by default, if `condition` is true, the build will fail. If you just
want to silently quit the build (with succeeded result), then set `nofail` to
true.
* `objects` a list of objects defined as:
* `name` object name
* `file` file name to load the object. The file should be in json or yaml format.

# Open Questions
## Condition syntax

How to define `condition`?
After some research, I found the package https://github.com/PaesslerAG/gval can
be used for expression evaluation. It supports basic evalutation syntax, and can
be extended to support more operations.

Basically `condition` will be evaluated to a boolean value.
An expression may contains:
### Integer operations and comparisons

```yaml
- load_var: mr_info
file: mr/data.json
- gate: some-gate
condition: ( ( ((.:mr_info.error)) + ((.:mr_info.failure)) ) / 300 ) > 0.85
```

### String operations and comparisons

```yaml
- load_var: mr_info
file: mr/data.json
- gate: some-gate
condition: "((.:mr_info.result))" == "success"
```

```yaml
- load_var: mr_info
file: mr/data.json
- gate: some-gate
condition: prefix_with( "((.:mr_info.subject))", "WIP" )
```

### JSON object operations

```yaml
- gate: some-gate
condition: "no-release" in mr_info.lables
objects:
- name: mr_info
file: mr/data.json
```


# Open Questions

* integer comparison
* string comparison
* not logic
* check if an item is in a list
Any suggestions to condition syntax?

# Answered Questions

Expand Down

0 comments on commit 3adf9a3

Please sign in to comment.