This commit is contained in:
WWW_cool 2019-09-20 12:24:41 +03:00
parent e4f914f0e8
commit 52681fd0bf
9 changed files with 322 additions and 0 deletions

12
.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
/_build/
*~
.tags*
*.sublime-workspace
.DS_Store
*~
\#*
.\#*
.tags*
rebar3.crashdump
include/*.hrl
src/*.erl

4
.gitmodules vendored Normal file
View File

@ -0,0 +1,4 @@
[submodule "build_utils"]
path = build_utils
url = git@github.com:rbkmoney/build_utils.git
branch = master

37
Jenkinsfile vendored Normal file
View File

@ -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'
}
}
}
}
}

83
Makefile Normal file
View File

@ -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)

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# bender-proto
Thrift protocol for bender service

90
pom.xml Normal file
View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.rbkmoney</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
</parent>
<groupId>com.rbkmoney</groupId>
<artifactId>limiter-proto</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>limiter</name>
<description>Generates jar artifact containing compiled thrift classes based on generated thrift IDL files</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.rbkmoney.woody</groupId>
<artifactId>woody-thrift</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.rbkmoney</groupId>
<artifactId>msgpack-proto</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- THRIFT -->
<plugin>
<groupId>org.apache.thrift</groupId>
<artifactId>thrift-maven-plugin</artifactId>
<version>0.9.3-1</version>
<configuration>
<generator>java:fullcamel</generator>
<thriftSourceRoot>${project.basedir}/proto</thriftSourceRoot>
<thriftExecutable>${path_to_thrift}</thriftExecutable>
</configuration>
<executions>
<execution>
<id>thrift-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>com.rbkmoney.limiter</pattern>
<shadedPattern>com.rbkmoney.limiter.v${commit.number}</shadedPattern>
</relocation>
</relocations>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>v${commit.number}</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

7
proto/limiter.thrift Normal file
View File

@ -0,0 +1,7 @@
namespace java com.rbkmoney.limiter
namespace erlang limiter
include "proto/msgpack.thrift"
typedef string Test

76
rebar.config Normal file
View File

@ -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"}
]}.

11
src/limiter_proto.app.src Normal file
View File

@ -0,0 +1,11 @@
{application, limiter_proto, [
{description, "Thrift proto for Limiter"},
{vsn, "1.0.0"},
{applications, [
kernel,
stdlib
]},
{maintainers, [
"Artem Fedorenko <a.fedorenko@rbkmoney.com>"
]}
]}.