Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
atsushi-ishibashi committed Dec 12, 2022
1 parent dde7cf3 commit 34285a7
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 1 deletion.
26 changes: 26 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,36 @@ $ runn run ./http.yml --debug

For the [details](../README.md#expression-evaluation-engine)

[expr.yml](./expr.yml)

```
// expression evaluation engine
$ runn run ./expr.yml --debug
```

[func.yml](./func.yml)

```
// built-in function
$ runn run ./func.yml --debug
```

## Chrome

[cdp.yml](./cdp.yml)

```
$ runn run ./cdp.yml --debug
```

## Include

[include.yml](./include.yml)

```
$ runn run ./include.yml --debug
```

## Go Test Helper

[go-test](./go-test)
Expand Down
Empty file removed examples/builtin-func.yml
Empty file.
28 changes: 28 additions & 0 deletions examples/cdp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
desc: Built-in function
runners:
cc: chrome://new
vars:
url: https://github.com
steps:
github:
cc:
actions:
- navigate: "{{ vars.url }}"
- sendKeys:
sel: "input[type=text]"
value: "k1LoW/runn"
- submit:
sel: "form.js-site-search-form"
- location:
url: "hoge"
test: |
steps.github.url == "https://github.com/search?q=k1LoW%2Frunn&type="
github2:
cc:
actions:
- innerHTML:
sel: "ul.repo-list"
- attributes:
sel: "ul.repo-list > li"
- sessionStorage:
origin: "{{ vars.url }}"
36 changes: 36 additions & 0 deletions examples/expr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
desc: Expression evaluation engine
vars:
itemId: B
items:
- itemId: A
name: Product A
price: 100
- itemId: B
name: Product B
price: 50
- itemId: C
name: Product C
price: 150
products:
A:
name: productA
B:
name: productB
keyString: runn
steps:
filterItemId:
dump: filter(vars.items, {.itemId == vars.itemId})[0].name
testAllPriceGte50:
test: all(vars.items, {.price >= 50}) == true
lenPriceEqual1000:
test: len(filter(vars.items, {.price == 100})) == 1
getProductWithKey:
dump: vars.products["A"]
getProductWithKey2:
dump: vars.products.B
concatString:
dump: ("k1LoW/" + vars.keyString)
containsString:
test: (vars.keyString startsWith "run") == true
whereIn:
test: (vars.keyString in ["runn", "hoge", "fuga"]) == true
30 changes: 30 additions & 0 deletions examples/func.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
desc: Built-in function
runners:
req: http://example.com
vars:
namae: runn太郎
username: runn
password: password
steps:
urlEncode:
req:
/users?name={{ urlencode(vars.namae) }}:
get:
body:
application/json: null
bindBasicAuth:
bind:
authToken: base64encode(vars.username + ":" + vars.password)
basicAuthReq:
req:
/basic:
get:
headers:
Authorization: "Basic {{ authToken }}"
body:
application/json: null
prompt:
bind:
otp: input("Enter OTP> ", "")
dumpOTP:
dump: otp
5 changes: 4 additions & 1 deletion examples/http.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ steps:
test: |
steps.getLatestRelease.res.status == 200
&& steps.getLatestRelease.res.body.id != 0
bindLatestReleaseId:
bind:
releaseId: steps.getLatestRelease.res.body.id
getRelease:
desc: |
Get a release
https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#get-a-release
req:
/repos/{{ fullName }}/releases/{{ steps.getLatestRelease.res.body.id }}:
/repos/{{ fullName }}/releases/{{ releaseId }}:
get:
body:
application/json: null
Expand Down
47 changes: 47 additions & 0 deletions examples/include.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
desc: Include HTTP Runner for GitHub k1LoW/runn
runners:
req: https://api.github.com
vars:
owner: k1LoW
repo: runn
steps:
getLatestRelease:
include:
path: http.yml
vars:
owner: "{{ vars.owner }}"
repo: "{{ vars.repo }}"
bindFullName:
bind:
fullName: steps.getLatestRelease.fullName
bindReleaseId:
bind:
releaseId: steps.getLatestRelease.releaseId
listReleaseAssets:
desc: |
List release assets
https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#list-release-assets
req:
/repos/{{ fullName }}/releases/{{ releaseId }}/assets:
get:
body:
application/json: null
test: |
steps.listReleaseAssets.res.status == 200
bindAssetDarwinArm64:
bind:
assetId: filter(steps.listReleaseAssets.res.body, {.name contains "darwin_arm64"})[0].id
getReleaseAsset:
desc: |
Get a release asset
https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#get-a-release-asset
req:
/repos/{{ fullName }}/releases/assets/{{ assetId }}:
get:
body:
application/json: null
test: |
steps.getReleaseAsset.res.status == 200
&& steps.getReleaseAsset.res.body.browser_download_url != ""
showDownloadUrl:
dump: steps.getReleaseAsset.res.body.browser_download_url

0 comments on commit 34285a7

Please sign in to comment.