From 57ff62ed9c74d43f01cc73e006ddebad314b3a19 Mon Sep 17 00:00:00 2001 From: Sergey Yelin Date: Fri, 4 Sep 2020 11:05:09 +0300 Subject: [PATCH 1/3] MSPF-544: Generate release --- Jenkinsfile | 45 ++++++++++++++-------- Makefile | 108 +++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 115 insertions(+), 38 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b364359..29ec25c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,25 +2,38 @@ // -*- mode: groovy -*- build('pstds-proto', 'docker-host') { - checkoutRepo() - loadBuildUtils() + checkoutRepo() + loadBuildUtils() - def pipeDefault - def gitUtils - runStage('load pipeline') { - env.JENKINS_LIB = "build_utils/jenkins_lib" - pipeDefault = load("${env.JENKINS_LIB}/pipeDefault.groovy") - pipeJavaProto = load("${env.JENKINS_LIB}/pipeJavaProto.groovy") - gitUtils = load("${env.JENKINS_LIB}/gitUtils.groovy") + def pipeDefault + def gitUtils + runStage('load pipeline') { + env.JENKINS_LIB = "build_utils/jenkins_lib" + pipeDefault = load("${env.JENKINS_LIB}/pipeDefault.groovy") + pipeJavaProto = load("${env.JENKINS_LIB}/pipeJavaProto.groovy") + gitUtils = load("${env.JENKINS_LIB}/gitUtils.groovy") + } + + pipeDefault() { + + runStage('compile') { + sh "make wc_compile" } - pipeDefault() { - - runStage('compile') { - sh "make wc_compile" + // Erlang + runStage('Generate Erlang lib') { + sh "make wc_release-erlang" + } + if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('epic/')) { + runStage('Publish Erlang lib') { + dir("_release/erlang") { + gitUtils.push(commitMsg: "Generated from commit: $COMMIT_ID \n\non $BRANCH_NAME in $RBK_REPO_URL\n\nChanges:\n$COMMIT_MSG", + files: "*", branch: "release/erlang/$BRANCH_NAME", orphan: true) } - - env.skipSonar = 'true' - pipeJavaProto() + } } + } + + env.skipSonar = 'true' + pipeJavaProto() } diff --git a/Makefile b/Makefile index ea496f2..2b9a7c2 100644 --- a/Makefile +++ b/Makefile @@ -1,42 +1,106 @@ THRIFT = $(or $(shell which thrift), $(error "`thrift' executable missing")) -REBAR = $(shell which rebar3 2>/dev/null || which ./rebar3) -SUBMODULES = build_utils -SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES)) +THRIFT_LANGUAGES = erlang java +THRIFT_OPTIONS_erlang = scoped_typenames +THRIFT_OPTIONS_java = fullcamel +THRIFT_OPTIONS_html = standalone UTILS_PATH := build_utils TEMPLATES_PATH := . # Name of the service -SERVICE_NAME := pstds_proto +SERVICE_NAME := pstds-proto +# Service image default tag +SERVICE_IMAGE_TAG ?= $(shell git rev-parse HEAD) +# The tag for service image to be pushed with +SERVICE_IMAGE_PUSH_TAG ?= $(SERVICE_IMAGE_TAG) -# Build image tag to be used -BUILD_IMAGE_TAG := b04c5291d101132e53e578d96e1628d2e6dab0c0 -CALL_ANYWHERE := \ - all submodules compile clean distclean +BUILD_IMAGE_TAG := 4536c31941b9c27c134e8daf0fd18848809219c9 -CALL_W_CONTAINER := $(CALL_ANYWHERE) +PROTODIR = proto +FILES = $(wildcard $(PROTODIR)/*.thrift) +DESTDIR = _gen +RELDIR = _release + +CALL_W_CONTAINER := \ + all compile doc clean release-erlang all: compile -include $(UTILS_PATH)/make_lib/utils_container.mk -.PHONY: $(CALL_W_CONTAINER) +define generate + $(THRIFT) -r -strict --gen $(1):$(THRIFT_OPTIONS_$(1)) -out $(2) $(3) +endef -# CALL_ANYWHERE -$(SUBTARGETS): %/.git: % - git submodule update --init $< - touch $@ +define targets + $(patsubst %, $(DESTDIR)/$(1)/%, $(FILES)) +endef -submodules: $(SUBTARGETS) +CUTLINE = $(shell printf '=%.0s' $$(seq 1 80)) -compile: - $(REBAR) compile +.PHONY: all compile doc clean -clean: - $(REBAR) clean +LANGUAGE_TARGETS = $(foreach lang, $(THRIFT_LANGUAGES), verify-$(lang)) -distclean: - $(REBAR) clean -a - rm -rfv _build +compile: $(LANGUAGE_TARGETS) + @echo "Ok" + +verify-%: $(DESTDIR) + @echo "Verifying '$*' ..." + @echo $(CUTLINE) + @$(MAKE) LANGUAGE=$* $(call targets,$*) + @echo + +TARGETS = $(call targets,$(LANGUAGE)) + +$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: % + mkdir -p $@ + $(call generate,$(LANGUAGE),$@,$<) + +clean:: + rm -rf $(DESTDIR) + +REPODIR = $(abspath $(RELDIR)/$*) +DOCKER_RUN_OPTS := -e BRANCH_NAME + +release-%: $(RELDIR) + @echo "Making '$*' release ..." + @echo $(CUTLINE) + @rm -rf $(REPODIR) + $(MAKE) LANGUAGE=$* DESTDIR=$(REPODIR) build-release + +clean:: + rm -rf $(RELDIR) + +$(DESTDIR): +$(RELDIR): + @mkdir -p $@ + +# Docs + +DOCDIR = doc +DOCTARGETS = $(patsubst %.thrift, $(DOCDIR)/%.html, $(FILES)) + +doc: $(DOCTARGETS) + +$(DOCTARGETS): $(DOCDIR)/%.html: %.thrift + mkdir -p $(dir $@) + $(call generate,html,$(dir $@),$<) + +# Erlang + +ERLC ?= erlc + +ifeq ($(LANGUAGE), erlang) +ifneq ($(shell which $(ERLC)),) + +$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: % + $(ERLC) -v -I$@ -o$@ $(shell find $@ -name "*.erl") + +build-release: + @make THRIFT="$(THRIFT)" FILES="$(abspath $(FILES))" PROTO="$(abspath $(PROTODIR))" -C build/erlang release + +endif +endif include $(UTILS_PATH)/make_lib/java_proto.mk From bf41164b84a9683272cc2a5f00188f85976d7475 Mon Sep 17 00:00:00 2001 From: Sergey Yelin Date: Fri, 4 Sep 2020 13:41:39 +0300 Subject: [PATCH 2/3] Fix build --- Jenkinsfile | 17 +-------- Makefile | 108 +++++++++++----------------------------------------- 2 files changed, 24 insertions(+), 101 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 29ec25c..4c3edd9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,20 +20,7 @@ build('pstds-proto', 'docker-host') { sh "make wc_compile" } - // Erlang - runStage('Generate Erlang lib') { - sh "make wc_release-erlang" - } - if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('epic/')) { - runStage('Publish Erlang lib') { - dir("_release/erlang") { - gitUtils.push(commitMsg: "Generated from commit: $COMMIT_ID \n\non $BRANCH_NAME in $RBK_REPO_URL\n\nChanges:\n$COMMIT_MSG", - files: "*", branch: "release/erlang/$BRANCH_NAME", orphan: true) - } - } - } + env.skipSonar = 'true' + pipeJavaProto() } - - env.skipSonar = 'true' - pipeJavaProto() } diff --git a/Makefile b/Makefile index 2b9a7c2..ea496f2 100644 --- a/Makefile +++ b/Makefile @@ -1,106 +1,42 @@ THRIFT = $(or $(shell which thrift), $(error "`thrift' executable missing")) -THRIFT_LANGUAGES = erlang java -THRIFT_OPTIONS_erlang = scoped_typenames -THRIFT_OPTIONS_java = fullcamel -THRIFT_OPTIONS_html = standalone +REBAR = $(shell which rebar3 2>/dev/null || which ./rebar3) +SUBMODULES = build_utils +SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES)) UTILS_PATH := build_utils TEMPLATES_PATH := . # Name of the service -SERVICE_NAME := pstds-proto -# Service image default tag -SERVICE_IMAGE_TAG ?= $(shell git rev-parse HEAD) -# The tag for service image to be pushed with -SERVICE_IMAGE_PUSH_TAG ?= $(SERVICE_IMAGE_TAG) +SERVICE_NAME := pstds_proto -BUILD_IMAGE_TAG := 4536c31941b9c27c134e8daf0fd18848809219c9 +# Build image tag to be used +BUILD_IMAGE_TAG := b04c5291d101132e53e578d96e1628d2e6dab0c0 +CALL_ANYWHERE := \ + all submodules compile clean distclean -PROTODIR = proto -FILES = $(wildcard $(PROTODIR)/*.thrift) -DESTDIR = _gen -RELDIR = _release - -CALL_W_CONTAINER := \ - all compile doc clean release-erlang +CALL_W_CONTAINER := $(CALL_ANYWHERE) all: compile -include $(UTILS_PATH)/make_lib/utils_container.mk -define generate - $(THRIFT) -r -strict --gen $(1):$(THRIFT_OPTIONS_$(1)) -out $(2) $(3) -endef +.PHONY: $(CALL_W_CONTAINER) -define targets - $(patsubst %, $(DESTDIR)/$(1)/%, $(FILES)) -endef +# CALL_ANYWHERE +$(SUBTARGETS): %/.git: % + git submodule update --init $< + touch $@ -CUTLINE = $(shell printf '=%.0s' $$(seq 1 80)) +submodules: $(SUBTARGETS) -.PHONY: all compile doc clean +compile: + $(REBAR) compile -LANGUAGE_TARGETS = $(foreach lang, $(THRIFT_LANGUAGES), verify-$(lang)) +clean: + $(REBAR) clean -compile: $(LANGUAGE_TARGETS) - @echo "Ok" - -verify-%: $(DESTDIR) - @echo "Verifying '$*' ..." - @echo $(CUTLINE) - @$(MAKE) LANGUAGE=$* $(call targets,$*) - @echo - -TARGETS = $(call targets,$(LANGUAGE)) - -$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: % - mkdir -p $@ - $(call generate,$(LANGUAGE),$@,$<) - -clean:: - rm -rf $(DESTDIR) - -REPODIR = $(abspath $(RELDIR)/$*) -DOCKER_RUN_OPTS := -e BRANCH_NAME - -release-%: $(RELDIR) - @echo "Making '$*' release ..." - @echo $(CUTLINE) - @rm -rf $(REPODIR) - $(MAKE) LANGUAGE=$* DESTDIR=$(REPODIR) build-release - -clean:: - rm -rf $(RELDIR) - -$(DESTDIR): -$(RELDIR): - @mkdir -p $@ - -# Docs - -DOCDIR = doc -DOCTARGETS = $(patsubst %.thrift, $(DOCDIR)/%.html, $(FILES)) - -doc: $(DOCTARGETS) - -$(DOCTARGETS): $(DOCDIR)/%.html: %.thrift - mkdir -p $(dir $@) - $(call generate,html,$(dir $@),$<) - -# Erlang - -ERLC ?= erlc - -ifeq ($(LANGUAGE), erlang) -ifneq ($(shell which $(ERLC)),) - -$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: % - $(ERLC) -v -I$@ -o$@ $(shell find $@ -name "*.erl") - -build-release: - @make THRIFT="$(THRIFT)" FILES="$(abspath $(FILES))" PROTO="$(abspath $(PROTODIR))" -C build/erlang release - -endif -endif +distclean: + $(REBAR) clean -a + rm -rfv _build include $(UTILS_PATH)/make_lib/java_proto.mk From 7a3079217224ebe0c1de3c6faf66b80e70b1f74c Mon Sep 17 00:00:00 2001 From: Sergey Yelin Date: Fri, 4 Sep 2020 13:48:46 +0300 Subject: [PATCH 3/3] Add erlang application file --- src/pstds_proto.app.src | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/pstds_proto.app.src diff --git a/src/pstds_proto.app.src b/src/pstds_proto.app.src new file mode 100644 index 0000000..04be23a --- /dev/null +++ b/src/pstds_proto.app.src @@ -0,0 +1,13 @@ +{application, pstds_proto, + [{description, "Payment System Token Data Storage"}, + {vsn, "0.1.0"}, + {registered, []}, + {applications, + [kernel, + stdlib + ]}, + {env,[]}, + {modules, []}, + + {licenses, ["Apache 2.0"]} + ]}.