From ab96c7f1f81022f301458cb7452e3e615251c356 Mon Sep 17 00:00:00 2001 From: krisbitney Date: Tue, 24 Oct 2023 16:58:53 +0500 Subject: [PATCH 1/8] made wasm templates more consistent --- .../wasm/assemblyscript/polywrap.deploy.yaml | 7 ----- .../validator.cue => polywrap.test.cue} | 0 .../wasm/assemblyscript/polywrap.test.yaml | 2 +- .../templates/wasm/typescript/package.json | 11 ++++--- .../wasm/typescript/polywrap.graphql | 6 +++- .../wasm/typescript/polywrap.test.cue | 11 +++++++ .../wasm/typescript/polywrap.test.yaml | 10 ++++++ .../src/__tests__/e2e/integration.spec.ts | 31 +++++++++++++++++++ .../src/__tests__/types/polywrap.app.yaml | 9 ++++++ .../src/__tests__/types/schema.graphql | 1 + .../templates/wasm/typescript/src/index.ts | 8 +++-- 11 files changed, 80 insertions(+), 16 deletions(-) delete mode 100644 packages/templates/wasm/assemblyscript/polywrap.deploy.yaml rename packages/templates/wasm/assemblyscript/{workflows/validator.cue => polywrap.test.cue} (100%) create mode 100644 packages/templates/wasm/typescript/polywrap.test.cue create mode 100644 packages/templates/wasm/typescript/polywrap.test.yaml create mode 100644 packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts create mode 100644 packages/templates/wasm/typescript/src/__tests__/types/polywrap.app.yaml create mode 100644 packages/templates/wasm/typescript/src/__tests__/types/schema.graphql diff --git a/packages/templates/wasm/assemblyscript/polywrap.deploy.yaml b/packages/templates/wasm/assemblyscript/polywrap.deploy.yaml deleted file mode 100644 index f0444053fc..0000000000 --- a/packages/templates/wasm/assemblyscript/polywrap.deploy.yaml +++ /dev/null @@ -1,7 +0,0 @@ -format: "0.1" -stages: - ipfs_deploy: - package: ipfs - uri: fs/./build - config: - gatewayUri: "https://ipfs.wrappers.io" \ No newline at end of file diff --git a/packages/templates/wasm/assemblyscript/workflows/validator.cue b/packages/templates/wasm/assemblyscript/polywrap.test.cue similarity index 100% rename from packages/templates/wasm/assemblyscript/workflows/validator.cue rename to packages/templates/wasm/assemblyscript/polywrap.test.cue diff --git a/packages/templates/wasm/assemblyscript/polywrap.test.yaml b/packages/templates/wasm/assemblyscript/polywrap.test.yaml index 1cb06da5f4..c622bccd27 100644 --- a/packages/templates/wasm/assemblyscript/polywrap.test.yaml +++ b/packages/templates/wasm/assemblyscript/polywrap.test.yaml @@ -1,6 +1,6 @@ name: template-wasm-rs format: 0.1.0 -validation: "./workflows/validator.cue" +validation: "./polywrap.test.cue" jobs: sampleMethod: steps: diff --git a/packages/templates/wasm/typescript/package.json b/packages/templates/wasm/typescript/package.json index 41a85158d2..a8009740e6 100644 --- a/packages/templates/wasm/typescript/package.json +++ b/packages/templates/wasm/typescript/package.json @@ -6,10 +6,13 @@ "main": "build/index.js", "scripts": { "bundle": "rollup -c", - "codegen": "polywrap codegen --verbose", - "build": "yarn bundle && npx polywrap build --no-codegen", - "test": "jest --passWithNoTests --runInBand --verbose", - "deploy": "polywrap deploy" + "codegen": "npx polywrap codegen", + "build": "yarn codegen && yarn bundle && npx polywrap build --no-codegen", + "deploy": "npx polywrap deploy", + "test": "yarn test:e2e && yarn test:workflow", + "test:e2e": "yarn test:e2e:codegen && cargo test --release", + "test:e2e:codegen": "npx polywrap codegen -m ./tests/types/polywrap.app.yaml -g ./tests/types/wrap", + "test:workflow": "npx polywrap test" }, "dependencies": { "tslib": "^2.6.2" diff --git a/packages/templates/wasm/typescript/polywrap.graphql b/packages/templates/wasm/typescript/polywrap.graphql index a527c058c2..5b34469c7e 100644 --- a/packages/templates/wasm/typescript/polywrap.graphql +++ b/packages/templates/wasm/typescript/polywrap.graphql @@ -1,3 +1,7 @@ type Module { - foo(bar: String!): String! + sampleMethod(arg: String!): SampleResult! +} + +type SampleResult { + result: String! } diff --git a/packages/templates/wasm/typescript/polywrap.test.cue b/packages/templates/wasm/typescript/polywrap.test.cue new file mode 100644 index 0000000000..72c37000a6 --- /dev/null +++ b/packages/templates/wasm/typescript/polywrap.test.cue @@ -0,0 +1,11 @@ +package e2e + +sampleMethod: { + $0: { + data: { + value: "polywrap from sample_method" + }, + error?: _|_, + } +} + diff --git a/packages/templates/wasm/typescript/polywrap.test.yaml b/packages/templates/wasm/typescript/polywrap.test.yaml new file mode 100644 index 0000000000..560e8b604e --- /dev/null +++ b/packages/templates/wasm/typescript/polywrap.test.yaml @@ -0,0 +1,10 @@ +name: template-wasm-ts +format: 0.1.0 +validation: "./polywrap.test.cue" +jobs: + sampleMethod: + steps: + - uri: fs/build + method: sampleMethod + args: + arg: "polywrap" diff --git a/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts b/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts new file mode 100644 index 0000000000..55913c174a --- /dev/null +++ b/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts @@ -0,0 +1,31 @@ +import { PolywrapClient } from "@polywrap/client-js"; +import * as App from "../types/wrap"; +import path from "path"; + +jest.setTimeout(60000); + +describe("Template Wrapper End to End Tests", () => { + + const client: PolywrapClient = new PolywrapClient(); + let wrapperUri: string; + + beforeAll(() => { + const dirname: string = path.resolve(__dirname); + const wrapperPath: string = path.join(dirname, "..", "..", ".."); + wrapperUri = `fs/${wrapperPath}/build`; + }) + + it("calls sampleMethod", async () => { + const expected: string = "polywrap"; + + const result = await client.invoke({ + uri: wrapperUri, + method: "sampleMethod", + args: { arg: expected } + }); + + expect(result.ok).toBeTruthy(); + if (!result.ok) return; + expect(result.value.result).toEqual(expected); + }); +}); diff --git a/packages/templates/wasm/typescript/src/__tests__/types/polywrap.app.yaml b/packages/templates/wasm/typescript/src/__tests__/types/polywrap.app.yaml new file mode 100644 index 0000000000..c084aed0f0 --- /dev/null +++ b/packages/templates/wasm/typescript/src/__tests__/types/polywrap.app.yaml @@ -0,0 +1,9 @@ +format: 0.3.0 +project: + name: sample-typescript-type-generation + type: app/typescript +source: + schema: ./schema.graphql + import_abis: + - uri: "wrap://ens/sample.eth" + abi: "../../../build/wrap.info" diff --git a/packages/templates/wasm/typescript/src/__tests__/types/schema.graphql b/packages/templates/wasm/typescript/src/__tests__/types/schema.graphql new file mode 100644 index 0000000000..6d75bfc9bc --- /dev/null +++ b/packages/templates/wasm/typescript/src/__tests__/types/schema.graphql @@ -0,0 +1 @@ +#import * into Template from "wrap://ens/sample.eth" diff --git a/packages/templates/wasm/typescript/src/index.ts b/packages/templates/wasm/typescript/src/index.ts index fb25fe8ea7..135f6e6ba1 100644 --- a/packages/templates/wasm/typescript/src/index.ts +++ b/packages/templates/wasm/typescript/src/index.ts @@ -1,7 +1,9 @@ -import { Args_foo, ModuleBase } from "./wrap"; +import { Args_sampleMethod, SampleResult, ModuleBase } from "./wrap"; export class Module extends ModuleBase { - foo(args: Args_foo): string { - throw new Error("Not implemented"); + sampleMethod(args: Args_sampleMethod): SampleResult { + return { + result: args.arg, + }; } } From ef7543ee12fdfb3dfc834405e491477a1288ba9c Mon Sep 17 00:00:00 2001 From: krisbitney Date: Tue, 24 Oct 2023 17:51:02 +0500 Subject: [PATCH 2/8] removed workflows from templates; fixed bugs in rust template; removed deploy manifests from templates --- packages/templates/wasm/assemblyscript/package.json | 8 ++------ .../templates/wasm/assemblyscript/polywrap.build.yaml | 4 ++-- .../templates/wasm/assemblyscript/polywrap.test.cue | 11 ----------- .../templates/wasm/assemblyscript/polywrap.test.yaml | 10 ---------- packages/templates/wasm/golang/package.json | 6 ++---- packages/templates/wasm/golang/polywrap.build.yaml | 4 ++++ packages/templates/wasm/golang/polywrap.test.cue | 11 ----------- packages/templates/wasm/golang/polywrap.test.yaml | 10 ---------- packages/templates/wasm/golang/polywrap.yaml | 2 ++ .../templates/wasm/interface/polywrap.deploy.yaml | 7 ------- packages/templates/wasm/rust/package.json | 6 ++---- packages/templates/wasm/rust/polywrap.deploy.yaml | 7 ------- packages/templates/wasm/rust/polywrap.test.cue | 11 ----------- packages/templates/wasm/rust/polywrap.test.yaml | 10 ---------- packages/templates/wasm/rust/tests/it/module.rs | 10 +++++----- packages/templates/wasm/typescript/package.json | 6 ++---- .../templates/wasm/typescript/polywrap.build.yaml | 3 +++ packages/templates/wasm/typescript/polywrap.test.cue | 11 ----------- packages/templates/wasm/typescript/polywrap.test.yaml | 10 ---------- packages/templates/wasm/typescript/polywrap.yaml | 2 ++ 20 files changed, 26 insertions(+), 123 deletions(-) delete mode 100644 packages/templates/wasm/assemblyscript/polywrap.test.cue delete mode 100644 packages/templates/wasm/assemblyscript/polywrap.test.yaml create mode 100644 packages/templates/wasm/golang/polywrap.build.yaml delete mode 100644 packages/templates/wasm/golang/polywrap.test.cue delete mode 100644 packages/templates/wasm/golang/polywrap.test.yaml delete mode 100644 packages/templates/wasm/interface/polywrap.deploy.yaml delete mode 100644 packages/templates/wasm/rust/polywrap.deploy.yaml delete mode 100644 packages/templates/wasm/rust/polywrap.test.cue delete mode 100644 packages/templates/wasm/rust/polywrap.test.yaml delete mode 100644 packages/templates/wasm/typescript/polywrap.test.cue delete mode 100644 packages/templates/wasm/typescript/polywrap.test.yaml diff --git a/packages/templates/wasm/assemblyscript/package.json b/packages/templates/wasm/assemblyscript/package.json index 5655b15996..8511c141c3 100644 --- a/packages/templates/wasm/assemblyscript/package.json +++ b/packages/templates/wasm/assemblyscript/package.json @@ -6,13 +6,9 @@ "scripts": { "codegen": "npx polywrap codegen", "build": "npx polywrap build", - "test:env:up": "npx polywrap infra up --modules=eth-ens-ipfs", - "test:env:down": "npx polywrap infra down --modules=eth-ens-ipfs", "deploy": "npx polywrap deploy", - "test": "yarn test:e2e && yarn test:workflow", - "test:e2e": "yarn test:e2e:codegen && jest --passWithNoTests --runInBand --verbose", - "test:e2e:codegen": "npx polywrap codegen -m ./src/__tests__/types/polywrap.app.yaml -g ./src/__tests__/types/wrap", - "test:workflow": "npx polywrap test -o ./workflows/output.json" + "test": "yarn test:codegen && jest --passWithNoTests --runInBand --verbose", + "test:codegen": "npx polywrap codegen -m ./src/__tests__/types/polywrap.app.yaml -g ./src/__tests__/types/wrap" }, "devDependencies": { "@types/jest": "26.0.8", diff --git a/packages/templates/wasm/assemblyscript/polywrap.build.yaml b/packages/templates/wasm/assemblyscript/polywrap.build.yaml index 7a6e7fac0e..4a90507972 100644 --- a/packages/templates/wasm/assemblyscript/polywrap.build.yaml +++ b/packages/templates/wasm/assemblyscript/polywrap.build.yaml @@ -1,8 +1,8 @@ format: 0.3.0 strategies: image: - name: wrap-wasm-as-build-image - node_version: 16.13.0 + name: template-wasm-as + node_version: 18.15.0 include: - ./package.json - ./src diff --git a/packages/templates/wasm/assemblyscript/polywrap.test.cue b/packages/templates/wasm/assemblyscript/polywrap.test.cue deleted file mode 100644 index a71f50ace0..0000000000 --- a/packages/templates/wasm/assemblyscript/polywrap.test.cue +++ /dev/null @@ -1,11 +0,0 @@ -package e2e - -sampleMethod: { - $0: { - data: { - value: "polywrap" - }, - error?: _|_, - } -} - diff --git a/packages/templates/wasm/assemblyscript/polywrap.test.yaml b/packages/templates/wasm/assemblyscript/polywrap.test.yaml deleted file mode 100644 index c622bccd27..0000000000 --- a/packages/templates/wasm/assemblyscript/polywrap.test.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: template-wasm-rs -format: 0.1.0 -validation: "./polywrap.test.cue" -jobs: - sampleMethod: - steps: - - uri: fs/build - method: sampleMethod - args: - arg: "polywrap" diff --git a/packages/templates/wasm/golang/package.json b/packages/templates/wasm/golang/package.json index aa9a03750f..4c51a15127 100644 --- a/packages/templates/wasm/golang/package.json +++ b/packages/templates/wasm/golang/package.json @@ -7,10 +7,8 @@ "codegen": "npx polywrap codegen", "build": "npx polywrap build", "deploy": "npx polywrap deploy", - "test": "yarn test:e2e && yarn test:workflow", - "test:e2e": "yarn test:e2e:codegen && jest --passWithNoTests --runInBand --verbose", - "test:e2e:codegen": "npx polywrap codegen -m ./module/__tests__/types/polywrap.app.yaml -g ./module/__tests__/types/wrap", - "test:workflow": "npx polywrap test" + "test": "yarn test:e2e:codegen && jest --passWithNoTests --runInBand --verbose", + "test:codegen": "npx polywrap codegen -m ./module/__tests__/types/polywrap.app.yaml -g ./module/__tests__/types/wrap" }, "devDependencies": { "@types/jest": "26.0.8", diff --git a/packages/templates/wasm/golang/polywrap.build.yaml b/packages/templates/wasm/golang/polywrap.build.yaml new file mode 100644 index 0000000000..63fd363ddf --- /dev/null +++ b/packages/templates/wasm/golang/polywrap.build.yaml @@ -0,0 +1,4 @@ +format: 0.2.0 +strategies: + image: + name: template-wasm-go diff --git a/packages/templates/wasm/golang/polywrap.test.cue b/packages/templates/wasm/golang/polywrap.test.cue deleted file mode 100644 index a71f50ace0..0000000000 --- a/packages/templates/wasm/golang/polywrap.test.cue +++ /dev/null @@ -1,11 +0,0 @@ -package e2e - -sampleMethod: { - $0: { - data: { - value: "polywrap" - }, - error?: _|_, - } -} - diff --git a/packages/templates/wasm/golang/polywrap.test.yaml b/packages/templates/wasm/golang/polywrap.test.yaml deleted file mode 100644 index 2603e2d03f..0000000000 --- a/packages/templates/wasm/golang/polywrap.test.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: template-wasm-go -format: 0.1.0 -validation: "./polywrap.test.cue" -jobs: - sampleMethod: - steps: - - uri: fs/build - method: sampleMethod - args: - arg: "polywrap" diff --git a/packages/templates/wasm/golang/polywrap.yaml b/packages/templates/wasm/golang/polywrap.yaml index 0b1f3f35d6..41560be606 100644 --- a/packages/templates/wasm/golang/polywrap.yaml +++ b/packages/templates/wasm/golang/polywrap.yaml @@ -5,3 +5,5 @@ project: source: schema: ./polywrap.graphql module: ./go.mod +extensions: + build: ./polywrap.build.yaml diff --git a/packages/templates/wasm/interface/polywrap.deploy.yaml b/packages/templates/wasm/interface/polywrap.deploy.yaml deleted file mode 100644 index f0444053fc..0000000000 --- a/packages/templates/wasm/interface/polywrap.deploy.yaml +++ /dev/null @@ -1,7 +0,0 @@ -format: "0.1" -stages: - ipfs_deploy: - package: ipfs - uri: fs/./build - config: - gatewayUri: "https://ipfs.wrappers.io" \ No newline at end of file diff --git a/packages/templates/wasm/rust/package.json b/packages/templates/wasm/rust/package.json index 8aec722df6..5bf7bbd1e8 100644 --- a/packages/templates/wasm/rust/package.json +++ b/packages/templates/wasm/rust/package.json @@ -7,10 +7,8 @@ "codegen": "npx polywrap codegen", "build": "npx polywrap build", "deploy": "npx polywrap deploy", - "test": "yarn test:e2e && yarn test:workflow", - "test:e2e": "yarn test:e2e:codegen && cargo test --release", - "test:e2e:codegen": "npx polywrap codegen -m ./tests/types/polywrap.app.yaml -g ./tests/types/wrap", - "test:workflow": "npx polywrap test" + "test": "yarn test:codegen && cargo test --release", + "test:codegen": "npx polywrap codegen -m ./tests/types/polywrap.app.yaml -g ./tests/types/wrap" }, "devDependencies": { "polywrap": "0.12.1" diff --git a/packages/templates/wasm/rust/polywrap.deploy.yaml b/packages/templates/wasm/rust/polywrap.deploy.yaml deleted file mode 100644 index 2b9ab565ce..0000000000 --- a/packages/templates/wasm/rust/polywrap.deploy.yaml +++ /dev/null @@ -1,7 +0,0 @@ -format: 0.1.0 -stages: - ipfs_deploy: - package: ipfs - uri: fs/./build - config: - gatewayUri: "https://ipfs.wrappers.io" \ No newline at end of file diff --git a/packages/templates/wasm/rust/polywrap.test.cue b/packages/templates/wasm/rust/polywrap.test.cue deleted file mode 100644 index 72c37000a6..0000000000 --- a/packages/templates/wasm/rust/polywrap.test.cue +++ /dev/null @@ -1,11 +0,0 @@ -package e2e - -sampleMethod: { - $0: { - data: { - value: "polywrap from sample_method" - }, - error?: _|_, - } -} - diff --git a/packages/templates/wasm/rust/polywrap.test.yaml b/packages/templates/wasm/rust/polywrap.test.yaml deleted file mode 100644 index c622bccd27..0000000000 --- a/packages/templates/wasm/rust/polywrap.test.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: template-wasm-rs -format: 0.1.0 -validation: "./polywrap.test.cue" -jobs: - sampleMethod: - steps: - - uri: fs/build - method: sampleMethod - args: - arg: "polywrap" diff --git a/packages/templates/wasm/rust/tests/it/module.rs b/packages/templates/wasm/rust/tests/it/module.rs index a738738bbc..33e83bc530 100644 --- a/packages/templates/wasm/rust/tests/it/module.rs +++ b/packages/templates/wasm/rust/tests/it/module.rs @@ -1,14 +1,14 @@ use crate::types::wrap::types::{ - TemplateModule, - TemplateModuleArgsSampleMethod + Template, + TemplateArgsSampleMethod }; #[test] fn sample_method() { - let args = TemplateModuleArgsSampleMethod { + let args = TemplateArgsSampleMethod { arg: "input data".to_string(), }; - let template: TemplateModule = TemplateModule::new(None, None, None); - let response = template.sample_method(&args, None, None, None).unwrap(); + let template: Template = Template::new(None); + let response = template.sample_method(&args, None).unwrap(); assert_eq!(response.result, "input data from sample_method"); } diff --git a/packages/templates/wasm/typescript/package.json b/packages/templates/wasm/typescript/package.json index a8009740e6..983f859756 100644 --- a/packages/templates/wasm/typescript/package.json +++ b/packages/templates/wasm/typescript/package.json @@ -9,10 +9,8 @@ "codegen": "npx polywrap codegen", "build": "yarn codegen && yarn bundle && npx polywrap build --no-codegen", "deploy": "npx polywrap deploy", - "test": "yarn test:e2e && yarn test:workflow", - "test:e2e": "yarn test:e2e:codegen && cargo test --release", - "test:e2e:codegen": "npx polywrap codegen -m ./tests/types/polywrap.app.yaml -g ./tests/types/wrap", - "test:workflow": "npx polywrap test" + "test": "yarn test:codegen && jest --passWithNoTests --runInBand --verbose", + "test:codegen": "npx polywrap codegen -m ./src/__tests__/types/polywrap.app.yaml -g ./src/__tests__/types/wrap" }, "dependencies": { "tslib": "^2.6.2" diff --git a/packages/templates/wasm/typescript/polywrap.build.yaml b/packages/templates/wasm/typescript/polywrap.build.yaml index 4bdc6dc166..096bdbcbb9 100644 --- a/packages/templates/wasm/typescript/polywrap.build.yaml +++ b/packages/templates/wasm/typescript/polywrap.build.yaml @@ -1,3 +1,6 @@ format: 0.3.0 +strategies: + image: + name: template-wasm-ts config: scriptFile: ./bundled/wrap.js \ No newline at end of file diff --git a/packages/templates/wasm/typescript/polywrap.test.cue b/packages/templates/wasm/typescript/polywrap.test.cue deleted file mode 100644 index 72c37000a6..0000000000 --- a/packages/templates/wasm/typescript/polywrap.test.cue +++ /dev/null @@ -1,11 +0,0 @@ -package e2e - -sampleMethod: { - $0: { - data: { - value: "polywrap from sample_method" - }, - error?: _|_, - } -} - diff --git a/packages/templates/wasm/typescript/polywrap.test.yaml b/packages/templates/wasm/typescript/polywrap.test.yaml deleted file mode 100644 index 560e8b604e..0000000000 --- a/packages/templates/wasm/typescript/polywrap.test.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: template-wasm-ts -format: 0.1.0 -validation: "./polywrap.test.cue" -jobs: - sampleMethod: - steps: - - uri: fs/build - method: sampleMethod - args: - arg: "polywrap" diff --git a/packages/templates/wasm/typescript/polywrap.yaml b/packages/templates/wasm/typescript/polywrap.yaml index 8df1debb95..0442be181f 100644 --- a/packages/templates/wasm/typescript/polywrap.yaml +++ b/packages/templates/wasm/typescript/polywrap.yaml @@ -5,3 +5,5 @@ project: source: schema: ./polywrap.graphql module: ./bundled/wrap.js +extensions: + build: ./polywrap.build.yaml From 9cda9334e59cf35d95ec9e6cad9c59e430f1d786 Mon Sep 17 00:00:00 2001 From: krisbitney Date: Tue, 24 Oct 2023 18:26:03 +0500 Subject: [PATCH 3/8] removed unused typescript template test file --- .../src/__tests__/integration.spec.ts | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 packages/templates/wasm/typescript/src/__tests__/integration.spec.ts diff --git a/packages/templates/wasm/typescript/src/__tests__/integration.spec.ts b/packages/templates/wasm/typescript/src/__tests__/integration.spec.ts deleted file mode 100644 index 5793310246..0000000000 --- a/packages/templates/wasm/typescript/src/__tests__/integration.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { PolywrapClient } from "@polywrap/client-js"; -import path from "path"; - -jest.setTimeout(60000); - -describe("Template Wrapper End to End Tests", () => { - - const client: PolywrapClient = new PolywrapClient(); - let wrapUri = `file://${path.join(__dirname, "../../build")}`; - - it("invoke foo", async () => { - const result = await client.invoke({ - uri: wrapUri, - method: "foo", - args: { bar: "bar" } - }); - - expect(result.ok).toBeFalsy(); - if (result.ok) return; - expect(result.error?.toString()).toContain("Not implemented"); - }); -}); From 80c6eefd1dc4256e104acdba9c426fba268ea5dd Mon Sep 17 00:00:00 2001 From: krisbitney Date: Tue, 24 Oct 2023 19:06:53 +0500 Subject: [PATCH 4/8] wasm templates now use app codegen for testing --- .../src/__tests__/e2e/integration.spec.ts | 16 +++++----------- .../module/__tests__/e2e/integration.spec.ts | 16 +++++----------- .../src/__tests__/e2e/integration.spec.ts | 16 +++++----------- 3 files changed, 15 insertions(+), 33 deletions(-) diff --git a/packages/templates/wasm/assemblyscript/src/__tests__/e2e/integration.spec.ts b/packages/templates/wasm/assemblyscript/src/__tests__/e2e/integration.spec.ts index 55913c174a..68c84d6ee1 100644 --- a/packages/templates/wasm/assemblyscript/src/__tests__/e2e/integration.spec.ts +++ b/packages/templates/wasm/assemblyscript/src/__tests__/e2e/integration.spec.ts @@ -1,4 +1,3 @@ -import { PolywrapClient } from "@polywrap/client-js"; import * as App from "../types/wrap"; import path from "path"; @@ -6,26 +5,21 @@ jest.setTimeout(60000); describe("Template Wrapper End to End Tests", () => { - const client: PolywrapClient = new PolywrapClient(); + let template: App.Template; let wrapperUri: string; beforeAll(() => { - const dirname: string = path.resolve(__dirname); - const wrapperPath: string = path.join(dirname, "..", "..", ".."); + const wrapperPath: string = path.join(__dirname, "..", "..", ".."); wrapperUri = `fs/${wrapperPath}/build`; + template = new App.Template(undefined, undefined, wrapperUri) }) it("calls sampleMethod", async () => { const expected: string = "polywrap"; - const result = await client.invoke({ - uri: wrapperUri, - method: "sampleMethod", - args: { arg: expected } - }); + const result = await template.sampleMethod({ arg: expected }) - expect(result.ok).toBeTruthy(); - if (!result.ok) return; + if (!result.ok) throw result.error; expect(result.value.result).toEqual(expected); }); }); diff --git a/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts b/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts index 55913c174a..68c84d6ee1 100644 --- a/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts +++ b/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts @@ -1,4 +1,3 @@ -import { PolywrapClient } from "@polywrap/client-js"; import * as App from "../types/wrap"; import path from "path"; @@ -6,26 +5,21 @@ jest.setTimeout(60000); describe("Template Wrapper End to End Tests", () => { - const client: PolywrapClient = new PolywrapClient(); + let template: App.Template; let wrapperUri: string; beforeAll(() => { - const dirname: string = path.resolve(__dirname); - const wrapperPath: string = path.join(dirname, "..", "..", ".."); + const wrapperPath: string = path.join(__dirname, "..", "..", ".."); wrapperUri = `fs/${wrapperPath}/build`; + template = new App.Template(undefined, undefined, wrapperUri) }) it("calls sampleMethod", async () => { const expected: string = "polywrap"; - const result = await client.invoke({ - uri: wrapperUri, - method: "sampleMethod", - args: { arg: expected } - }); + const result = await template.sampleMethod({ arg: expected }) - expect(result.ok).toBeTruthy(); - if (!result.ok) return; + if (!result.ok) throw result.error; expect(result.value.result).toEqual(expected); }); }); diff --git a/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts b/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts index 55913c174a..68c84d6ee1 100644 --- a/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts +++ b/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts @@ -1,4 +1,3 @@ -import { PolywrapClient } from "@polywrap/client-js"; import * as App from "../types/wrap"; import path from "path"; @@ -6,26 +5,21 @@ jest.setTimeout(60000); describe("Template Wrapper End to End Tests", () => { - const client: PolywrapClient = new PolywrapClient(); + let template: App.Template; let wrapperUri: string; beforeAll(() => { - const dirname: string = path.resolve(__dirname); - const wrapperPath: string = path.join(dirname, "..", "..", ".."); + const wrapperPath: string = path.join(__dirname, "..", "..", ".."); wrapperUri = `fs/${wrapperPath}/build`; + template = new App.Template(undefined, undefined, wrapperUri) }) it("calls sampleMethod", async () => { const expected: string = "polywrap"; - const result = await client.invoke({ - uri: wrapperUri, - method: "sampleMethod", - args: { arg: expected } - }); + const result = await template.sampleMethod({ arg: expected }) - expect(result.ok).toBeTruthy(); - if (!result.ok) return; + if (!result.ok) throw result.error; expect(result.value.result).toEqual(expected); }); }); From d4177823e89f1c63aaca23f35ba317274bec2c6b Mon Sep 17 00:00:00 2001 From: krisbitney Date: Tue, 24 Oct 2023 19:55:46 +0500 Subject: [PATCH 5/8] fixed typo in Golang test script --- packages/templates/wasm/golang/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/templates/wasm/golang/package.json b/packages/templates/wasm/golang/package.json index 4c51a15127..7d4a4e525f 100644 --- a/packages/templates/wasm/golang/package.json +++ b/packages/templates/wasm/golang/package.json @@ -7,7 +7,7 @@ "codegen": "npx polywrap codegen", "build": "npx polywrap build", "deploy": "npx polywrap deploy", - "test": "yarn test:e2e:codegen && jest --passWithNoTests --runInBand --verbose", + "test": "yarn test:codegen && jest --passWithNoTests --runInBand --verbose", "test:codegen": "npx polywrap codegen -m ./module/__tests__/types/polywrap.app.yaml -g ./module/__tests__/types/wrap" }, "devDependencies": { From 49b89cac10dbefbb88a81e04851f6b2a440e1403 Mon Sep 17 00:00:00 2001 From: krisbitney Date: Fri, 27 Oct 2023 12:26:46 +0500 Subject: [PATCH 6/8] fixed rust plugin template test --- packages/templates/plugin/rust/Cargo.toml | 8 ++++---- packages/templates/plugin/rust/tests/e2e.rs | 19 +++++++------------ ...wrap.wasm-assemblyscript-linked.build.yaml | 2 +- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/packages/templates/plugin/rust/Cargo.toml b/packages/templates/plugin/rust/Cargo.toml index 57d2f68633..1fe73f4514 100644 --- a/packages/templates/plugin/rust/Cargo.toml +++ b/packages/templates/plugin/rust/Cargo.toml @@ -11,11 +11,11 @@ include = [ ] [dependencies] -polywrap_core = { version = "~0.1.8" } -polywrap_plugin = { version = "~0.1.8" } +polywrap_core = { version = "~0.1.9-beta.2" } +polywrap_plugin = { version = "~0.1.9-beta.2" } polywrap_msgpack_serde = { version = "~0.0.2-beta.7" } -wrap_manifest_schemas = { version = "~0.1.8" } +wrap_manifest_schemas = { version = "~0.1.9-beta.2" } serde = {version = "1.0.145", features = ["derive"]} [dev-dependencies] -polywrap_client = { version = "~0.1.8" } +polywrap_client = { version = "~0.1.9-beta.2" } diff --git a/packages/templates/plugin/rust/tests/e2e.rs b/packages/templates/plugin/rust/tests/e2e.rs index f8a9c346ac..01afa205d1 100644 --- a/packages/templates/plugin/rust/tests/e2e.rs +++ b/packages/templates/plugin/rust/tests/e2e.rs @@ -1,30 +1,25 @@ use template_plugin_rs::SamplePlugin; use template_plugin_rs::wrap::module::ArgsSampleMethod; -use polywrap_core::{ - client::ClientConfig, - uri::Uri, -}; +use polywrap_core::uri::Uri; use polywrap_plugin::{package::PluginPackage}; use polywrap_client::{ - client::PolywrapClient, - builder::{PolywrapClientConfig, PolywrapClientConfigBuilder}, + client::Client, + builder::{ClientConfig, ClientConfigBuilder}, }; use polywrap_msgpack_serde::to_vec; -use std::{ - sync::{Arc, Mutex}, -}; +use std::sync::Arc; -fn get_client() -> PolywrapClient { +fn get_client() -> Client { let sample_plugin = SamplePlugin {}; let plugin_pkg = PluginPackage::::from(sample_plugin); - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config.add_package( Uri::try_from("plugin/sample").unwrap(), Arc::new(plugin_pkg) ); - PolywrapClient::new(config.into()) + Client::new(config.into()) } #[test] diff --git a/packages/templates/polywrap.wasm-assemblyscript-linked.build.yaml b/packages/templates/polywrap.wasm-assemblyscript-linked.build.yaml index 8df221b07c..45f8a76d55 100644 --- a/packages/templates/polywrap.wasm-assemblyscript-linked.build.yaml +++ b/packages/templates/polywrap.wasm-assemblyscript-linked.build.yaml @@ -2,7 +2,7 @@ format: 0.3.0 strategies: image: name: wrap-wasm-as-build-image - node_version: 16.13.0 + node_version: 18.15.0 include: - ./package.json - ./src From 3939cb459d40b90771c67ba89985bcd016b0dd0d Mon Sep 17 00:00:00 2001 From: krisbitney Date: Fri, 27 Oct 2023 12:30:52 +0500 Subject: [PATCH 7/8] Revert "fixed rust plugin template test" This reverts commit 49b89cac10dbefbb88a81e04851f6b2a440e1403. --- packages/templates/plugin/rust/Cargo.toml | 8 ++++---- packages/templates/plugin/rust/tests/e2e.rs | 19 ++++++++++++------- ...wrap.wasm-assemblyscript-linked.build.yaml | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/templates/plugin/rust/Cargo.toml b/packages/templates/plugin/rust/Cargo.toml index 1fe73f4514..57d2f68633 100644 --- a/packages/templates/plugin/rust/Cargo.toml +++ b/packages/templates/plugin/rust/Cargo.toml @@ -11,11 +11,11 @@ include = [ ] [dependencies] -polywrap_core = { version = "~0.1.9-beta.2" } -polywrap_plugin = { version = "~0.1.9-beta.2" } +polywrap_core = { version = "~0.1.8" } +polywrap_plugin = { version = "~0.1.8" } polywrap_msgpack_serde = { version = "~0.0.2-beta.7" } -wrap_manifest_schemas = { version = "~0.1.9-beta.2" } +wrap_manifest_schemas = { version = "~0.1.8" } serde = {version = "1.0.145", features = ["derive"]} [dev-dependencies] -polywrap_client = { version = "~0.1.9-beta.2" } +polywrap_client = { version = "~0.1.8" } diff --git a/packages/templates/plugin/rust/tests/e2e.rs b/packages/templates/plugin/rust/tests/e2e.rs index 01afa205d1..f8a9c346ac 100644 --- a/packages/templates/plugin/rust/tests/e2e.rs +++ b/packages/templates/plugin/rust/tests/e2e.rs @@ -1,25 +1,30 @@ use template_plugin_rs::SamplePlugin; use template_plugin_rs::wrap::module::ArgsSampleMethod; -use polywrap_core::uri::Uri; +use polywrap_core::{ + client::ClientConfig, + uri::Uri, +}; use polywrap_plugin::{package::PluginPackage}; use polywrap_client::{ - client::Client, - builder::{ClientConfig, ClientConfigBuilder}, + client::PolywrapClient, + builder::{PolywrapClientConfig, PolywrapClientConfigBuilder}, }; use polywrap_msgpack_serde::to_vec; -use std::sync::Arc; +use std::{ + sync::{Arc, Mutex}, +}; -fn get_client() -> Client { +fn get_client() -> PolywrapClient { let sample_plugin = SamplePlugin {}; let plugin_pkg = PluginPackage::::from(sample_plugin); - let mut config = ClientConfig::new(); + let mut config = PolywrapClientConfig::new(); config.add_package( Uri::try_from("plugin/sample").unwrap(), Arc::new(plugin_pkg) ); - Client::new(config.into()) + PolywrapClient::new(config.into()) } #[test] diff --git a/packages/templates/polywrap.wasm-assemblyscript-linked.build.yaml b/packages/templates/polywrap.wasm-assemblyscript-linked.build.yaml index 45f8a76d55..8df221b07c 100644 --- a/packages/templates/polywrap.wasm-assemblyscript-linked.build.yaml +++ b/packages/templates/polywrap.wasm-assemblyscript-linked.build.yaml @@ -2,7 +2,7 @@ format: 0.3.0 strategies: image: name: wrap-wasm-as-build-image - node_version: 18.15.0 + node_version: 16.13.0 include: - ./package.json - ./src From a10464a379725336ab83adb67d5614cd1fcbcaa2 Mon Sep 17 00:00:00 2001 From: krisbitney Date: Tue, 31 Oct 2023 16:56:49 +0500 Subject: [PATCH 8/8] removed build manifests from wasm templates --- .../templates/wasm/assemblyscript/polywrap.build.yaml | 8 -------- packages/templates/wasm/assemblyscript/polywrap.yaml | 2 -- packages/templates/wasm/golang/polywrap.build.yaml | 4 ---- packages/templates/wasm/golang/polywrap.yaml | 4 +--- packages/templates/wasm/rust/polywrap.build.yaml | 4 ---- packages/templates/wasm/rust/polywrap.yaml | 4 +--- packages/templates/wasm/typescript/polywrap.build.yaml | 6 ------ packages/templates/wasm/typescript/polywrap.yaml | 2 -- 8 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 packages/templates/wasm/assemblyscript/polywrap.build.yaml delete mode 100644 packages/templates/wasm/golang/polywrap.build.yaml delete mode 100644 packages/templates/wasm/rust/polywrap.build.yaml delete mode 100644 packages/templates/wasm/typescript/polywrap.build.yaml diff --git a/packages/templates/wasm/assemblyscript/polywrap.build.yaml b/packages/templates/wasm/assemblyscript/polywrap.build.yaml deleted file mode 100644 index 4a90507972..0000000000 --- a/packages/templates/wasm/assemblyscript/polywrap.build.yaml +++ /dev/null @@ -1,8 +0,0 @@ -format: 0.3.0 -strategies: - image: - name: template-wasm-as - node_version: 18.15.0 - include: - - ./package.json - - ./src diff --git a/packages/templates/wasm/assemblyscript/polywrap.yaml b/packages/templates/wasm/assemblyscript/polywrap.yaml index 0474ff70bd..950f086093 100644 --- a/packages/templates/wasm/assemblyscript/polywrap.yaml +++ b/packages/templates/wasm/assemblyscript/polywrap.yaml @@ -5,5 +5,3 @@ project: source: module: ./src/index.ts schema: ./polywrap.graphql -extensions: - build: ./polywrap.build.yaml diff --git a/packages/templates/wasm/golang/polywrap.build.yaml b/packages/templates/wasm/golang/polywrap.build.yaml deleted file mode 100644 index 63fd363ddf..0000000000 --- a/packages/templates/wasm/golang/polywrap.build.yaml +++ /dev/null @@ -1,4 +0,0 @@ -format: 0.2.0 -strategies: - image: - name: template-wasm-go diff --git a/packages/templates/wasm/golang/polywrap.yaml b/packages/templates/wasm/golang/polywrap.yaml index 41560be606..d9b2de8b3a 100644 --- a/packages/templates/wasm/golang/polywrap.yaml +++ b/packages/templates/wasm/golang/polywrap.yaml @@ -4,6 +4,4 @@ project: type: wasm/golang source: schema: ./polywrap.graphql - module: ./go.mod -extensions: - build: ./polywrap.build.yaml + module: ./go.mod \ No newline at end of file diff --git a/packages/templates/wasm/rust/polywrap.build.yaml b/packages/templates/wasm/rust/polywrap.build.yaml deleted file mode 100644 index 875939c725..0000000000 --- a/packages/templates/wasm/rust/polywrap.build.yaml +++ /dev/null @@ -1,4 +0,0 @@ -format: 0.2.0 -strategies: - image: - name: template-wasm-rs \ No newline at end of file diff --git a/packages/templates/wasm/rust/polywrap.yaml b/packages/templates/wasm/rust/polywrap.yaml index a87ff9b728..11220fee06 100644 --- a/packages/templates/wasm/rust/polywrap.yaml +++ b/packages/templates/wasm/rust/polywrap.yaml @@ -4,6 +4,4 @@ project: type: wasm/rust source: module: ./Cargo.toml - schema: ./polywrap.graphql -extensions: - build: ./polywrap.build.yaml + schema: ./polywrap.graphql \ No newline at end of file diff --git a/packages/templates/wasm/typescript/polywrap.build.yaml b/packages/templates/wasm/typescript/polywrap.build.yaml deleted file mode 100644 index 096bdbcbb9..0000000000 --- a/packages/templates/wasm/typescript/polywrap.build.yaml +++ /dev/null @@ -1,6 +0,0 @@ -format: 0.3.0 -strategies: - image: - name: template-wasm-ts -config: - scriptFile: ./bundled/wrap.js \ No newline at end of file diff --git a/packages/templates/wasm/typescript/polywrap.yaml b/packages/templates/wasm/typescript/polywrap.yaml index 0442be181f..8df1debb95 100644 --- a/packages/templates/wasm/typescript/polywrap.yaml +++ b/packages/templates/wasm/typescript/polywrap.yaml @@ -5,5 +5,3 @@ project: source: schema: ./polywrap.graphql module: ./bundled/wrap.js -extensions: - build: ./polywrap.build.yaml