diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 47e0e622d0..27ded3b745 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -140,6 +140,14 @@ jobs: parallel -k -j 4 --retries 3 --joblog report.log ./target/release/examples/{} cat report.log + - name: Run Rust Readme examples + # run examples only on ubuntu for now + if: matrix.os == 'ubuntu-latest' + run: | + cd bindings/wasm + npm ci + npm run test:readme:rust + - name: Tear down private tangle if: matrix.os == 'ubuntu-latest' && always() uses: './.github/actions/private-tangle/tear-down' diff --git a/README.md b/README.md index 564817faa8..558e53f7e2 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,17 @@ See the [instructions](https://github.com/iotaledger/hornet/tree/develop/private _Cargo.toml_ + + + ```toml [package] name = "iota_identity_example" @@ -77,10 +88,25 @@ edition = "2021" identity_iota = {version = "1.0.0", features = ["memstore"]} iota-sdk = { version = "1.0.2", default-features = true, features = ["tls", "client", "stronghold"] } tokio = { version = "1", features = ["full"] } +anyhow = "1.0.62" +rand = "0.8.5" ``` _main.__rs_ + + + + ```rust,no_run use identity_iota::core::ToJson; use identity_iota::iota::IotaClientExt; diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index 7f00d683d8..842945fe79 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -25,6 +25,7 @@ "test:browser:parallel": "npm run build:examples:web && cypress-parallel -s test:browser -t 4 -d cypress/e2e -a '\"--quiet\"'", "test:browser": "cypress run --headless", "test:readme": "mocha ./tests/txm_readme.js --retries 3 --timeout 180000 --exit", + "test:readme:rust": "mocha ./tests/txm_readme_rust.js --retries 3 --timeout 360000 --exit", "test:unit:node": "ts-mocha -p tsconfig.node.json ./tests/*.ts --parallel --exit", "cypress": "cypress open", "fmt": "dprint fmt" diff --git a/bindings/wasm/tests/txm_readme.js b/bindings/wasm/tests/txm_readme.js index 0f1ed5d0c0..2a388c2dba 100644 --- a/bindings/wasm/tests/txm_readme.js +++ b/bindings/wasm/tests/txm_readme.js @@ -1,7 +1,21 @@ -const { execSync } = require("child_process"); +const assert = require("assert"); +const spawn = require("child_process").spawn; -describe("Test TXM", function() { - it("README examples pass", async () => { - execSync("txm README.md"); +describe("Test TXM", () => { + before((done) => { + let process = spawn("txm", ["README.md"]); + process.stdout.on("data", function(data) { + console.log(data.toString()); + }); + process.stderr.on("data", function(data) { + console.log(data.toString()); + }); + process.on("exit", (code) => { + exitCode = code; + done(); + }); + }); + it("exit code should be zero", () => { + assert.equal(exitCode, 0); }); }); diff --git a/bindings/wasm/tests/txm_readme_rust.js b/bindings/wasm/tests/txm_readme_rust.js new file mode 100644 index 0000000000..d024653fe2 --- /dev/null +++ b/bindings/wasm/tests/txm_readme_rust.js @@ -0,0 +1,21 @@ +const assert = require("assert"); +const spawn = require("child_process").spawn; + +describe("Test TXM", () => { + before((done) => { + let process = spawn("txm", ["../../README.md"]); + process.stdout.on("data", function(data) { + console.log(data.toString()); + }); + process.stderr.on("data", function(data) { + console.log(data.toString()); + }); + process.on("exit", (code) => { + exitCode = code; + done(); + }); + }); + it("exit code should be zero", () => { + assert.equal(exitCode, 0); + }); +});