Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled E2E test for Typescript #63

Merged
merged 11 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ jobs:
run: |
npm install
npm pack
- name: verify example codes (ts)
run: |
kubectl port-forward statefulset/vald-agent-ngt 8081:8081 &
pid=$!

version=`make vald/client/node/version/print`
npm install -g ts-node

cd example-ts
npm install ../vald-client-node-${version}.tgz -s -f
DIM=300 ts-node example.ts

kill $pid
- name: verify example codes (js)
run: |
version=`make vald/client/node/version/print`
Expand All @@ -71,19 +84,6 @@ jobs:
DIM=300 node example.js

kill $pid
# - name: verify example codes (ts)
# run: |
# kubectl port-forward statefulset/vald-agent-ngt 8081:8081 &
# pid=$!
#
# version=`make vald/client/node/version/print`
# npm install -g ts-node
#
# cd example-ts
# npm install ../vald-client-node-${version}.tgz -s -f
# DIM=300 ts-node example.ts
#
# kill $pid
publish:
if: startsWith( github.ref, 'refs/tags/')
needs:
Expand Down
20 changes: 0 additions & 20 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ version: v1
managed:
enabled: true
plugins:
# - plugin: buf.build/protocolbuffers/js
# out: src/
# opt: import_style=commonjs
# - plugin: buf.build/grpc/node
# out: src
# opt: grpc_js,import_style=commonjs

- plugin: buf.build/community/timostamm-protobuf-ts
out: src
# https://github.com/timostamm/protobuf-ts/blob/main/MANUAL.md#the-protoc-plugin
Expand All @@ -22,16 +15,3 @@ plugins:
- output_javascript
- output_legacy_commonjs
- eslint_disable

# Failed because timeout type changed
# opt:
# - add_pb_suffix
# - client_grpc1
# - generate_dependencies
# - keep_enum_prefix
# - ts_nocheck
# - use_proto_field_name
# - output_javascript
# - optimize_code_size
# - long_type_string
# - eslint_disable
32 changes: 17 additions & 15 deletions example-ts/example.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as grpc from "@grpc/grpc-js";
import { v1_vald, v1_payload } from "vald-client-node";
import type { Insert_Request, Search_Request, Remove_Request } from "vald-client-node/src/vald/v1/payload/payload_pb";

const addr = "localhost:8081";
const DIM = process.env.DIM || 4;
Expand Down Expand Up @@ -38,7 +39,7 @@ const main = async () => {
grpc.credentials.createInsecure()
);

const insertFunc = (req: any) => {
const insertFunc = async (req: Insert_Request) => {
return new Promise((resolve, reject) => {
iclient.insert(req, (err, resp) => {
if (err) {
Expand All @@ -49,13 +50,13 @@ const main = async () => {
});
});
};
insertFunc(ireq)
.then(async (res) => {
console.log("resp: ", res);
await insertFunc(ireq)
.then((res) => {
console.log("insert resp: ", res);
})
.catch((e) => {
console.log("err: ", e);
return -1;
process.exit(1);
});

const second = 100;
Expand All @@ -79,7 +80,7 @@ const main = async () => {
grpc.credentials.createInsecure()
);

const searchFunc = (req: any) => {
const searchFunc = async (req: Search_Request) => {
return new Promise((resolve, reject) => {
sclient.search(req, (err, resp) => {
if (err) {
Expand All @@ -90,13 +91,13 @@ const main = async () => {
});
});
};
searchFunc(sreq)
.then((res: any) => {
console.log("res: ", res, "\n");
await searchFunc(sreq)
.then((res) => {
console.log("search res: ", res, "\n");
})
.catch((e) => {
console.log("err: ", e);
return -1;
process.exit(1);
});

// remove
Expand All @@ -117,7 +118,7 @@ const main = async () => {
grpc.credentials.createInsecure()
);

const removeFunc = (req: any) => {
const removeFunc = async (req: Remove_Request) => {
return new Promise((resolve, reject) => {
rclient.remove(req, (err, resp) => {
if (err) {
Expand All @@ -128,14 +129,15 @@ const main = async () => {
});
});
};
removeFunc(rreq)
.then((res: any) => {
console.log("res: ", res, "\n");
await removeFunc(rreq)
.then((res) => {
console.log("remove res: ", res, "\n");
})
.catch((e) => {
console.log("err: ", e);
return -1;
process.exit(1);
});
process.exit(0);
};

main();
11 changes: 11 additions & 0 deletions example-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"resolveJsonModule": true
}
}
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import v1_agent_core = require("./src/vald/v1/agent/core");
import v1_payload = require("./src/vald/v1/payload");
import v1_vald = require("./src/vald/v1/vald");
import v1_payload = require("./src/vald/v1/payload");
declare const _default: {
v1_agent_core: typeof v1_agent_core,
v1_payload: typeof v1_payload,
v1_vald: typeof v1_vald,
v1_payload: typeof v1_payload,
};
export = _default;
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports.v1_agent_core = require("./src/vald/v1/agent/core");
module.exports.v1_payload = require("./src/vald/v1/payload");
module.exports.v1_vald = require("./src/vald/v1/vald");
module.exports.v1_payload = require("./src/vald/v1/payload");
Loading
Loading