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

[vald-client-node]: Use vald-client-ci workflows for release and e2e #281

Merged
merged 9 commits into from
May 7, 2024
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
80 changes: 66 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 \
Expand Down Expand Up @@ -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
Expand All @@ -216,30 +229,69 @@ 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: npm/deps
npm/deps: \
.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/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)

$(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:
npm install

.PHONY: ci/deps/update
## update deps for CI environment
ci/deps/update:
npm update

.PHONY: ci/package/prepare
## prepare for publich
ci/package/prepare: \
ci/deps/install

.PHONY: ci/package/publish
## publich packages
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: proto/deps
## install proto deps
proto/deps: \
npm/deps
.PHONY: version/node
## Print Node version
version/node:
@echo $(NODE_VERSION)
1 change: 1 addition & 0 deletions NODE_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
Loading