This commit is contained in:
Boris 2019-05-28 16:49:36 +03:00 committed by GitHub
parent d05098e32d
commit aa65accf0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 340 additions and 1 deletions

14
.gitignore vendored Normal file
View File

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

3
.gitmodules vendored Normal file
View File

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

35
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,35 @@
#!groovy
// -*- mode: groovy -*-
build('moneypenny-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') {
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'
}
}
}
}
}

84
Makefile Normal file
View File

@ -0,0 +1,84 @@
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 := moneypenny_proto
# Build image tag to be used
BUILD_IMAGE_TAG := 55e987e74e9457191a5b4a7c5dc9e3838ae82d2b
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:
$(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)

View File

@ -1 +1,3 @@
# moli-proto
# Miss Moneypenny protocol
Mobile Network Portability

1
build_utils Submodule

@ -0,0 +1 @@
Subproject commit c41dac7d702757deb29baa68ed1eba87359eafb5

82
pom.xml Normal file
View File

@ -0,0 +1,82 @@
<?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>Moneypenny-proto</artifactId>
<version>SNAPSHOT</version>
<packaging>jar</packaging>
<name>Moneypenny-proto</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>
</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.damsel</pattern>
<shadedPattern>com.rbkmoney.damsel.v${commit.number}</shadedPattern>
</relocation>
</relocations>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>v${commit.number}</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

40
proto/mnp.thrift Normal file
View File

@ -0,0 +1,40 @@
namespace java com.rbkmoney.mnp
namespace erlang mnp
enum Operator {
mts
beeline
megafone
tele2
yota
}
exception BadPhoneFormat {}
exception OperatorNotFound {}
struct ResponseData {
1: required Operator operator
}
/**
* Телефонный номер согласно (E.164 рекомендация ITU-T)
* +79114363738
* cc = 7 - код страны(1-3 цифры)
* ctn = 9114363738 - 10-ти значный номер абонента
*/
struct PhoneNumber {
1: required string ctn
}
service Mnp {
/**
* Получить оператора по номеру телефона
* кидает:
* BadPhoneFormat, некорректный телефон
* OperatorNotFound, если оператор не определен
*/
ResponseData Lookup (1: PhoneNumber phone) throws (
1: BadPhoneFormat ex1
2: OperatorNotFound ex2
)
}

69
rebar.config Normal file
View File

@ -0,0 +1,69 @@
%% 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
]}.
%% 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", {tag, "0.2"}}}
]}.
{provider_hooks, [
{pre, [
{compile, {thrift, compile}},
{clean , {thrift, clean }}
]}
]}.
{thrift_compiler_opts, [
{in_dir, "proto"},
{in_files, [
"mnp.thrift"
]},
{gen, "erlang:app_prefix=moneypenny,scoped_typenames"}
]}.

1
rebar.lock Normal file
View File

@ -0,0 +1 @@
[].

View File

@ -0,0 +1,8 @@
{application, moneypenny_proto, [
{description, "Thrift proto for Miss Moneypenny"},
{vsn, "0.1.0"},
{applications, [
kernel,
stdlib
]}
]}.