mirror of
https://github.com/valitydev/damsel.git
synced 2024-11-06 01:35:19 +00:00
HG-241: create erlang release by Jenkins (#195)
* Make targets to verify & release generated Erlang code * Use Jenkins gitUtils
This commit is contained in:
parent
1519af6daa
commit
2559fe98ca
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
||||
.idea
|
||||
|
||||
/_gen/
|
||||
/_release/
|
||||
/_build/
|
||||
*.sublime-workspace
|
||||
|
||||
|
17
Jenkinsfile
vendored
17
Jenkinsfile
vendored
@ -6,9 +6,11 @@ build('damsel', 'docker-host') {
|
||||
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() {
|
||||
@ -17,6 +19,20 @@ build('damsel', 'docker-host') {
|
||||
sh "make wc_compile"
|
||||
}
|
||||
|
||||
// Erlang
|
||||
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('epic/')) {
|
||||
runStage('Generate Erlang lib') {
|
||||
sh "make wc_release-erlang"
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Java
|
||||
runStage('Execute build container') {
|
||||
withCredentials([[$class: 'FileBinding', credentialsId: 'java-maven-settings.xml', variable: 'SETTINGS_XML']]) {
|
||||
if (env.BRANCH_NAME == 'master') {
|
||||
@ -28,5 +44,6 @@ build('damsel', 'docker-host') {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
52
Makefile
52
Makefile
@ -1,4 +1,4 @@
|
||||
THRIFT_EXEC = $(or $(shell which thrift), $(error "`thrift' executable missing"))
|
||||
THRIFT = $(or $(shell which thrift), $(error "`thrift' executable missing"))
|
||||
THRIFT_LANGUAGES = erlang java
|
||||
THRIFT_OPTIONS_erlang = scoped_typenames
|
||||
THRIFT_OPTIONS_java = fullcamel
|
||||
@ -16,19 +16,23 @@ SERVICE_IMAGE_TAG ?= $(shell git rev-parse HEAD)
|
||||
SERVICE_IMAGE_PUSH_TAG ?= $(SERVICE_IMAGE_TAG)
|
||||
|
||||
|
||||
BUILD_IMAGE_TAG := efd28e5e732513f09224931fa183478750f3ca16
|
||||
BUILD_IMAGE_TAG := fbef66759ab9c7b620fc73785ba1840d2f48bd68
|
||||
|
||||
FILES = $(wildcard proto/*.thrift)
|
||||
DESTDIR = _gen
|
||||
RELDIR = _release
|
||||
|
||||
CALL_W_CONTAINER := clean all create java_compile compile doc deploy_nexus deploy_epic_nexus java_install
|
||||
CALL_W_CONTAINER := \
|
||||
all compile doc clean \
|
||||
java_compile deploy_nexus deploy_epic_nexus java_install \
|
||||
release-erlang
|
||||
|
||||
all: compile
|
||||
|
||||
-include $(UTILS_PATH)/make_lib/utils_container.mk
|
||||
|
||||
define generate
|
||||
$(THRIFT_EXEC) -r -strict --gen $(1):$(THRIFT_OPTIONS_$(1)) -out $(2) $(3)
|
||||
$(THRIFT) -r -strict --gen $(1):$(THRIFT_OPTIONS_$(1)) -out $(2) $(3)
|
||||
endef
|
||||
|
||||
define targets
|
||||
@ -37,11 +41,10 @@ endef
|
||||
|
||||
CUTLINE = $(shell printf '=%.0s' $$(seq 1 80))
|
||||
|
||||
.PHONY: $(CALL_W_CONTAINER) create
|
||||
.PHONY: all compile doc clean java_compile deploy_nexus deploy_epic_nexus java_install
|
||||
|
||||
LANGUAGE_TARGETS = $(foreach lang, $(THRIFT_LANGUAGES), verify-$(lang))
|
||||
|
||||
|
||||
compile: $(LANGUAGE_TARGETS)
|
||||
@echo "Ok"
|
||||
|
||||
@ -51,18 +54,31 @@ verify-%: $(DESTDIR)
|
||||
@$(MAKE) LANGUAGE=$* $(call targets,$*)
|
||||
@echo
|
||||
|
||||
$(DESTDIR):
|
||||
@mkdir -p $@
|
||||
|
||||
clean::
|
||||
rm -rf $(DESTDIR)
|
||||
|
||||
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
|
||||
@ -74,7 +90,6 @@ $(DOCTARGETS): $(DOCDIR)/%.html: %.thrift
|
||||
mkdir -p $(dir $@)
|
||||
$(call generate,html,$(dir $@),$<)
|
||||
|
||||
|
||||
# Erlang
|
||||
|
||||
ERLC ?= erlc
|
||||
@ -85,9 +100,14 @@ ifneq ($(shell which $(ERLC)),)
|
||||
$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: %
|
||||
$(ERLC) -v -I$@ -o$@ $(shell find $@ -name "*.erl")
|
||||
|
||||
build-release:
|
||||
@make THRIFT="$(THRIFT)" FILES="$(abspath $(FILES))" -C build/erlang release
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
# Java
|
||||
|
||||
ifdef SETTINGS_XML
|
||||
DOCKER_RUN_OPTS = -v $(SETTINGS_XML):$(SETTINGS_XML)
|
||||
DOCKER_RUN_OPTS += -e SETTINGS_XML=$(SETTINGS_XML)
|
||||
@ -107,16 +127,16 @@ java_compile:
|
||||
deploy_nexus:
|
||||
$(if $(SETTINGS_XML),, echo "SETTINGS_XML not defined"; exit 1)
|
||||
mvn versions:set versions:commit -DnewVersion="1.$(NUMBER_COMMITS)-$(COMMIT_HASH)" -s $(SETTINGS_XML) \
|
||||
&& mvn deploy -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT_EXEC)" -Dcommit.number="$(NUMBER_COMMITS)"
|
||||
&& mvn deploy -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT)" -Dcommit.number="$(NUMBER_COMMITS)"
|
||||
|
||||
deploy_epic_nexus:
|
||||
$(if $(SETTINGS_XML),, echo "SETTINGS_XML not defined"; exit 1)
|
||||
mvn versions:set versions:commit -DnewVersion="1.$(NUMBER_COMMITS)-$(COMMIT_HASH)-epic" -s $(SETTINGS_XML) \
|
||||
&& mvn deploy -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT_EXEC)" -Dcommit.number="$(NUMBER_COMMITS)"
|
||||
&& mvn deploy -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT)" -Dcommit.number="$(NUMBER_COMMITS)"
|
||||
|
||||
|
||||
java_install:
|
||||
$(if $(SETTINGS_XML),, echo "SETTINGS_XML not defined"; exit 1)
|
||||
mvn clean -s $(SETTINGS_XML) && \
|
||||
mvn versions:set versions:commit -DnewVersion="1.$(NUMBER_COMMITS)-$(COMMIT_HASH)" -s $(SETTINGS_XML) \
|
||||
&& mvn install -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT_EXEC)" -Dcommit.number="$(NUMBER_COMMITS)"
|
||||
&& mvn install -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT)" -Dcommit.number="$(NUMBER_COMMITS)"
|
||||
|
3
build/erlang/.gitignore
vendored
Normal file
3
build/erlang/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/_build/
|
||||
/include/*.hrl
|
||||
/src/*.erl
|
40
build/erlang/Makefile
Normal file
40
build/erlang/Makefile
Normal file
@ -0,0 +1,40 @@
|
||||
REBAR := $(shell which rebar3 2>/dev/null || which ./rebar3)
|
||||
|
||||
define gen
|
||||
$(THRIFT) --gen erlang:scoped_typenames,app_prefix=dmsl -out src $(1)
|
||||
|
||||
endef
|
||||
|
||||
release: generate lint xref dialyze publish
|
||||
|
||||
generate: $(FILES)
|
||||
$(patsubst %, $(call gen,%), $(FILES))
|
||||
@mkdir -p include
|
||||
@mv -v src/*.hrl include
|
||||
|
||||
lint:
|
||||
elvis rock
|
||||
|
||||
xref:
|
||||
$(REBAR) xref
|
||||
|
||||
dialyze:
|
||||
$(REBAR) dialyzer
|
||||
|
||||
distclean:
|
||||
@rm -rf _build
|
||||
@rm -rvf src/*_thrift.erl include
|
||||
|
||||
DESTDIR ?= release
|
||||
ARTIFACTS := \
|
||||
include \
|
||||
src \
|
||||
elvis.config \
|
||||
rebar.config \
|
||||
rebar.lock
|
||||
|
||||
publish: $(DESTDIR) $(ARTIFACTS)
|
||||
@cp -r $(ARTIFACTS) $(DESTDIR)
|
||||
|
||||
$(DESTDIR):
|
||||
@mkdir -p $@
|
58
build/erlang/elvis.config
Normal file
58
build/erlang/elvis.config
Normal file
@ -0,0 +1,58 @@
|
||||
[
|
||||
{elvis, [
|
||||
{config, [
|
||||
#{
|
||||
dirs => ["src"],
|
||||
filter => "*.erl",
|
||||
ignore => ["_thrift.erl$"],
|
||||
rules => [
|
||||
{elvis_style, line_length, #{limit => 120, skip_comments => false}},
|
||||
{elvis_style, no_tabs},
|
||||
{elvis_style, no_trailing_whitespace},
|
||||
{elvis_style, macro_module_names},
|
||||
{elvis_style, operator_spaces, #{rules => [{right, ","}, {right, "++"}, {left, "++"}]}},
|
||||
{elvis_style, nesting_level, #{level => 3}},
|
||||
{elvis_style, god_modules, #{limit => 25}},
|
||||
{elvis_style, no_if_expression},
|
||||
{elvis_style, invalid_dynamic_call, #{ignore => [elvis]}},
|
||||
{elvis_style, used_ignored_variable},
|
||||
{elvis_style, no_behavior_info},
|
||||
{elvis_style, module_naming_convention, #{regex => "^([a-z][a-z0-9]*_?)*(_SUITE)?$"}},
|
||||
{elvis_style, function_naming_convention, #{regex => "^([a-z][a-z0-9]*_?)*$"}},
|
||||
{elvis_style, state_record_and_type},
|
||||
{elvis_style, no_spec_with_records},
|
||||
{elvis_style, dont_repeat_yourself, #{min_complexity => 10}},
|
||||
{elvis_style, no_debug_call, #{ignore => [elvis, elvis_utils]}}
|
||||
]
|
||||
},
|
||||
#{
|
||||
dirs => ["."],
|
||||
filter => "Makefile",
|
||||
ruleset => makefiles
|
||||
},
|
||||
#{
|
||||
dirs => ["."],
|
||||
filter => "elvis.config",
|
||||
ruleset => elvis_config
|
||||
},
|
||||
#{
|
||||
dirs => ["."],
|
||||
filter => "rebar.config",
|
||||
rules => [
|
||||
{elvis_style, line_length, #{limit => 120, skip_comments => false}},
|
||||
{elvis_style, no_tabs},
|
||||
{elvis_style, no_trailing_whitespace}
|
||||
]
|
||||
},
|
||||
#{
|
||||
dirs => ["src"],
|
||||
filter => "*.app.src",
|
||||
rules => [
|
||||
{elvis_style, line_length, #{limit => 120, skip_comments => false}},
|
||||
{elvis_style, no_tabs},
|
||||
{elvis_style, no_trailing_whitespace}
|
||||
]
|
||||
}
|
||||
]}
|
||||
]}
|
||||
].
|
52
build/erlang/rebar.config
Normal file
52
build/erlang/rebar.config
Normal file
@ -0,0 +1,52 @@
|
||||
%% 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
|
||||
]}.
|
||||
|
||||
%% Common project dependencies.
|
||||
{deps, [
|
||||
]}.
|
||||
|
||||
%% XRef checks
|
||||
{xref_checks, [
|
||||
undefined_function_calls,
|
||||
undefined_functions,
|
||||
deprecated_functions_calls,
|
||||
deprecated_functions
|
||||
]}.
|
||||
% at will
|
||||
% {xref_warnings, true}.
|
||||
|
||||
%% Dialyzer static analyzing
|
||||
{dialyzer, [
|
||||
{warnings, [
|
||||
% mandatory
|
||||
unmatched_returns,
|
||||
error_handling,
|
||||
race_conditions,
|
||||
unknown
|
||||
]},
|
||||
{plt_apps, all_deps}
|
||||
]}.
|
1
build/erlang/rebar.lock
Normal file
1
build/erlang/rebar.lock
Normal file
@ -0,0 +1 @@
|
||||
[].
|
11
build/erlang/src/dmsl.app.src
Normal file
11
build/erlang/src/dmsl.app.src
Normal file
@ -0,0 +1,11 @@
|
||||
{application, dmsl , [
|
||||
{description, "Damsel modules compiled to use as a dependency"},
|
||||
{vsn, "1"},
|
||||
{applications, [
|
||||
kernel,
|
||||
stdlib
|
||||
]},
|
||||
{maintainers, [
|
||||
"Mayorov Andrey <a.mayorov@rbkmoney.com>"
|
||||
]}
|
||||
]}.
|
@ -1 +1 @@
|
||||
Subproject commit 2b1c328ce9a42d9072850f03685005a4153efc28
|
||||
Subproject commit 8dd1d30e97e4db20c9da98a5ddb261b199402bc0
|
Loading…
Reference in New Issue
Block a user