diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fb08ff7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,78 @@ +# Created by .ignore support plugin (hsz.mobi) +.eunit +deps +*.o +*.beam +*.plt +erl_crash.dump +ebin/*.beam +rel/example_project +.concrete/DEV_MODE +.rebar +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/ +.idea/workspace.xml +.idea/tasks.xml +.idea/dictionaries +.idea/vcs.xml +.idea/jsLibraryMappings.xml + +# Sensitive or high-churn files: +.idea/dataSources.ids +.idea/dataSources.xml +.idea/dataSources.local.xml +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# Gradle: +.idea/gradle.xml +.idea/libraries + +# Mongo Explorer plugin: +.idea/mongoSettings.xml + +*.iws +*.ipr +*.iml + + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +env.list diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..b53f0db --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,34 @@ +#!groovy +// -*- mode: groovy -*- + +build('fraudbusters-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' + } + } + } + + } +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..33bbfa8 --- /dev/null +++ b/Makefile @@ -0,0 +1,80 @@ +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 := fraudbusters-proto + +# Build image tag to be used +BUILD_IMAGE_TAG := 55e987e74e9457191a5b4a7c5dc9e3838ae82d2b +CALL_ANYWHERE := \ + all submodules 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) + +compile: + $(REBAR) compile + +clean: + $(REBAR) clean + +distclean: + $(REBAR) clean -a + rm -rfv _build + +# 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/pom.xml b/pom.xml new file mode 100644 index 0000000..a68fe16 --- /dev/null +++ b/pom.xml @@ -0,0 +1,90 @@ + + + 4.0.0 + + + com.rbkmoney + parent + 1.0.0 + + + fraudbusters-proto + SNAPSHOT + jar + + + Fraudbusters + Generates jar artifact containing compiled thrift classes based on generated thrift IDL files + + + + UTF-8 + + + + + + com.rbkmoney.woody + woody-thrift + LATEST + provided + + + com.rbkmoney + damsel + 1.268-45c8524 + + + + + ${project.artifactId} + + + + org.apache.thrift + thrift-maven-plugin + 0.9.3-1 + + java:fullcamel + ${project.basedir}/proto + + + + + thrift-sources + generate-sources + + compile + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.0.0 + + + package + + shade + + + + + com.rbkmoney.damsel + com.rbkmoney.damsel.v${commit.number} + + + true + v${commit.number} + + + + + + + + \ No newline at end of file diff --git a/proto/fraudbusters.thrift b/proto/fraudbusters.thrift new file mode 100644 index 0000000..33517f3 --- /dev/null +++ b/proto/fraudbusters.thrift @@ -0,0 +1,37 @@ +/** + * Сервис поиска мошеннических операций. + */ + +namespace java com.rbkmoney.damsel.fraudbusters +namespace erlang fraudbusters + +typedef string ID + +exception ListNotFound {} + +enum Command { + CREATE + DELETE +} + +// Модель шаблона +struct Template { + // Уникальный идентификатор шаблона + 1: required ID id + // Описние правил на языке fraudo + 2: required binary template + // Комманда изменения шаблона + 3: required Command command +} + +// Модель связки шаблона с проверяемым субъектом +struct TemplateReference { + // Идентификатор party + 1: optional ID party_id + // Идентификатор магазина + 2: optional ID shop_id + // Идентификатор привязываемого шаблона + 3: required ID template_id + // Признак глобальности (при значении true поля party_id и shop_id игнорируются) + 4: required bool is_global = false +} \ No newline at end of file