mirror of
https://github.com/valitydev/damsel.git
synced 2024-11-06 01:35:19 +00:00
BJ-49: add build_utils (#56)
This commit is contained in:
parent
71887ddee8
commit
d24806b7d4
4
.gitmodules
vendored
Normal file
4
.gitmodules
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
[submodule "build_utils"]
|
||||
path = build_utils
|
||||
url = git@github.com:rbkmoney/build_utils.git
|
||||
branch = master
|
40
Jenkinsfile
vendored
40
Jenkinsfile
vendored
@ -1,28 +1,30 @@
|
||||
#!groovy
|
||||
|
||||
// Args:
|
||||
// GitHub repo name
|
||||
// Jenkins agent label
|
||||
// Tracing artifacts to be stored alongside build logs
|
||||
pipeline("damsel", 'docker-host', "_build/") {
|
||||
build('damsel', 'docker-host') {
|
||||
checkoutRepo()
|
||||
loadBuildUtils()
|
||||
|
||||
runStage('compile') {
|
||||
sh "make w_container_compile"
|
||||
}
|
||||
def pipeDefault
|
||||
runStage('load pipeline') {
|
||||
env.JENKINS_LIB = "build_utils/jenkins_lib"
|
||||
pipeDefault = load("${env.JENKINS_LIB}/pipeDefault.groovy")
|
||||
}
|
||||
|
||||
// Build failed without this file: _build/test/logs/index.html (Hi, jenkins_pipeline_lib)
|
||||
runStage('folder_create') {
|
||||
sh "make w_container_create"
|
||||
}
|
||||
pipeDefault() {
|
||||
|
||||
if (env.BRANCH_NAME == 'master') {
|
||||
runStage('deploy_nexus') {
|
||||
sh "make w_container_deploy_nexus"
|
||||
runStage('compile') {
|
||||
sh "make wc_compile"
|
||||
}
|
||||
} else {
|
||||
runStage('java_compile') {
|
||||
sh "make w_container_java_compile"
|
||||
|
||||
runStage('Execute build container') {
|
||||
withCredentials([[$class: 'FileBinding', credentialsId: 'java-maven-settings.xml', variable: 'SETTINGS_XML']]) {
|
||||
if (env.BRANCH_NAME == 'master') {
|
||||
sh 'make wc_deploy_nexus SETTINGS_XML=$SETTINGS_XML'
|
||||
} else {
|
||||
sh 'make wc_java_compile SETTINGS_XML=$SETTINGS_XML'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
40
Makefile
40
Makefile
@ -4,23 +4,28 @@ THRIFT_OPTIONS_erlang = scoped_typenames
|
||||
THRIFT_OPTIONS_java = fullcamel
|
||||
THRIFT_OPTIONS_html = standalone
|
||||
|
||||
REGISTRY := dr.rbkmoney.com
|
||||
ORG_NAME := rbkmoney
|
||||
BASE_IMAGE := "$(REGISTRY)/$(ORG_NAME)/build:530114ab63a7ff0379a2220169a0be61d3f7c64c"
|
||||
UTILS_PATH := build_utils
|
||||
TEMPLATES_PATH := .
|
||||
|
||||
RELNAME := damsel
|
||||
|
||||
# Name of the service
|
||||
SERVICE_NAME := damsel
|
||||
# Service image default tag
|
||||
SERVICE_IMAGE_TAG ?= $(shell git rev-parse HEAD)
|
||||
# The tag for service image to be pushed with
|
||||
SERVICE_IMAGE_PUSH_TAG ?= $(SERVICE_IMAGE_TAG)
|
||||
|
||||
|
||||
BUILD_IMAGE_TAG := 753126790c9ecd763840d9fe58507335af02b875
|
||||
|
||||
FILES = $(wildcard proto/*.thrift)
|
||||
DESTDIR = _gen
|
||||
|
||||
CALL_ANYWHERE := clean all create java_compile compile doc deploy_nexus
|
||||
CALL_W_CONTAINER := $(CALL_ANYWHERE)
|
||||
|
||||
BASE_IMAGE ?= rbkmoney/build
|
||||
CALL_W_CONTAINER := clean all create java_compile compile doc deploy_nexus
|
||||
|
||||
all: compile
|
||||
|
||||
include utils.mk
|
||||
-include $(UTILS_PATH)/make_lib/utils_container.mk
|
||||
|
||||
define generate
|
||||
$(THRIFT_EXEC) -r -strict --gen $(1):$(THRIFT_OPTIONS_$(1)) -out $(2) $(3)
|
||||
@ -32,13 +37,10 @@ endef
|
||||
|
||||
CUTLINE = $(shell printf '=%.0s' $$(seq 1 80))
|
||||
|
||||
.PHONY: $(CALL_W_CONTAINER) create $(UTIL_TARGETS)
|
||||
.PHONY: $(CALL_W_CONTAINER) create
|
||||
|
||||
LANGUAGE_TARGETS = $(foreach lang, $(THRIFT_LANGUAGES), verify-$(lang))
|
||||
|
||||
# Build failed without this file: _build/test/logs/index.html (Hi, jenkins_pipeline_lib)
|
||||
create:
|
||||
mkdir -p _build/test/logs && touch _build/test/logs/index.html
|
||||
|
||||
compile: $(LANGUAGE_TARGETS)
|
||||
@echo "Ok"
|
||||
@ -86,13 +88,19 @@ $(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: %
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef SETTINGS_XML
|
||||
DOCKER_RUN_OPTS = -v $(SETTINGS_XML):$(SETTINGS_XML)
|
||||
DOCKER_RUN_OPTS += -e SETTINGS_XML=$(SETTINGS_XML)
|
||||
endif
|
||||
|
||||
COMMIT_HASH = $(shell git --no-pager log -1 --pretty=format:"%h")
|
||||
NUMBER_COMMITS = $(shell git rev-list --count HEAD)
|
||||
|
||||
java_compile:
|
||||
mvn compile
|
||||
$(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1)
|
||||
mvn compile -s $(SETTINGS_XML)
|
||||
|
||||
deploy_nexus:
|
||||
mvn versions:set versions:commit -DnewVersion="1.$(NUMBER_COMMITS)-$(COMMIT_HASH)" \
|
||||
&& mvn deploy -Dpath_to_thrift="$(THRIFT_EXEC)"
|
||||
$(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)"
|
||||
|
1
build_utils
Submodule
1
build_utils
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 2b1c328ce9a42d9072850f03685005a4153efc28
|
46
utils.mk
46
utils.mk
@ -1,46 +0,0 @@
|
||||
SHELL := /bin/bash
|
||||
|
||||
which = $(if $(shell which $(1) 2>/dev/null),\
|
||||
$(shell which $(1) 2>/dev/null),\
|
||||
$(error "Error: could not locate $(1)!"))
|
||||
|
||||
DOCKER = $(call which,docker)
|
||||
DOCKER_COMPOSE = $(call which,docker-compose)
|
||||
|
||||
UTIL_TARGETS := to_dev_container w_container_% w_compose_% run_w_container_% check_w_container_%
|
||||
|
||||
ifndef RELNAME
|
||||
$(error RELNAME is not set)
|
||||
endif
|
||||
|
||||
ifndef CALL_W_CONTAINER
|
||||
$(error CALL_W_CONTAINER is not set)
|
||||
endif
|
||||
|
||||
to_dev_container:
|
||||
$(DOCKER) run -it --rm -v $$PWD:$$PWD --workdir $$PWD $(BASE_IMAGE) /bin/bash
|
||||
|
||||
w_container_%:
|
||||
$(MAKE) -s run_w_container_$*
|
||||
|
||||
w_compose_%:
|
||||
$(MAKE) -s run_w_compose_$*
|
||||
|
||||
run_w_container_%: check_w_container_%
|
||||
{ \
|
||||
$(DOCKER) run --rm -v $$PWD:$$PWD --workdir $$PWD $(BASE_IMAGE) make $* ; \
|
||||
res=$$? ; exit $$res ; \
|
||||
}
|
||||
|
||||
run_w_compose_%: check_w_container_%
|
||||
{ \
|
||||
$(DOCKER_COMPOSE) up -d ; \
|
||||
$(DOCKER_COMPOSE) exec -T $(RELNAME) make $* ; \
|
||||
res=$$? ; \
|
||||
$(DOCKER_COMPOSE) down ; \
|
||||
exit $$res ; \
|
||||
}
|
||||
|
||||
check_w_container_%:
|
||||
$(if $(filter $*,$(CALL_W_CONTAINER)),,\
|
||||
$(error "Error: target '$*' cannot be called w_container_"))
|
Loading…
Reference in New Issue
Block a user