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

[WIP]: Support two version deploy #26

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/vald-origin
/vald
wordvecs1000.json

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
78 changes: 52 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ LANGUAGE = python
PKGNAME = $(NAME)-client-$(LANGUAGE)
PKGREPO = github.com/$(REPO)/$(PKGNAME)

PYTHON = python

VALD_DIR = vald-origin
VALD_SHA = VALD_SHA
VALD_CLIENT_PYTHON_VERSION = VALD_CLIENT_PYTHON_VERSION
VALD_CHECKOUT_REF ?= main

BINDIR ?= /usr/local/bin

Expand Down Expand Up @@ -58,6 +57,9 @@ PB2PYS = $(PROTOS:$(PROTO_ROOT)/%.proto=$(PB2DIR_ROOT)/$(SHADOW_ROOT)/%_pb2.py)

MAKELISTS = Makefile

PYTHON_VERSION := $(eval PYTHON_VERSION := $(shell cat PYTHON_VERSION))$(PYTHON_VERSION)
TEST_DATASET_PATH = wordvecs1000.json

red = /bin/echo -e "\x1b[31m\#\# $1\x1b[0m"
green = /bin/echo -e "\x1b[32m\#\# $1\x1b[0m"
yellow = /bin/echo -e "\x1b[33m\#\# $1\x1b[0m"
Expand Down Expand Up @@ -112,7 +114,17 @@ $(PB2DIR_ROOT):
$(PB2PYS): proto/deps $(PB2DIR_ROOT) $(SHADOWS)

$(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 @@ -121,35 +133,20 @@ vald/sha/print:

.PHONY: vald/sha/update
## update VALD_SHA value
vald/sha/update: vald
(cd vald; git rev-parse HEAD | tr -d '\n' > ../$(VALD_SHA))
vald/sha/update: $(VALD_DIR)
(cd $(VALD_DIR); git rev-parse HEAD | tr -d '\n' > ../$(VALD_SHA))

.PHONY: vald/client/python/version/print
.PHONY: vald/client/version/print
## print VALD_CLIENT_PYTHON_VERSION value
vald/client/python/version/print:
vald/client/version/print:
@cat $(VALD_CLIENT_PYTHON_VERSION)

.PHONY: vald/client/python/version/update
.PHONY: vald/client/version/update
## update VALD_CLIENT_PYTHON_VERSION value
vald/client/python/version/update: vald
vald/client/version/update: $(VALD_DIR)
(vald_version=`cat $(VALD_DIR)/versions/VALD_VERSION | sed -e 's/^v//'`; \
client_version=`cat $(VALD_CLIENT_PYTHON_VERSION)`; \
major=$${client_version%%.*}; client_version="$${client_version#*.}"; \
minor=$${client_version%%.*}; client_version="$${client_version#*.}"; \
patch=$${client_version%%.*}; client_version="$${client_version#*.}"; \
if [ "$${vald_version}" = "$${major}.$${minor}.$${patch}" ]; then \
if [ "$${patch}" = "$${client_version}" ]; then \
new_version="$${major}.$${minor}.$${patch}.post1"; \
else \
rev="$${client_version#post}"; \
rev=$$((rev+1)); \
new_version="$${major}.$${minor}.$${patch}.post$${rev}"; \
fi; \
else \
new_version="$${vald_version}"; \
fi; \
echo "VALD_VERSION: $${vald_version}, NEW_CLIENT_VERSION: $${new_version}"; \
echo "$${new_version}" > VALD_CLIENT_PYTHON_VERSION)
echo "VALD_VERSION: $${vald_version}"; \
echo "$${vald_version}" > VALD_CLIENT_PYTHON_VERSION)
sed -i -e "s/^version = .*\$$/version = `cat VALD_CLIENT_PYTHON_VERSION`/" setup.cfg

.PHONY: proto/deps
Expand All @@ -166,3 +163,32 @@ $(BINDIR)/buf:
"https://github.com/bufbuild/buf/releases/download/$$version/buf-$(shell uname -s)-$(shell uname -m)" \
-o "${BINDIR}/buf" && \
chmod +x "${BINDIR}/buf"

.PHONY: ci/deps/install
## install deps for CI environment
ci/deps/install:
sudo apt-get update -y && sudo apt-get install -y \
python3-setuptools \
libprotobuf-dev \
libprotoc-dev \
protobuf-compiler
pip3 install grpcio-tools

.PHONY: ci/test
## Execute test for CI environment
ci/test: $(TEST_DATASET_PATH)
python src/test.py

$(TEST_DATASET_PATH):
curl -L https://raw.githubusercontent.com/rinx/word2vecjson/master/data/wordvecs1000.json -o $(TEST_DATASET_PATH)

.PHONY: ci/package/prepare
## prepare package to publish
ci/package/prepare:
python3 setup.py sdist
python3 setup.py bdist_wheel

.PHONY: version/python
## Print Python version
version/python:
@echo $(PYTHON_VERSION)
1 change: 1 addition & 0 deletions PYTHON_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
Loading