mirror of
https://github.com/valitydev/hellgate.git
synced 2024-11-06 02:45:20 +00:00
Merge pull request #6 from rbkmoney/ft/MSPF-46/jenkinsci-adaption
MSPF-46: introduce scripts for Jekins CI 2.0 and new dev WoWs
This commit is contained in:
commit
fc09047457
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM rbkmoney/service_erlang:latest
|
||||
MAINTAINER Andrey Mayorov <a.mayorov@rbkmoney.com>
|
||||
COPY ./_build/prod/rel/hellgate /opt/hellgate
|
||||
CMD /opt/hellgate/bin/hellgate foreground
|
||||
LABEL service_version="semver"
|
||||
WORKDIR /opt/hellgate
|
||||
|
35
Jenkinsfile
vendored
Normal file
35
Jenkinsfile
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
#!groovy
|
||||
|
||||
// Args:
|
||||
// GitHub repo name
|
||||
// Jenkins agent label
|
||||
// Tracing artifacts to be stored alongside build logs
|
||||
pipeline("hellgate", 'docker-host', "_build/") {
|
||||
runStage('compile') {
|
||||
sh 'make w_container_compile'
|
||||
}
|
||||
|
||||
// ToDo: Uncomment the stage as soon as Elvis is in the build image!
|
||||
// runStage('lint') {
|
||||
// sh 'make w_container_lint'
|
||||
// }
|
||||
|
||||
runStage('xref') {
|
||||
sh 'make w_container_xref'
|
||||
}
|
||||
|
||||
runStage('test') {
|
||||
sh "make w_container_test"
|
||||
}
|
||||
|
||||
runStage('dialyze') {
|
||||
sh 'make w_container_dialyze'
|
||||
}
|
||||
|
||||
if (env.BRANCH_NAME == 'master') {
|
||||
runStage('push container') {
|
||||
sh 'make push'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
68
Makefile
68
Makefile
@ -2,36 +2,54 @@ REBAR := $(shell which rebar3 2>/dev/null || which ./rebar3)
|
||||
SUBMODULES = apps/hg_proto/damsel
|
||||
SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES))
|
||||
|
||||
.PHONY: all submodules compile devrel start test clean distclean dialyze release containerize
|
||||
ORG_NAME := rbkmoney
|
||||
BASE_IMAGE := "$(ORG_NAME)/build:latest"
|
||||
|
||||
all: compile
|
||||
# Note: RELNAME should match the name of
|
||||
# the first service in docker-compose.yml
|
||||
RELNAME := hellgate
|
||||
|
||||
rebar-update:
|
||||
$(REBAR) update
|
||||
TAG = latest
|
||||
IMAGE_NAME = "$(ORG_NAME)/$(RELNAME):$(TAG)"
|
||||
|
||||
CALL_ANYWHERE := submodules rebar-update compile xref lint dialyze start devrel release clean distclean
|
||||
|
||||
CALL_W_CONTAINER := $(CALL_ANYWHERE) test
|
||||
|
||||
include utils.mk
|
||||
|
||||
.PHONY: $(CALL_W_CONTAINER) all containerize push $(UTIL_TARGETS)
|
||||
|
||||
# CALL_ANYWHERE
|
||||
$(SUBTARGETS): %/.git: %
|
||||
git submodule update --init $<
|
||||
touch $@
|
||||
|
||||
submodules: $(SUBTARGETS)
|
||||
|
||||
compile: submodules
|
||||
rebar-update:
|
||||
$(REBAR) update
|
||||
|
||||
compile: submodules rebar-update
|
||||
$(REBAR) compile
|
||||
|
||||
devrel: submodules
|
||||
$(REBAR) release
|
||||
|
||||
start: submodules
|
||||
$(REBAR) run
|
||||
|
||||
test: submodules
|
||||
$(REBAR) ct
|
||||
xref: submodules
|
||||
$(REBAR) xref
|
||||
|
||||
lint: compile
|
||||
elvis rock
|
||||
|
||||
xref: submodules
|
||||
$(REBAR) xref
|
||||
dialyze:
|
||||
$(REBAR) dialyzer
|
||||
|
||||
start: submodules
|
||||
$(REBAR) run
|
||||
|
||||
devrel: submodules
|
||||
$(REBAR) release
|
||||
|
||||
release: distclean
|
||||
$(REBAR) as prod release
|
||||
|
||||
clean:
|
||||
$(REBAR) clean
|
||||
@ -40,18 +58,16 @@ distclean:
|
||||
$(REBAR) clean -a
|
||||
rm -rfv _build _builds _cache _steps _temp
|
||||
|
||||
dialyze:
|
||||
$(REBAR) dialyzer
|
||||
# CALL_W_CONTAINER
|
||||
test: submodules
|
||||
$(REBAR) ct
|
||||
|
||||
DOCKER := $(shell which docker 2>/dev/null)
|
||||
PACKER := $(shell which packer 2>/dev/null)
|
||||
BASE_DIR := $(shell pwd)
|
||||
# OTHER
|
||||
all: compile
|
||||
|
||||
release: ~/.docker/config.json distclean
|
||||
$(DOCKER) run --rm -v $(BASE_DIR):$(BASE_DIR) --workdir $(BASE_DIR) rbkmoney/build rebar3 as prod release
|
||||
containerize: w_container_release
|
||||
$(DOCKER) build --force-rm --tag $(IMAGE_NAME) .
|
||||
|
||||
containerize: release ./packer.json
|
||||
$(PACKER) build packer.json
|
||||
push: containerize
|
||||
$(DOCKER) push "$(IMAGE_NAME)"
|
||||
|
||||
~/.docker/config.json:
|
||||
test -f ~/.docker/config.json || (echo "Please run: docker login" ; exit 1)
|
||||
|
@ -108,7 +108,6 @@ wrap_external_event(Ev = #'InvoicePaymentStatusChanged'{}) ->
|
||||
{processing_payment, payment_id(), payment_st()}.
|
||||
|
||||
-type ev() ::
|
||||
{stage_changed, stage()} |
|
||||
{invoice_created, invoice()} |
|
||||
{invoice_status_changed, invoice_status(), detail()} |
|
||||
{payment_created, payment()} |
|
||||
@ -388,10 +387,7 @@ map_event({payment_bound, _, _}, _St) ->
|
||||
map_event({payment_succeeded, PaymentID}, St) ->
|
||||
#'InvoicePaymentStatusChanged'{payment = get_payment(PaymentID, St)};
|
||||
map_event({payment_failed, PaymentID, _}, St) ->
|
||||
#'InvoicePaymentStatusChanged'{payment = get_payment(PaymentID, St)};
|
||||
|
||||
map_event({stage_changed, _}, _St) ->
|
||||
undefined.
|
||||
#'InvoicePaymentStatusChanged'{payment = get_payment(PaymentID, St)}.
|
||||
|
||||
select_range(undefined, Limit, History) ->
|
||||
select_range(Limit, History);
|
||||
|
@ -45,7 +45,7 @@ all() ->
|
||||
-spec init_per_suite(config()) -> config().
|
||||
|
||||
init_per_suite(C) ->
|
||||
Host = "localhost",
|
||||
Host = "hellgate",
|
||||
% Port = rand:uniform(32768) + 32767,
|
||||
Port = 8042,
|
||||
RootUrl = "http://" ++ Host ++ ":" ++ integer_to_list(Port),
|
||||
@ -59,7 +59,7 @@ init_per_suite(C) ->
|
||||
% You will need up and running mgun reachable at the following url,
|
||||
% properly configured to serve incoming requests and talk back to
|
||||
% the test hg instance.
|
||||
{automaton_service_url, <<"http://localhost:8022/v1/automaton_service">>}
|
||||
{automaton_service_url, <<"http://machinegun:8022/v1/automaton_service">>}
|
||||
]),
|
||||
[{root_url, RootUrl}, {apps, lists:reverse(Apps)} | C].
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
{hellgate, [
|
||||
{host, "0.0.0.0"},
|
||||
{port, 8042},
|
||||
{automaton_service_url, <<"http://localhost:8022/v1/automaton_service">>}
|
||||
{port, 8022},
|
||||
{automaton_service_url, <<"http://machinegun:8022/v1/automaton_service">>}
|
||||
]}
|
||||
].
|
||||
|
15
docker-compose.yml
Normal file
15
docker-compose.yml
Normal file
@ -0,0 +1,15 @@
|
||||
version: '2'
|
||||
services:
|
||||
hellgate:
|
||||
image: rbkmoney/build:latest
|
||||
volumes:
|
||||
- .:/code
|
||||
working_dir: /code
|
||||
command: /sbin/init
|
||||
links:
|
||||
- machinegun
|
||||
|
||||
machinegun:
|
||||
image: rbkmoney/mg:ci_latest
|
||||
command: /opt/mgun/bin/mgun foreground
|
||||
|
38
utils.mk
Normal file
38
utils.mk
Normal file
@ -0,0 +1,38 @@
|
||||
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_% 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_$*
|
||||
|
||||
run_w_container_%: 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_"))
|
||||
|
37
wercker.yml
37
wercker.yml
@ -1,37 +0,0 @@
|
||||
box:
|
||||
id: rbkmoney/build
|
||||
username: $CI_BOT_GIT_USERNAME
|
||||
password: $CI_BOT_GIT_PASSWORD
|
||||
tag: latest
|
||||
|
||||
dev:
|
||||
steps:
|
||||
- internal/shell:
|
||||
code: make compile
|
||||
|
||||
build:
|
||||
steps:
|
||||
- script:
|
||||
name: rebar update
|
||||
code: make rebar-update
|
||||
- script:
|
||||
name: lint
|
||||
code: |
|
||||
export ELVIS_VERSION="0.2.11"
|
||||
export ELVIS_PATH="/usr/local/bin/elvis"
|
||||
curl -sL -o "${ELVIS_PATH}" "https://github.com/inaka/elvis/releases/download/${ELVIS_VERSION}/elvis"
|
||||
chmod +x "${ELVIS_PATH}"
|
||||
make lint
|
||||
- script:
|
||||
name: run xref
|
||||
code: make xref
|
||||
- script:
|
||||
name: run test suite
|
||||
code: make test
|
||||
- script:
|
||||
name: run dialyzer
|
||||
code: make dialyze
|
||||
after-steps:
|
||||
- slack-notifier:
|
||||
url: ${SLACK_WEBHOOK_URL}
|
||||
username: "wercker"
|
Loading…
Reference in New Issue
Block a user