diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8b0e33b --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +/_build/ +*~ +.tags* +*.sublime-workspace +.DS_Store +*~ +\#* +.\#* +.tags* +rebar3.crashdump +include/*.hrl +src/*.erl \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ca5a761 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "build_utils"] + path = build_utils + url = git@github.com:rbkmoney/build_utils.git + branch = master diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..22f6a89 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,37 @@ +#!groovy +// -*- mode: groovy -*- + +build('limiter-proto', 'docker-host') { + checkoutRepo() + loadBuildUtils() + + def pipeDefault + def gitUtils + runStage('load pipeline') { + env.JENKINS_LIB = "build_utils/jenkins_lib" + pipeDefault = load("${env.JENKINS_LIB}/pipeDefault.groovy") + gitUtils = load("${env.JENKINS_LIB}/gitUtils.groovy") + } + + pipeDefault() { + + runStage('compile') { + withGithubPrivkey { + sh "make submodules" + sh "make wc_compile" + } + } + + // Java + runStage('Execute build container') { + withCredentials([[$class: 'FileBinding', credentialsId: 'java-maven-settings.xml', variable: 'SETTINGS_XML']]) { + if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('epic/')) { + sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} wc_java.deploy' + } else { + sh 'make SETTINGS_XML=${SETTINGS_XML} wc_java.compile' + } + } + } + + } +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3e1c8c1 --- /dev/null +++ b/Makefile @@ -0,0 +1,83 @@ +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)) + +UTILS_PATH := build_utils +TEMPLATES_PATH := . + +# Name of the service +SERVICE_NAME := limiter_proto + +# Build image tag to be used +BUILD_IMAGE_TAG := eee42f2ca018c313190bc350fe47d4dea70b6d27 +CALL_ANYWHERE := \ + all submodules rebar-update compile clean distclean \ + java.compile java.deploy + +CALL_W_CONTAINER := $(CALL_ANYWHERE) + +all: compile + +-include $(UTILS_PATH)/make_lib/utils_container.mk + +.PHONY: $(CALL_W_CONTAINER) + +# CALL_ANYWHERE +$(SUBTARGETS): %/.git: % + git submodule update --init $< + touch $@ + +submodules: $(SUBTARGETS) + +rebar-update: + $(REBAR) update + +compile: submodules + $(REBAR) compile + +clean: + $(REBAR) clean + +distclean: + $(REBAR) clean -a + rm -rfv _build _builds _cache _steps _temp + +# Java + +ifdef SETTINGS_XML +DOCKER_RUN_OPTS = -v $(SETTINGS_XML):$(SETTINGS_XML) +DOCKER_RUN_OPTS += -e SETTINGS_XML=$(SETTINGS_XML) +endif + +ifdef LOCAL_BUILD +DOCKER_RUN_OPTS += -v $$HOME/.m2:/home/$(UNAME)/.m2:rw +endif + +COMMIT_HASH := $(shell git --no-pager log -1 --pretty=format:"%h") +NUMBER_COMMITS := $(shell git rev-list --count HEAD) + +JAVA_PKG_VERSION := 1.$(NUMBER_COMMITS)-$(COMMIT_HASH) + +ifdef BRANCH_NAME +ifeq "$(findstring epic,$(BRANCH_NAME))" "epic" +JAVA_PKG_VERSION := $(JAVA_PKG_VERSION)-epic +endif +endif + +MVN = mvn -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT)" -Dcommit.number="$(NUMBER_COMMITS)" + +java.compile: java.settings + $(MVN) compile + +java.deploy: java.settings + $(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)" && \ + $(MVN) deploy + +java.install: java.settings + $(MVN) clean && \ + $(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)" && \ + $(MVN) install + +java.settings: + $(if $(SETTINGS_XML),, echo "SETTINGS_XML not defined"; exit 1) diff --git a/README.md b/README.md new file mode 100644 index 0000000..3dc93d5 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# bender-proto +Thrift protocol for bender service diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..96f7877 --- /dev/null +++ b/pom.xml @@ -0,0 +1,90 @@ + + + 4.0.0 + + + com.rbkmoney + parent + 1.0.0 + + + com.rbkmoney + limiter-proto + 1.0.0 + jar + + limiter + Generates jar artifact containing compiled thrift classes based on generated thrift IDL files + + + UTF-8 + + + + + com.rbkmoney.woody + woody-thrift + LATEST + provided + + + com.rbkmoney + msgpack-proto + LATEST + + + + + ${project.artifactId} + + + + + org.apache.thrift + thrift-maven-plugin + 0.9.3-1 + + java:fullcamel + ${project.basedir}/proto + ${path_to_thrift} + + + + thrift-sources + generate-sources + + compile + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.0.0 + + + package + + shade + + + + + com.rbkmoney.limiter + com.rbkmoney.limiter.v${commit.number} + + + true + v${commit.number} + + + + + + + + diff --git a/proto/limiter.thrift b/proto/limiter.thrift new file mode 100644 index 0000000..7b9d2dc --- /dev/null +++ b/proto/limiter.thrift @@ -0,0 +1,7 @@ +namespace java com.rbkmoney.limiter +namespace erlang limiter + +include "proto/msgpack.thrift" + +typedef string Test + diff --git a/rebar.config b/rebar.config new file mode 100644 index 0000000..a2350ad --- /dev/null +++ b/rebar.config @@ -0,0 +1,76 @@ +%% Common project erlang options. +{erl_opts, [ + + % mandatory + debug_info, + warnings_as_errors, + warn_export_all, + warn_missing_spec, + warn_untyped_record, + warn_export_vars, + + % by default + warn_unused_record, + warn_bif_clash, + warn_obsolete_guard, + warn_unused_vars, + warn_shadow_vars, + warn_unused_import, + warn_unused_function, + warn_deprecated_function, + + % at will + % bin_opt_info + % no_auto_import, + warn_missing_spec_all +]}. + +{deps, [ + {msgpack_proto, + {git, "git@github.com:rbkmoney/msgpack-proto.git", + {branch, "master"}} + } +]}. + +%% XRef checks +{xref_checks, [ + undefined_function_calls, + undefined_functions, + deprecated_functions_calls, + deprecated_functions +]}. + +%% Tests +{cover_enabled, true}. + +%% Dialyzer static analyzing +{dialyzer, [ + {warnings, [ + % mandatory + unmatched_returns, + error_handling, + race_conditions, + unknown + ]}, + {plt_apps, all_deps} +]}. + +{plugins, [ + {rebar3_thrift_compiler, + {git, "https://github.com/rbkmoney/rebar3_thrift_compiler.git", {branch, "master"}}} +]}. + +{provider_hooks, [ + {pre, [ + {compile, {thrift, compile}}, + {clean , {thrift, clean }} + ]} +]}. + +{thrift_compiler_opts, [ + {in_dir, "proto"}, + {in_files, [ + "limiter.thrift" + ]}, + {gen, "erlang:scoped_typenames"} +]}. diff --git a/src/limiter_proto.app.src b/src/limiter_proto.app.src new file mode 100644 index 0000000..2e4cf21 --- /dev/null +++ b/src/limiter_proto.app.src @@ -0,0 +1,11 @@ +{application, limiter_proto, [ + {description, "Thrift proto for Limiter"}, + {vsn, "1.0.0"}, + {applications, [ + kernel, + stdlib + ]}, + {maintainers, [ + "Artem Fedorenko " + ]} +]}.