From 5fb9a3a2895195ed789ff82ee5496f656c02d7a9 Mon Sep 17 00:00:00 2001 From: Matija Petrunic Date: Thu, 7 Jan 2021 16:31:27 +0100 Subject: [PATCH 1/7] Add witx specification --- spec/witx/spec.md | 123 ++++++++++++++++++++++++++++++++++++++++++++ spec/witx/spec.witx | 57 ++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 spec/witx/spec.md create mode 100644 spec/witx/spec.witx diff --git a/spec/witx/spec.md b/spec/witx/spec.md new file mode 100644 index 0000000..1353777 --- /dev/null +++ b/spec/witx/spec.md @@ -0,0 +1,123 @@ +# Types +# Modules +## w3 +### Imports +### Functions + +--- + +#### `_w3_init()` +Init w3 + +##### Params +##### Results + +--- + +#### `_w3_invoke(name_size: u64, args_size: u32)` +Invoke call + +##### Params +- `name_size`: `u64` + +- `args_size`: `u32` + +##### Results + +--- + +#### `__w3_invoke_args(name_ptr: s32, args_ptr: s32)` +Get Invoke Arguments + +##### Params +- `name_ptr`: `s32` + +- `args_ptr`: `s32` + +##### Results + +--- + +#### `__w3_invoke_result(ptr: s32, len: u64)` +Set Invoke Arguments + +##### Params +- `ptr`: `s32` + +- `len`: `u64` + +##### Results + +--- + +#### `__w3_invoke_error(ptr: s32, len: u64)` +Set Invoke Error + +##### Params +- `ptr`: `s32` + +- `len`: `u64` + +##### Results + +--- + +#### `__w3_query(uri_ptr: s32, uri_len: u64, query_ptr: s32, query_len: u64, args_ptr: s32, args_len: u64) -> s8` +Query API + +##### Params +- `uri_ptr`: `s32` + +- `uri_len`: `u64` + +- `query_ptr`: `s32` + +- `query_len`: `u64` + +- `args_ptr`: `s32` + +- `args_len`: `u64` + +##### Results +- `res`: `s8` + + +--- + +#### `__w3_query_result_len() -> u64` +Query Result + +##### Params +##### Results +- `res`: `u64` + + +--- + +#### `__w3_query_result(ptr: s32)` +Query Result + +##### Params +- `ptr`: `s32` + +##### Results + +--- + +#### `__w3_query_error_len() -> u64` +Query Error + +##### Params +##### Results +- `res`: `u64` + + +--- + +#### `__w3_query_error(ptr: s32)` +Query Error + +##### Params +- `ptr`: `s32` + +##### Results diff --git a/spec/witx/spec.witx b/spec/witx/spec.witx new file mode 100644 index 0000000..408c61c --- /dev/null +++ b/spec/witx/spec.witx @@ -0,0 +1,57 @@ +(module $w3 + ;;; Init w3 + (@interface func (export "_w3_init")) + + ;;; Invoke call + (@interface func (export "_w3_invoke") + (param $name_size u64) + (param $args_size u32) + ) + + ;;; Get Invoke Arguments + (@interface func (export "__w3_invoke_args") + (param $name_ptr s32) + (param $args_ptr s32) + ) + + ;;; Set Invoke Arguments + (@interface func (export "__w3_invoke_result") + (param $ptr s32) + (param $len u64) + ) + + ;;; Set Invoke Error + (@interface func (export "__w3_invoke_error") + (param $ptr s32) + (param $len u64) + ) + + ;;; Query API + (@interface func (export "__w3_query") + (param $uri_ptr s32) + (param $uri_len u64) + (param $query_ptr s32) + (param $query_len u64) + (param $args_ptr s32) + (param $args_len u64) + (result $res s8) + ) + + ;;; Query Result + (@interface func (export "__w3_query_result_len") + (result $res u64) + ) + ;;; Query Result + (@interface func (export "__w3_query_result") + (param $ptr s32) + ) + + ;;; Query Error + (@interface func (export "__w3_query_error_len") + (result $res u64) + ) + ;;; Query Error + (@interface func (export "__w3_query_error") + (param $ptr s32) + ) +) From 3be8e60f601639769a1c53dc704711d59d470d75 Mon Sep 17 00:00:00 2001 From: Matija Petrunic Date: Thu, 7 Jan 2021 16:31:44 +0100 Subject: [PATCH 2/7] Add pipeline for checking if markdown is outdated --- .github/workflows/check-witx.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/check-witx.yaml diff --git a/.github/workflows/check-witx.yaml b/.github/workflows/check-witx.yaml new file mode 100644 index 0000000..7c28951 --- /dev/null +++ b/.github/workflows/check-witx.yaml @@ -0,0 +1,27 @@ +name: Check Witx + +on: [push, pull_request] + +jobs: + Witx: + name: "Check Witx" + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Generate markdown + uses: NodeFactoryIo/witx-md-generator-action@master + with: + markdownPath: spec/witx/spec.md + witxPath: spec/witx/spec.witx + + - name: Check if there are changes + id: changes + uses: UnicornGlobal/has-changes-action@v1.0.11 + + - name: Process changes + if: steps.changes.outputs.changed == 1 + run: exit 1 From 325b8ccd7df169b3800d1029ee247423a36468d8 Mon Sep 17 00:00:00 2001 From: Matija Petrunic Date: Thu, 7 Jan 2021 16:31:55 +0100 Subject: [PATCH 3/7] Add README for generating markdown --- spec/witx/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 spec/witx/README.md diff --git a/spec/witx/README.md b/spec/witx/README.md new file mode 100644 index 0000000..a0fa60b --- /dev/null +++ b/spec/witx/README.md @@ -0,0 +1,15 @@ +## Generating Markdown + +Generating Markdown is done via tool from WASI [repo](https://github.com/WebAssembly/WASI/tree/master/tools/witx): + +```bash +cargo run --example witx docs -o target.md target.witx +``` + +### Docker + +Also available is a docker image with prepackaged cli: + +```bash +docker run -v /path:/usr/src/witx nodefactory/witx docs -o target.md target.witx +``` From 33bc8a3a6438978a28f016dfd23c1d2c2423c83d Mon Sep 17 00:00:00 2001 From: Matija Petrunic Date: Fri, 8 Jan 2021 12:37:15 +0100 Subject: [PATCH 4/7] Rename spec to w3 module --- spec/witx/{spec.md => w3.md} | 0 spec/witx/{spec.witx => w3.witx} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename spec/witx/{spec.md => w3.md} (100%) rename spec/witx/{spec.witx => w3.witx} (100%) diff --git a/spec/witx/spec.md b/spec/witx/w3.md similarity index 100% rename from spec/witx/spec.md rename to spec/witx/w3.md diff --git a/spec/witx/spec.witx b/spec/witx/w3.witx similarity index 100% rename from spec/witx/spec.witx rename to spec/witx/w3.witx From a6aae9e44f5cb9c65a928aee2971a00f29c5763c Mon Sep 17 00:00:00 2001 From: Matija Petrunic Date: Fri, 8 Jan 2021 12:56:28 +0100 Subject: [PATCH 5/7] Use recursive witx md generation in pipeline --- .github/workflows/check-witx.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/check-witx.yaml b/.github/workflows/check-witx.yaml index 7c28951..d60ec0f 100644 --- a/.github/workflows/check-witx.yaml +++ b/.github/workflows/check-witx.yaml @@ -15,8 +15,7 @@ jobs: - name: Generate markdown uses: NodeFactoryIo/witx-md-generator-action@master with: - markdownPath: spec/witx/spec.md - witxPath: spec/witx/spec.witx + witxPath: spec/witx/ - name: Check if there are changes id: changes From cb116f8e21b638dda5a7d899f624292a3adceb85 Mon Sep 17 00:00:00 2001 From: Matija Petrunic Date: Fri, 8 Jan 2021 14:32:16 +0100 Subject: [PATCH 6/7] Update generate markdown action --- .github/workflows/check-witx.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-witx.yaml b/.github/workflows/check-witx.yaml index d60ec0f..d4b71e2 100644 --- a/.github/workflows/check-witx.yaml +++ b/.github/workflows/check-witx.yaml @@ -15,7 +15,7 @@ jobs: - name: Generate markdown uses: NodeFactoryIo/witx-md-generator-action@master with: - witxPath: spec/witx/ + witxGlobPath: spec/witx/**/*.witx - name: Check if there are changes id: changes From f4c295360c57b7d88a69aa508858d7f3731f9c78 Mon Sep 17 00:00:00 2001 From: Matija Petrunic Date: Fri, 8 Jan 2021 14:36:38 +0100 Subject: [PATCH 7/7] Update README --- spec/witx/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/witx/README.md b/spec/witx/README.md index a0fa60b..8f4beee 100644 --- a/spec/witx/README.md +++ b/spec/witx/README.md @@ -3,7 +3,7 @@ Generating Markdown is done via tool from WASI [repo](https://github.com/WebAssembly/WASI/tree/master/tools/witx): ```bash -cargo run --example witx docs -o target.md target.witx +cargo run witx docs "path/**/*.witx" ``` ### Docker @@ -11,5 +11,5 @@ cargo run --example witx docs -o target.md target.witx Also available is a docker image with prepackaged cli: ```bash -docker run -v /path:/usr/src/witx nodefactory/witx docs -o target.md target.witx +docker run -v /path:/usr/src/witx nodefactory/witx docs "path/**/*.witx" ```