Skip to content

Commit

Permalink
Merge pull request #73 from vdaas/feat/support-two-version
Browse files Browse the repository at this point in the history
Introduced two version support feature
  • Loading branch information
hlts2 authored May 13, 2024
2 parents 9815269 + c60e827 commit d1263ca
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 190 deletions.
53 changes: 0 additions & 53 deletions .github/workflows/build.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Copyright (C) 2019-2024 vdaas.org vald team <vald@vdaas.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# DO NOT EDIT
name: "Run E2E test"
on:
push:
branches:
- main
pull_request:

jobs:
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: vdaas/vald-client-ci/.github/actions/e2e@main
with:
client_type: node
145 changes: 21 additions & 124 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,133 +1,30 @@
name: release
#
# Copyright (C) 2019-2024 vdaas.org vald team <vald@vdaas.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# DO NOT EDIT
name: "Run release"
on:
push:
branches:
- main
tags:
- '*.*.*'
- 'v*.*.*'
- '*.*.*-*'
- 'v*.*.*-*'
pull_request:

jobs:
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: rinx/setup-k3d@v0.0.4
with:
version: latest
name: vald
agents: 1
- name: check k3d
run: |
kubectl cluster-info
- uses: azure/setup-helm@v3
- name: Helm version
run: |
helm version
- name: deploy Vald
run: |
helm repo add vald https://vald.vdaas.org/charts
helm install \
--values ${VALUES} \
--set defaults.image.tag=nightly \
--set agent.ngt.dimension=300 \
--set agent.ngt.auto_index_length=2 \
--set agent.minReplicas=1 \
--set gateway.lb.enabled=false \
--set discoverer.enabled=false \
--set manager.index.enabled=false \
--generate-name vald/vald
sleep 3
kubectl wait --for=condition=ready pod -l app=vald-agent --timeout=3m
kubectl get pods
env:
VALUES: https://raw.githubusercontent.com/vdaas/vald/main/.github/helm/values/values-lb.yaml
- name: node dependencies
run: |
npm install
curl -L https://raw.githubusercontent.com/rinx/word2vecjson/master/data/wordvecs1000.json -o tests/wordvecs1000.json
- name: run tests
run: |
kubectl port-forward statefulset/vald-agent 8081:8081 &
pid=$!
npm run test
kill $pid
- name: packing for running example code
run: |
npm install
npm pack
- name: verify example codes (ts)
run: |
kubectl port-forward statefulset/vald-agent 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`
cd example && npm install ../vald-client-node-${version}.tgz -s -f
kubectl port-forward statefulset/vald-agent 8081:8081 &
pid=$!
DIM=300 node example.js
kill $pid
publish:
if: startsWith( github.ref, 'refs/tags/')
needs:
- e2e
runs-on: ubuntu-latest
steps:
- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Build
run: |
make npm/deps
export GOPATH=$HOME/go
make all
make vald/sha/update
make vald/client/node/version/update
rm -rf vald
- name: publish
run: |
npm install
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
release:
if: startsWith( github.ref, 'refs/tags/')
needs:
- e2e
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create release
if: startsWith( github.ref, 'refs/tags/')
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
uses: vdaas/vald-client-ci/.github/workflows/release.yaml@main
with:
client_type: node
secrets: inherit
30 changes: 30 additions & 0 deletions .github/workflows/sync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Copyright (C) 2019-2024 vdaas.org vald team <vald@vdaas.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# DO NOT EDIT
name: "Sync Vald"
on:
workflow_dispatch:
schedule:
- cron: "*/10 * * * *"
jobs:
sync:
uses: vdaas/vald-client-ci/.github/workflows/sync.yaml@main
with:
client_type: node
secrets:
CI_USER: ${{ secrets.CI_TOKEN }}
CI_TOKEN: ${{ secrets.CI_USER }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
79 changes: 66 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ PKGREPO = github.com/$(REPO)/$(PKGNAME)
VALD_DIR = vald-origin
VALD_SHA = VALD_SHA
VALD_CLIENT_NODE_VERSION = VALD_CLIENT_NODE_VERSION
VALD_CHECKOUT_REF ?= main

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 +40,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 +211,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 +230,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
.PHONY: vald/client/version/print
## print VALD_CLIENT_NODE_VERSION value
vald/client/node/version/print:
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

0 comments on commit d1263ca

Please sign in to comment.