From f77fe12ca2a338b971a767af02a112cf047a72e8 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 7 May 2024 12:04:51 +0900 Subject: [PATCH 1/9] feat: add make command to support two version feature Signed-off-by: hlts2 --- Makefile | 72 ++++++++++++++++++++++++++++++++++++++++++++++------ NODE_VERSION | 1 + 2 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 NODE_VERSION diff --git a/Makefile b/Makefile index 70b7c34f..b571217f 100755 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ VALD_CLIENT_NODE_VERSION = VALD_CLIENT_NODE_VERSION PWD := $(eval PWD := $(shell pwd))$(PWD) PROTO_ROOT = $(VALD_DIR)/apis/proto +NODE_VERSION := $(eval NODE_VERSION := $(shell cat NODE_VERSION))$(NODE_VERSION) NODE_ROOT = src NPM_BIN = $(shell npm prefix) @@ -38,6 +39,8 @@ BUF_CONFIGS = \ SHADOW_ROOT = vald SHADOW_PROTO_ROOT = $(SHADOW_ROOT)/$(SHADOW_ROOT) +TEST_DATASET_PATH = tests/wordvecs1000.json + PROTOS = \ v1/agent/core/agent.proto \ v1/vald/filter.proto \ @@ -207,7 +210,17 @@ $(NODE_ROOT)/$(SHADOW_ROOT)/%_grpc_pb.js: $(SHADOW_PROTO_ROOT)/%.proto $(BUF_GEN_PATH) generate --include-imports $(VALD_DIR): - git clone --depth 1 https://$(VALDREPO) $(VALD_DIR) + git clone https://$(VALDREPO) $(VALD_DIR) + +.PHONY: vald/checkout +## checkout vald repository +vald/checkout: $(VALD_DIR) + cd $(VALD_DIR) && git checkout $(VALD_CHECKOUT_REF) + +.PHONY: vald/origin/sha/print +## print origin VALD_SHA value +vald/origin/sha/print: $(VALD_DIR) + @cd $(VALD_DIR) && git rev-parse HEAD | tr -d '\n' .PHONY: vald/sha/print ## print VALD_SHA value @@ -216,22 +229,47 @@ vald/sha/print: .PHONY: vald/sha/update ## update VALD_SHA value -vald/sha/update: vald - (cd vald; git rev-parse HEAD > ../$(VALD_SHA)) +vald/sha/update: $(VALD_DIR) + (cd $(VALD_DIR); git rev-parse HEAD | tr -d '\n' > ../$(VALD_SHA)) -.PHONY: vald/client/node/version/print -## print VALD_CLIENT_NODE_VERSION value -vald/client/node/version/print: +.PHONY: vald/client/version/print +## print VALD_CLIENT_JAVA_VERSION value +vald/client/version/print: @cat $(VALD_CLIENT_NODE_VERSION) -.PHONY: vald/client/node/version/update +.PHONY: vald/client/version/update ## update VALD_CLIENT_NODE_VERSION value -vald/client/node/version/update: vald +vald/client/version/update: $(VALD_DIR) (vald_version=`cat $(VALD_DIR)/versions/VALD_VERSION | sed -e 's/^v//'`; \ echo "VALD_VERSION: $${vald_version}"; \ echo "$${vald_version}" > VALD_CLIENT_NODE_VERSION) sed -i -e "s/\"version\": \".*\",\$$/\"version\": \"`cat VALD_CLIENT_NODE_VERSION`\",/" package.json +.PHONY: test +## Execute test for CI environment +test: $(TEST_DATASET_PATH) + npm run test + + # verify example codes + npm pack + npm install -g ts-node + (version=$(shell $(MAKE) -s vald/client/node/version/print); \ + echo "vald-client-node version: $${version}"; \ + cd example-ts && npm install ../vald-client-node-$${version}.tgz -s -f; \ + DIM=300 ts-node example.ts; \ + cd ../example && npm install ../vald-client-node-$${version}.tgz -s -f; \ + DIM=300 node example.js) + +.PHONY: ci/deps/install +## install deps for CI environment +ci/deps/install: + npm install + +.PHONY: ci/deps/update +## update deps for CI environment +ci/deps/update: + @echo "Nothing do be done" + .PHONY: npm/deps npm/deps: \ $(BUF_GEN_PATH) @@ -243,3 +281,21 @@ $(BUF_GEN_PATH): ## install proto deps proto/deps: \ npm/deps + +$(TEST_DATASET_PATH): + curl -L https://raw.githubusercontent.com/rinx/word2vecjson/master/data/wordvecs1000.json -o $(TEST_DATASET_PATH) + +.PHONY: ci/package/prepare +## prepare for publich +ci/package/prepare: + @echo "Nothing do be done" + +.PHONY: ci/package/publish +## publich packages +ci/package/publish: + @echo "Nothing do be done" + +.PHONY: version/node +## Print Node version +version/node: + @echo $(NODE_VERSION) diff --git a/NODE_VERSION b/NODE_VERSION new file mode 100644 index 00000000..3c032078 --- /dev/null +++ b/NODE_VERSION @@ -0,0 +1 @@ +18 From 4967acd23c3e731435bbba734b40557e340cccc1 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 7 May 2024 12:14:55 +0900 Subject: [PATCH 2/9] fix: make command not found error Signed-off-by: hlts2 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b571217f..8e6273cf 100755 --- a/Makefile +++ b/Makefile @@ -253,7 +253,7 @@ test: $(TEST_DATASET_PATH) # verify example codes npm pack npm install -g ts-node - (version=$(shell $(MAKE) -s vald/client/node/version/print); \ + (version=$(shell $(MAKE) -s vald/client/version/print); \ echo "vald-client-node version: $${version}"; \ cd example-ts && npm install ../vald-client-node-$${version}.tgz -s -f; \ DIM=300 ts-node example.ts; \ From 89741882a321215830dc4c92431bb8511bd7b4f6 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 7 May 2024 12:20:08 +0900 Subject: [PATCH 3/9] fix: update node version Signed-off-by: hlts2 --- NODE_VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NODE_VERSION b/NODE_VERSION index 3c032078..2bd5a0a9 100644 --- a/NODE_VERSION +++ b/NODE_VERSION @@ -1 +1 @@ -18 +22 From 690536e4ca0295fc597550e4e32aa12d0c1fc66c Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 7 May 2024 13:20:28 +0900 Subject: [PATCH 4/9] fix: add debug job for build and test Signed-off-by: hlts2 --- .github/workflows/e2e.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 195ed555..2ae930a9 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -31,3 +31,27 @@ jobs: - uses: vdaas/vald-client-ci/.github/actions/e2e@feat/add-common-workflows with: client_type: node + build-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: debug for build + run: | + echo "Install dependencies" + make ci/deps/install + + echo "Build proto" + export GOPATH=$HOME/go + export PATH=$HOME/grpc-java:$PATH + make proto + make vald/sha/update + make vald/client/version/update + + echo "Update dependencies" + make ci/deps/update + + git diff + git diff --name-only + - uses: vdaas/vald-client-ci/.github/actions/e2e@feat/add-common-workflows + with: + client_type: node From dff080e3e065be9b4a942b7e115de3543a2f9d37 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 7 May 2024 13:32:50 +0900 Subject: [PATCH 5/9] fix: add command to publish Signed-off-by: hlts2 --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8e6273cf..119a7fc7 100755 --- a/Makefile +++ b/Makefile @@ -287,13 +287,12 @@ $(TEST_DATASET_PATH): .PHONY: ci/package/prepare ## prepare for publich -ci/package/prepare: - @echo "Nothing do be done" +ci/package/prepare: ci/deps/install .PHONY: ci/package/publish ## publich packages ci/package/publish: - @echo "Nothing do be done" + npm publish .PHONY: version/node ## Print Node version From 070f96c78d9c50390f0446d35f98596ffab875b9 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 7 May 2024 13:37:45 +0900 Subject: [PATCH 6/9] fix: tweak Signed-off-by: hlts2 --- .github/workflows/e2e.yaml | 3 +++ Makefile | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 2ae930a9..a36c950a 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -40,6 +40,9 @@ jobs: echo "Install dependencies" make ci/deps/install + NPM_BIN=$(npm prefix) + ls ${NPM_BIN}/node_modules/@bufbuild/buf/bin/buf + echo "Build proto" export GOPATH=$HOME/go export PATH=$HOME/grpc-java:$PATH diff --git a/Makefile b/Makefile index 119a7fc7..5c032523 100755 --- a/Makefile +++ b/Makefile @@ -270,8 +270,8 @@ ci/deps/install: ci/deps/update: @echo "Nothing do be done" -.PHONY: npm/deps -npm/deps: \ +.PHONY: npm/deps/install +npm/deps/install: \ $(BUF_GEN_PATH) $(BUF_GEN_PATH): @@ -280,14 +280,15 @@ $(BUF_GEN_PATH): .PHONY: proto/deps ## install proto deps proto/deps: \ - npm/deps + npm/deps/install $(TEST_DATASET_PATH): curl -L https://raw.githubusercontent.com/rinx/word2vecjson/master/data/wordvecs1000.json -o $(TEST_DATASET_PATH) .PHONY: ci/package/prepare ## prepare for publich -ci/package/prepare: ci/deps/install +ci/package/prepare: \ + ci/deps/install .PHONY: ci/package/publish ## publich packages From 71673924c8e3efe1b1d8a04a9facf0eb7dfe95a7 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 7 May 2024 14:06:11 +0900 Subject: [PATCH 7/9] fix: refactor for makefile Signed-off-by: hlts2 --- Makefile | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 5c032523..89b5583f 100755 --- a/Makefile +++ b/Makefile @@ -260,6 +260,9 @@ test: $(TEST_DATASET_PATH) cd ../example && npm install ../vald-client-node-$${version}.tgz -s -f; \ DIM=300 node example.js) +$(TEST_DATASET_PATH): + curl -L https://raw.githubusercontent.com/rinx/word2vecjson/master/data/wordvecs1000.json -o $(TEST_DATASET_PATH) + .PHONY: ci/deps/install ## install deps for CI environment ci/deps/install: @@ -270,21 +273,6 @@ ci/deps/install: ci/deps/update: @echo "Nothing do be done" -.PHONY: npm/deps/install -npm/deps/install: \ - $(BUF_GEN_PATH) - -$(BUF_GEN_PATH): - npm install --save-dev @bufbuild/buf @bufbuild/protobuf - -.PHONY: proto/deps -## install proto deps -proto/deps: \ - npm/deps/install - -$(TEST_DATASET_PATH): - curl -L https://raw.githubusercontent.com/rinx/word2vecjson/master/data/wordvecs1000.json -o $(TEST_DATASET_PATH) - .PHONY: ci/package/prepare ## prepare for publich ci/package/prepare: \ @@ -295,6 +283,14 @@ ci/package/prepare: \ ci/package/publish: npm publish +.PHONY: proto/deps/install +## install proto deps +proto/deps/install: \ + $(BUF_GEN_PATH) + +$(BUF_GEN_PATH): + npm install --save-dev @bufbuild/buf @bufbuild/protobuf + .PHONY: version/node ## Print Node version version/node: From ddfd23407699264b2fa91acab9fbebae4b8702b7 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 7 May 2024 14:39:09 +0900 Subject: [PATCH 8/9] fix: npm update command Signed-off-by: hlts2 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 89b5583f..2052a633 100755 --- a/Makefile +++ b/Makefile @@ -271,7 +271,7 @@ ci/deps/install: .PHONY: ci/deps/update ## update deps for CI environment ci/deps/update: - @echo "Nothing do be done" + npm update .PHONY: ci/package/prepare ## prepare for publich From 008c1764cd9e6626c21ddaa7a6de5118b237eb38 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 7 May 2024 15:14:56 +0900 Subject: [PATCH 9/9] fix: deleted debug job for e2e and build proto Signed-off-by: hlts2 --- .github/workflows/e2e.yaml | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index a36c950a..195ed555 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -31,30 +31,3 @@ jobs: - uses: vdaas/vald-client-ci/.github/actions/e2e@feat/add-common-workflows with: client_type: node - build-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: debug for build - run: | - echo "Install dependencies" - make ci/deps/install - - NPM_BIN=$(npm prefix) - ls ${NPM_BIN}/node_modules/@bufbuild/buf/bin/buf - - echo "Build proto" - export GOPATH=$HOME/go - export PATH=$HOME/grpc-java:$PATH - make proto - make vald/sha/update - make vald/client/version/update - - echo "Update dependencies" - make ci/deps/update - - git diff - git diff --name-only - - uses: vdaas/vald-client-ci/.github/actions/e2e@feat/add-common-workflows - with: - client_type: node