mirror of
https://github.com/valitydev/machinery-erlang.git
synced 2024-11-06 00:35:19 +00:00
Add GitHub actions (#1)
This commit is contained in:
parent
db7c94b991
commit
0f71f3b914
8
.editorconfig
Normal file
8
.editorconfig
Normal file
@ -0,0 +1,8 @@
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
trim_trailing_whitespace = true
|
||||
max_line_length = 120
|
7
.env
Normal file
7
.env
Normal file
@ -0,0 +1,7 @@
|
||||
# NOTE
|
||||
# You SHOULD specify point releases here so that build time and run time Erlang/OTPs
|
||||
# are the same. See: https://github.com/erlware/relx/pull/902
|
||||
SERVICE_NAME=machinery
|
||||
OTP_VERSION=24.2.0
|
||||
REBAR_VERSION=3.18
|
||||
THRIFT_VERSION=0.14.2.2
|
2
.github/settings.yml
vendored
Normal file
2
.github/settings.yml
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# These settings are synced to GitHub by https://probot.github.io/apps/settings/
|
||||
_extends: .github
|
10
.github/workflows/basic-linters.yml
vendored
Normal file
10
.github/workflows/basic-linters.yml
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
name: Vality basic linters
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
uses: valitydev/base-workflows/.github/workflows/basic-linters.yml@v1
|
39
.github/workflows/erlang-checks.yml
vendored
Normal file
39
.github/workflows/erlang-checks.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: Erlang CI Checks
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'epic/**'
|
||||
pull_request:
|
||||
branches: ['**']
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
name: Load .env
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
otp-version: ${{ steps.otp-version.outputs.version }}
|
||||
rebar-version: ${{ steps.rebar-version.outputs.version }}
|
||||
thrift-version: ${{ steps.thrift-version.outputs.version }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- run: grep -v '^#' .env >> $GITHUB_ENV
|
||||
- id: otp-version
|
||||
run: echo "::set-output name=version::$OTP_VERSION"
|
||||
- id: rebar-version
|
||||
run: echo "::set-output name=version::$REBAR_VERSION"
|
||||
- id: thrift-version
|
||||
run: echo "::set-output name=version::$THRIFT_VERSION"
|
||||
|
||||
run:
|
||||
name: Run checks
|
||||
needs: setup
|
||||
uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.1
|
||||
with:
|
||||
otp-version: ${{ needs.setup.outputs.otp-version }}
|
||||
rebar-version: ${{ needs.setup.outputs.rebar-version }}
|
||||
use-thrift: true
|
||||
thrift-version: ${{ needs.setup.outputs.thrift-version }}
|
||||
run-ct-with-compose: true
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -7,7 +7,9 @@ erl_crash.dump
|
||||
.tags*
|
||||
*.sublime-workspace
|
||||
.DS_Store
|
||||
docker-compose.yml
|
||||
/.idea/
|
||||
*.beam
|
||||
/.edts
|
||||
tags
|
||||
# make stuff
|
||||
/.image.*
|
||||
Makefile.env
|
||||
|
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -1,4 +0,0 @@
|
||||
[submodule "build_utils"]
|
||||
path = build_utils
|
||||
url = git@github.com:rbkmoney/build_utils.git
|
||||
branch = master
|
42
Dockerfile
Normal file
42
Dockerfile
Normal file
@ -0,0 +1,42 @@
|
||||
ARG OTP_VERSION
|
||||
|
||||
# Build the release
|
||||
FROM docker.io/library/erlang:${OTP_VERSION} AS builder
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
# Install thrift compiler
|
||||
ARG THRIFT_VERSION
|
||||
ARG TARGETARCH
|
||||
RUN wget -q -O- "https://github.com/valitydev/thrift/releases/download/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}-linux-${TARGETARCH}.tar.gz" \
|
||||
| tar -xvz -C /usr/local/bin/
|
||||
|
||||
# Copy sources
|
||||
RUN mkdir /build
|
||||
COPY . /build/
|
||||
|
||||
# Build the release
|
||||
WORKDIR /build
|
||||
RUN rebar3 compile && \
|
||||
rebar3 as prod release
|
||||
|
||||
# Make a runner image
|
||||
FROM docker.io/library/erlang:${OTP_VERSION}-slim
|
||||
|
||||
ARG SERVICE_NAME
|
||||
|
||||
# Set env
|
||||
ENV CHARSET=UTF-8
|
||||
ENV LANG=C.UTF-8
|
||||
|
||||
# Set runtime
|
||||
WORKDIR /opt/${SERVICE_NAME}
|
||||
|
||||
COPY --from=builder /build/_build/prod/rel/${SERVICE_NAME} /opt/${SERVICE_NAME}
|
||||
|
||||
RUN echo "#!/bin/sh" >> /entrypoint.sh && \
|
||||
echo "exec /opt/${SERVICE_NAME}/bin/${SERVICE_NAME} foreground" >> /entrypoint.sh && \
|
||||
chmod +x /entrypoint.sh
|
||||
ENTRYPOINT []
|
||||
CMD ["/entrypoint.sh"]
|
||||
|
||||
EXPOSE 8022
|
17
Dockerfile.dev
Normal file
17
Dockerfile.dev
Normal file
@ -0,0 +1,17 @@
|
||||
ARG OTP_VERSION
|
||||
|
||||
FROM docker.io/library/erlang:${OTP_VERSION}
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
# Install thrift compiler
|
||||
ARG THRIFT_VERSION
|
||||
ARG TARGETARCH
|
||||
RUN wget -q -O- "https://github.com/valitydev/thrift/releases/download/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}-linux-${TARGETARCH}.tar.gz" \
|
||||
| tar -xvz -C /usr/local/bin/
|
||||
|
||||
# Set env
|
||||
ENV CHARSET=UTF-8
|
||||
ENV LANG=C.UTF-8
|
||||
|
||||
# Set runtime
|
||||
CMD ["/bin/bash"]
|
23
Jenkinsfile
vendored
23
Jenkinsfile
vendored
@ -1,23 +0,0 @@
|
||||
#!groovy
|
||||
// -*- mode: groovy -*-
|
||||
|
||||
def finalHook = {
|
||||
runStage('store CT logs') {
|
||||
archive '_build/test/logs/'
|
||||
}
|
||||
}
|
||||
|
||||
build('machinery', 'docker-host', finalHook) {
|
||||
checkoutRepo()
|
||||
loadBuildUtils()
|
||||
|
||||
def pipeErlangLib
|
||||
runStage('load pipeline') {
|
||||
env.JENKINS_LIB = "build_utils/jenkins_lib"
|
||||
env.SH_TOOLS = "build_utils/sh"
|
||||
pipeErlangLib = load("${env.JENKINS_LIB}/pipeErlangLib.groovy")
|
||||
}
|
||||
|
||||
pipeErlangLib.runPipe(true, false, 'test')
|
||||
}
|
||||
|
115
Makefile
115
Makefile
@ -1,57 +1,108 @@
|
||||
REBAR := $(shell which rebar3 2>/dev/null || which ./rebar3)
|
||||
# HINT
|
||||
# Use this file to override variables here.
|
||||
# For example, to run with podman put `DOCKER=podman` there.
|
||||
-include Makefile.env
|
||||
|
||||
UTILS_PATH := build_utils
|
||||
TEMPLATES_PATH := .
|
||||
# NOTE
|
||||
# Variables specified in `.env` file are used to pick and setup specific
|
||||
# component versions, both when building a development image and when running
|
||||
# CI workflows on GH Actions. This ensures that tasks run with `wc-` prefix
|
||||
# (like `wc-dialyze`) are reproducible between local machine and CI runners.
|
||||
DOTENV := $(shell grep -v '^\#' .env)
|
||||
|
||||
SUBMODULES = $(UTILS_PATH)
|
||||
SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES))
|
||||
# Development images
|
||||
DEV_IMAGE_TAG = $(TEST_CONTAINER_NAME)-dev
|
||||
DEV_IMAGE_ID = $(file < .image.dev)
|
||||
|
||||
SERVICE_NAME := machinery
|
||||
BASE_IMAGE_NAME := service-erlang
|
||||
BASE_IMAGE_TAG := 51bd5f25d00cbf75616e2d672601dfe7351dcaa4
|
||||
BUILD_IMAGE_NAME := build-erlang
|
||||
BUILD_IMAGE_TAG := 61a001bbb48128895735a3ac35b0858484fdb2eb
|
||||
|
||||
CALL_ANYWHERE := all submodules compile xref lint dialyze clean distclean check_format format
|
||||
|
||||
CALL_W_CONTAINER := $(CALL_ANYWHERE) test
|
||||
DOCKER ?= docker
|
||||
DOCKERCOMPOSE ?= docker-compose
|
||||
DOCKERCOMPOSE_W_ENV = DEV_IMAGE_TAG=$(DEV_IMAGE_TAG) $(DOCKERCOMPOSE)
|
||||
REBAR ?= rebar3
|
||||
TEST_CONTAINER_NAME ?= testrunner
|
||||
|
||||
all: compile
|
||||
|
||||
-include $(UTILS_PATH)/make_lib/utils_container.mk
|
||||
.PHONY: dev-image clean-dev-image wc-shell test
|
||||
|
||||
.PHONY: $(CALL_W_CONTAINER)
|
||||
dev-image: .image.dev
|
||||
|
||||
$(SUBTARGETS): %/.git: %
|
||||
git submodule update --init $<
|
||||
touch $@
|
||||
.image.dev: Dockerfile.dev .env
|
||||
env $(DOTENV) $(DOCKERCOMPOSE_W_ENV) build $(TEST_CONTAINER_NAME)
|
||||
$(DOCKER) image ls -q -f "reference=$(DEV_IMAGE_TAG)" | head -n1 > $@
|
||||
|
||||
submodules: $(SUBTARGETS)
|
||||
clean-dev-image:
|
||||
ifneq ($(DEV_IMAGE_ID),)
|
||||
$(DOCKER) image rm -f $(DEV_IMAGE_TAG)
|
||||
rm .image.dev
|
||||
endif
|
||||
|
||||
compile: submodules
|
||||
DOCKER_WC_OPTIONS := -v $(PWD):$(PWD) --workdir $(PWD)
|
||||
DOCKER_WC_EXTRA_OPTIONS ?= --rm
|
||||
DOCKER_RUN = $(DOCKER) run -t $(DOCKER_WC_OPTIONS) $(DOCKER_WC_EXTRA_OPTIONS)
|
||||
|
||||
DOCKERCOMPOSE_RUN = $(DOCKERCOMPOSE_W_ENV) run --rm $(DOCKER_WC_OPTIONS)
|
||||
|
||||
# Utility tasks
|
||||
|
||||
wc-shell: dev-image
|
||||
$(DOCKER_RUN) --interactive --tty $(DEV_IMAGE_TAG)
|
||||
|
||||
wc-%: dev-image
|
||||
$(DOCKER_RUN) $(DEV_IMAGE_TAG) make $*
|
||||
|
||||
# TODO docker compose down doesn't work yet
|
||||
wdeps-shell: dev-image
|
||||
$(DOCKERCOMPOSE_RUN) $(TEST_CONTAINER_NAME) su; \
|
||||
$(DOCKERCOMPOSE_W_ENV) down
|
||||
|
||||
wdeps-%: dev-image
|
||||
$(DOCKERCOMPOSE_RUN) -T $(TEST_CONTAINER_NAME) make $*; \
|
||||
res=$$?; \
|
||||
$(DOCKERCOMPOSE_W_ENV) down; \
|
||||
exit $$res
|
||||
|
||||
# Rebar tasks
|
||||
|
||||
rebar-shell:
|
||||
$(REBAR) shell
|
||||
|
||||
compile:
|
||||
$(REBAR) compile
|
||||
|
||||
xref: submodules
|
||||
xref:
|
||||
$(REBAR) xref
|
||||
|
||||
lint:
|
||||
elvis rock -V
|
||||
$(REBAR) lint
|
||||
|
||||
check_format:
|
||||
$(REBAR) as test fmt -c
|
||||
check-format:
|
||||
$(REBAR) fmt -c
|
||||
|
||||
dialyze:
|
||||
$(REBAR) as test dialyzer
|
||||
|
||||
release:
|
||||
$(REBAR) as prod release
|
||||
|
||||
eunit:
|
||||
$(REBAR) eunit --cover
|
||||
|
||||
common-test:
|
||||
$(REBAR) ct --cover
|
||||
|
||||
cover:
|
||||
$(REBAR) covertool generate
|
||||
|
||||
format:
|
||||
$(REBAR) fmt -w
|
||||
|
||||
dialyze: submodules
|
||||
$(REBAR) as test dialyzer
|
||||
|
||||
clean:
|
||||
$(REBAR) clean
|
||||
|
||||
distclean:
|
||||
$(REBAR) clean -a
|
||||
distclean: clean-build-image
|
||||
rm -rf _build
|
||||
|
||||
test: submodules
|
||||
$(REBAR) ct
|
||||
test: eunit common-test
|
||||
|
||||
cover-report:
|
||||
$(REBAR) cover
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit e1318727d4d0c3e48f5122bf3197158b6695f50e
|
26
docker-compose.sh → compose.yaml
Executable file → Normal file
26
docker-compose.sh → compose.yaml
Executable file → Normal file
@ -1,29 +1,29 @@
|
||||
#!/bin/bash
|
||||
cat <<EOF
|
||||
version: '2.1'
|
||||
services:
|
||||
|
||||
${SERVICE_NAME}:
|
||||
image: ${BUILD_IMAGE}
|
||||
testrunner:
|
||||
image: $DEV_IMAGE_TAG
|
||||
build:
|
||||
dockerfile: Dockerfile.dev
|
||||
context: .
|
||||
args:
|
||||
OTP_VERSION: $OTP_VERSION
|
||||
THRIFT_VERSION: $THRIFT_VERSION
|
||||
volumes:
|
||||
- .:$PWD
|
||||
- $HOME/.cache:/home/$UNAME/.cache
|
||||
working_dir: $PWD
|
||||
command: /sbin/init
|
||||
hostname: $SERVICE_NAME
|
||||
depends_on:
|
||||
machinegun:
|
||||
condition: service_healthy
|
||||
working_dir: $PWD
|
||||
command: /sbin/init
|
||||
|
||||
machinegun:
|
||||
image: dr2.rbkmoney.com/rbkmoney/machinegun:0da2ffc23221e1e3f8557b03d48d11d2dd18fac0
|
||||
image: ghcr.io/valitydev/machinegun:sha-7f0a21a
|
||||
command: /opt/machinegun/bin/machinegun foreground
|
||||
volumes:
|
||||
- ./test/machinegun/config.yaml:/opt/machinegun/etc/config.yaml
|
||||
- ./test/machinegun/cookie:/opt/machinegun/etc/cookie
|
||||
healthcheck:
|
||||
test: "curl http://localhost:8022/"
|
||||
test: "/opt/machinegun/bin/machinegun ping"
|
||||
interval: 5s
|
||||
timeout: 1s
|
||||
retries: 20
|
||||
|
||||
EOF
|
33
elvis.config
33
elvis.config
@ -1,27 +1,17 @@
|
||||
[
|
||||
{elvis, [
|
||||
{verbose, true},
|
||||
{config, [
|
||||
#{
|
||||
dirs => ["src", "test"],
|
||||
filter => "*.erl",
|
||||
ruleset => erl_files,
|
||||
rules => [
|
||||
{elvis_text_style, line_length, #{limit => 120, skip_comments => false}},
|
||||
{elvis_text_style, no_tabs},
|
||||
{elvis_text_style, no_trailing_whitespace},
|
||||
{elvis_style, macro_module_names},
|
||||
{elvis_style, operator_spaces, #{rules => [{right, ","}, {right, "++"}, {left, "++"}]}},
|
||||
{elvis_style, nesting_level, #{level => 4}},
|
||||
{elvis_style, god_modules, #{limit => 30, ignore => []}},
|
||||
{elvis_style, no_if_expression},
|
||||
{elvis_style, invalid_dynamic_call, #{ignore => []}},
|
||||
{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, #{ignore => []}},
|
||||
{elvis_style, no_spec_with_records},
|
||||
{elvis_style, dont_repeat_yourself, #{min_complexity => 30}},
|
||||
{elvis_style, no_debug_call, #{}}
|
||||
{elvis_text_style, line_length, #{limit => 120}},
|
||||
{elvis_style, nesting_level, #{level => 3}},
|
||||
{elvis_style, function_naming_convention, #{regex => "^([a-z][a-z0-9]*_?)*$"}},
|
||||
{elvis_style, no_if_expression, disable},
|
||||
{elvis_style, dont_repeat_yourself, #{min_complexity => 30}}
|
||||
]
|
||||
},
|
||||
#{
|
||||
@ -37,17 +27,20 @@
|
||||
#{
|
||||
dirs => ["."],
|
||||
filter => "rebar.config",
|
||||
ruleset => rebar_config,
|
||||
rules => [
|
||||
{elvis_text_style, line_length, #{limit => 120, skip_comments => false}},
|
||||
{elvis_text_style, line_length, #{limit => 120}},
|
||||
{elvis_text_style, no_tabs},
|
||||
{elvis_text_style, no_trailing_whitespace}
|
||||
{elvis_text_style, no_trailing_whitespace},
|
||||
%% Temporarily disabled till regex pattern is available
|
||||
{elvis_project, no_deps_master_rebar, disable}
|
||||
]
|
||||
},
|
||||
#{
|
||||
dirs => ["src"],
|
||||
filter => "*.app.src",
|
||||
rules => [
|
||||
{elvis_text_style, line_length, #{limit => 120, skip_comments => false}},
|
||||
{elvis_text_style, line_length, #{limit => 120}},
|
||||
{elvis_text_style, no_tabs},
|
||||
{elvis_text_style, no_trailing_whitespace}
|
||||
]
|
||||
|
24
rebar.config
24
rebar.config
@ -26,9 +26,9 @@
|
||||
|
||||
% Common project dependencies.
|
||||
{deps, [
|
||||
{genlib, {git, "https://github.com/rbkmoney/genlib.git", {branch, "master"}}},
|
||||
{woody, {git, "https://github.com/rbkmoney/woody_erlang.git", {branch, "master"}}},
|
||||
{mg_proto, {git, "https://github.com/rbkmoney/machinegun_proto.git", {branch, "master"}}}
|
||||
{genlib, {git, "https://github.com/valitydev/genlib.git", {branch, "master"}}},
|
||||
{woody, {git, "https://github.com/valitydev/woody_erlang.git", {branch, "master"}}},
|
||||
{mg_proto, {git, "https://github.com/valitydev/machinegun-proto.git", {branch, "master"}}}
|
||||
]}.
|
||||
|
||||
{xref_checks, [
|
||||
@ -50,11 +50,23 @@
|
||||
{plt_extra_apps, [eunit, common_test]}
|
||||
]}.
|
||||
|
||||
{plugins, [
|
||||
{erlfmt, "0.10.0"}
|
||||
{project_plugins, [
|
||||
{rebar3_lint, "1.0.1"},
|
||||
{erlfmt, "1.0.0"},
|
||||
{covertool, "2.0.4"}
|
||||
]}.
|
||||
|
||||
%% Linter config.
|
||||
{elvis_output_format, colors}.
|
||||
|
||||
{erlfmt, [
|
||||
{print_width, 120},
|
||||
{files, ["{src,include,test}/*.{hrl,erl}", "rebar.config", "elvis.config"]}
|
||||
{files, ["{src,test}/*.{hrl,erl}", "rebar.config", "elvis.config"]}
|
||||
]}.
|
||||
|
||||
{covertool, [
|
||||
{coverdata_files, [
|
||||
"eunit.coverdata",
|
||||
"ct.coverdata"
|
||||
]}
|
||||
]}.
|
||||
|
71
rebar.lock
71
rebar.lock
@ -1,79 +1,64 @@
|
||||
{"1.2.0",
|
||||
[{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},3},
|
||||
{<<"cache">>,{pkg,<<"cache">>,<<"2.3.3">>},1},
|
||||
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.3">>},2},
|
||||
{<<"cg_mon">>,
|
||||
{git,"https://github.com/rbkmoney/cg_mon.git",
|
||||
{ref,"5a87a37694e42b6592d3b4164ae54e0e87e24e18"}},
|
||||
2},
|
||||
{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.7.0">>},1},
|
||||
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.8.0">>},2},
|
||||
{<<"folsom">>,
|
||||
{git,"https://github.com/folsom-project/folsom.git",
|
||||
{ref,"eeb1cc467eb64bd94075b95b8963e80d8b4df3df"}},
|
||||
2},
|
||||
[{<<"cache">>,{pkg,<<"cache">>,<<"2.3.3">>},1},
|
||||
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.8.0">>},2},
|
||||
{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.9.0">>},1},
|
||||
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},2},
|
||||
{<<"genlib">>,
|
||||
{git,"https://github.com/rbkmoney/genlib.git",
|
||||
{ref,"4565a8d73f34a0b78cca32c9cd2b97d298bdadf8"}},
|
||||
{git,"https://github.com/valitydev/genlib.git",
|
||||
{ref,"82c5ff3866e3019eb347c7f1d8f1f847bed28c10"}},
|
||||
0},
|
||||
{<<"gproc">>,{pkg,<<"gproc">>,<<"0.8.0">>},1},
|
||||
{<<"hackney">>,{pkg,<<"hackney">>,<<"1.17.0">>},1},
|
||||
{<<"how_are_you">>,
|
||||
{git,"https://github.com/rbkmoney/how_are_you.git",
|
||||
{ref,"8f11d17eeb6eb74096da7363a9df272fd3099718"}},
|
||||
1},
|
||||
{<<"gproc">>,{pkg,<<"gproc">>,<<"0.9.0">>},1},
|
||||
{<<"hackney">>,{pkg,<<"hackney">>,<<"1.18.0">>},1},
|
||||
{<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},2},
|
||||
{<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},2},
|
||||
{<<"mg_proto">>,
|
||||
{git,"https://github.com/rbkmoney/machinegun_proto.git",
|
||||
{ref,"d814d6948d4ff13f6f41d12c6613f59c805750b2"}},
|
||||
{git,"https://github.com/valitydev/machinegun-proto.git",
|
||||
{ref,"b43d6fd0939ee4029ec8873dbd16f3c5fbe4a95c"}},
|
||||
0},
|
||||
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.2.0">>},2},
|
||||
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.1">>},2},
|
||||
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.7.1">>},2},
|
||||
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},2},
|
||||
{<<"snowflake">>,
|
||||
{git,"https://github.com/rbkmoney/snowflake.git",
|
||||
{git,"https://github.com/valitydev/snowflake.git",
|
||||
{ref,"de159486ef40cec67074afe71882bdc7f7deab72"}},
|
||||
1},
|
||||
{<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.6">>},2},
|
||||
{<<"thrift">>,
|
||||
{git,"https://github.com/rbkmoney/thrift_erlang.git",
|
||||
{ref,"846a0819d9b6d09d0c31f160e33a78dbad2067b4"}},
|
||||
{git,"https://github.com/valitydev/thrift_erlang.git",
|
||||
{ref,"c280ff266ae1c1906fb0dcee8320bb8d8a4a3c75"}},
|
||||
1},
|
||||
{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},2},
|
||||
{<<"woody">>,
|
||||
{git,"https://github.com/rbkmoney/woody_erlang.git",
|
||||
{ref,"f2cd30883d58eb1c3ab2172556956f757bc27e23"}},
|
||||
{git,"https://github.com/valitydev/woody_erlang.git",
|
||||
{ref,"3ddacb9296691aa8ddad05498d1fd34b078eda75"}},
|
||||
0}]}.
|
||||
[
|
||||
{pkg_hash,[
|
||||
{<<"bear">>, <<"16264309AE5D005D03718A5C82641FCC259C9E8F09ADEB6FD79CA4271168656F">>},
|
||||
{<<"cache">>, <<"B23A5FE7095445A88412A6E614C933377E0137B44FFED77C9B3FEF1A731A20B2">>},
|
||||
{<<"certifi">>, <<"70BDD7E7188C804F3A30EE0E7C99655BC35D8AC41C23E12325F36AB449B70651">>},
|
||||
{<<"cowboy">>, <<"91ED100138A764355F43316B1D23D7FF6BDB0DE4EA618CB5D8677C93A7A2F115">>},
|
||||
{<<"cowlib">>, <<"FD0FF1787DB84AC415B8211573E9A30A3EBE71B5CBFF7F720089972B2319C8A4">>},
|
||||
{<<"gproc">>, <<"CEA02C578589C61E5341FCE149EA36CCEF236CC2ECAC8691FBA408E7EA77EC2F">>},
|
||||
{<<"hackney">>, <<"717EA195FD2F898D9FE9F1CE0AFCC2621A41ECFE137FAE57E7FE6E9484B9AA99">>},
|
||||
{<<"certifi">>, <<"D4FB0A6BB20B7C9C3643E22507E42F356AC090A1DCEA9AB99E27E0376D695EBA">>},
|
||||
{<<"cowboy">>, <<"865DD8B6607E14CF03282E10E934023A1BD8BE6F6BACF921A7E2A96D800CD452">>},
|
||||
{<<"cowlib">>, <<"0B9FF9C346629256C42EBE1EEB769A83C6CB771A6EE5960BD110AB0B9B872063">>},
|
||||
{<<"gproc">>, <<"853CCB7805E9ADA25D227A157BA966F7B34508F386A3E7E21992B1B484230699">>},
|
||||
{<<"hackney">>, <<"C4443D960BB9FBA6D01161D01CD81173089686717D9490E5D3606644C48D121F">>},
|
||||
{<<"idna">>, <<"8A63070E9F7D0C62EB9D9FCB360A7DE382448200FBBD1B106CC96D3D8099DF8D">>},
|
||||
{<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>},
|
||||
{<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>},
|
||||
{<<"parse_trans">>, <<"16328AB840CC09919BD10DAB29E431DA3AF9E9E7E7E6F0089DD5A2D2820011D8">>},
|
||||
{<<"ranch">>, <<"6B1FAB51B49196860B733A49C07604465A47BDB78AA10C1C16A3D199F7F8C881">>},
|
||||
{<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>},
|
||||
{<<"ssl_verify_fun">>, <<"CF344F5692C82D2CD7554F5EC8FD961548D4FD09E7D22F5B62482E5AEAEBD4B0">>},
|
||||
{<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>}]},
|
||||
{pkg_hash_ext,[
|
||||
{<<"bear">>, <<"534217DCE6A719D59E54FB0EB7A367900DBFC5F85757E8C1F94269DF383F6D9B">>},
|
||||
{<<"cache">>, <<"44516CE6FA03594D3A2AF025DD3A87BFE711000EB730219E1DDEFC816E0AA2F4">>},
|
||||
{<<"certifi">>, <<"ED516ACB3929B101208A9D700062D520F3953DA3B6B918D866106FFA980E1C10">>},
|
||||
{<<"cowboy">>, <<"04FD8C6A39EDC6AAA9C26123009200FC61F92A3A94F3178C527B70B767C6E605">>},
|
||||
{<<"cowlib">>, <<"79F954A7021B302186A950A32869DBC185523D99D3E44CE430CD1F3289F41ED4">>},
|
||||
{<<"gproc">>, <<"580ADAFA56463B75263EF5A5DF4C86AF321F68694E7786CB057FD805D1E2A7DE">>},
|
||||
{<<"hackney">>, <<"64C22225F1EA8855F584720C0E5B3CD14095703AF1C9FBC845BA042811DC671C">>},
|
||||
{<<"certifi">>, <<"6AC7EFC1C6F8600B08D625292D4BBF584E14847CE1B6B5C44D983D273E1097EA">>},
|
||||
{<<"cowboy">>, <<"2C729F934B4E1AA149AFF882F57C6372C15399A20D54F65C8D67BEF583021BDE">>},
|
||||
{<<"cowlib">>, <<"2B3E9DA0B21C4565751A6D4901C20D1B4CC25CBB7FD50D91D2AB6DD287BC86A9">>},
|
||||
{<<"gproc">>, <<"587E8AF698CCD3504CF4BA8D90F893EDE2B0F58CABB8A916E2BF9321DE3CF10B">>},
|
||||
{<<"hackney">>, <<"9AFCDA620704D720DB8C6A3123E9848D09C87586DC1C10479C42627B905B5C5E">>},
|
||||
{<<"idna">>, <<"92376EB7894412ED19AC475E4A86F7B413C1B9FBB5BD16DCCD57934157944CEA">>},
|
||||
{<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>},
|
||||
{<<"mimerl">>, <<"F278585650AA581986264638EBF698F8BB19DF297F66AD91B18910DFC6E19323">>},
|
||||
{<<"parse_trans">>, <<"07CD9577885F56362D414E8C4C4E6BDF10D43A8767ABB92D24CBE8B24C54888B">>},
|
||||
{<<"ranch">>, <<"451D8527787DF716D99DC36162FCA05934915DB0B6141BBDAC2EA8D3C7AFC7D7">>},
|
||||
{<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>},
|
||||
{<<"ssl_verify_fun">>, <<"BDB0D2471F453C88FF3908E7686F86F9BE327D065CC1EC16FA4540197EA04680">>},
|
||||
{<<"unicode_util_compat">>, <<"25EEE6D67DF61960CF6A794239566599B09E17E668D3700247BC498638152521">>}]}
|
||||
].
|
||||
|
@ -31,7 +31,7 @@
|
||||
-type limit() :: undefined | non_neg_integer().
|
||||
-type direction() :: forward | backward.
|
||||
-type range() :: {event_cursor(), limit(), direction()}.
|
||||
-type signal(T) :: {init, args(T)} | {repair, args(T)} | timeout.
|
||||
-type signal(T) :: {init, args(T)} | timeout.
|
||||
-type machine(E, A) :: #{
|
||||
namespace := namespace(),
|
||||
id := id(),
|
||||
@ -144,7 +144,8 @@ call(NS, Ref, Range, Args, Backend) ->
|
||||
{Module, Opts} = machinery_utils:get_backend(Backend),
|
||||
machinery_backend:call(Module, NS, Ref, Range, Args, Opts).
|
||||
|
||||
-spec repair(namespace(), ref(), args(_), backend(_)) -> {ok, response(_)} | {error, notfound | working}.
|
||||
-spec repair(namespace(), ref(), args(_), backend(_)) ->
|
||||
{ok, response(_)} | {error, notfound | working | {failed, machinery:error(_)}}.
|
||||
repair(NS, Ref, Args, Backend) ->
|
||||
repair(NS, Ref, {undefined, undefined, forward}, Args, Backend).
|
||||
|
||||
@ -168,13 +169,6 @@ get(NS, Ref, Range, Backend) ->
|
||||
-spec dispatch_signal(signal(_), machine(E, A), logic_handler(_), handler_opts(_)) -> result(E, A).
|
||||
dispatch_signal({init, Args}, Machine, {Handler, HandlerArgs}, Opts) ->
|
||||
Handler:init(Args, Machine, HandlerArgs, Opts);
|
||||
dispatch_signal({repair, Args}, Machine, {Handler, HandlerArgs}, Opts) ->
|
||||
case Handler:process_repair(Args, Machine, HandlerArgs, Opts) of
|
||||
{ok, {_Response, Result}} ->
|
||||
Result;
|
||||
{error, Reason} ->
|
||||
erlang:error({repair_failed, Reason})
|
||||
end;
|
||||
dispatch_signal(timeout, Machine, {Handler, HandlerArgs}, Opts) ->
|
||||
Handler:process_timeout(Machine, HandlerArgs, Opts).
|
||||
|
||||
|
@ -430,9 +430,6 @@ unmarshal({signal, Schema, Context0}, {init, #mg_stateproc_InitSignal{arg = Args
|
||||
{{init, Args1}, Context1};
|
||||
unmarshal({signal, _Schema, Context}, {timeout, #mg_stateproc_TimeoutSignal{}}) ->
|
||||
{timeout, Context};
|
||||
unmarshal({signal, Schema, Context0}, {repair, #mg_stateproc_RepairSignal{arg = Args0}}) ->
|
||||
{Args1, Context1} = unmarshal({schema, Schema, {args, repair}, Context0}, Args0),
|
||||
{{repair, Args1}, Context1};
|
||||
unmarshal({list, T}, V) when is_list(V) ->
|
||||
[unmarshal(T, E) || E <- V];
|
||||
unmarshal(T, V) ->
|
||||
|
@ -51,13 +51,19 @@ start_apps(AppNames) ->
|
||||
|
||||
-spec start_app(app_name()) -> {[Started :: app_name()], startup_ctx()}.
|
||||
start_app(scoper = AppName) ->
|
||||
{start_app_with(AppName, [
|
||||
{
|
||||
start_app_with(AppName, [
|
||||
{storage, scoper_storage_logger}
|
||||
]), #{}};
|
||||
]),
|
||||
#{}
|
||||
};
|
||||
start_app(woody = AppName) ->
|
||||
{start_app_with(AppName, [
|
||||
{
|
||||
start_app_with(AppName, [
|
||||
{acceptors_pool_size, 4}
|
||||
]), #{}};
|
||||
]),
|
||||
#{}
|
||||
};
|
||||
start_app(AppName) ->
|
||||
{start_app_with(AppName, []), #{}}.
|
||||
|
||||
|
@ -143,16 +143,14 @@ unmarshal(T, V, C) when
|
||||
T =:= {args, call} orelse
|
||||
T =:= {args, repair} orelse
|
||||
T =:= {response, call} orelse
|
||||
T =:= {response, {repair, success}} orelse
|
||||
T =:= {response, {repair, failure}}
|
||||
->
|
||||
{bin, EncodedV} = V,
|
||||
{erlang:binary_to_term(EncodedV), process_context(T, C)};
|
||||
unmarshal({aux_state, undefined} = T, {bin, <<>>}, C) ->
|
||||
% initial aux_state
|
||||
{undefined, process_context(T, C)};
|
||||
unmarshal({response, {repair, success}} = T, {bin, <<"ok">>}, C) ->
|
||||
% mg repair migration artefact
|
||||
{done, process_context(T, C)}.
|
||||
{undefined, process_context(T, C)}.
|
||||
|
||||
-spec get_version(machinery_mg_schema:vt()) -> machinery_mg_schema:version().
|
||||
get_version(aux_state) ->
|
||||
|
@ -97,7 +97,7 @@ simple_repair_test(C) ->
|
||||
ID = unique(),
|
||||
?assertEqual(ok, start(ID, init_numbers, C)),
|
||||
?assertError({failed, general, ID}, call(ID, fail, C)),
|
||||
?assertEqual({ok, <<"ok">>}, repair(ID, simple, C)),
|
||||
?assertEqual({ok, done}, repair(ID, simple, C)),
|
||||
?assertEqual({ok, lists:seq(1, 100)}, call(ID, get_events, C)).
|
||||
|
||||
-spec complex_repair_test(config()) -> test_return().
|
||||
@ -105,7 +105,7 @@ complex_repair_test(C) ->
|
||||
ID = unique(),
|
||||
?assertEqual(ok, start(ID, init_numbers, C)),
|
||||
?assertError({failed, general, ID}, call(ID, fail, C)),
|
||||
?assertEqual({ok, <<"ok">>}, repair(ID, {add_events, [repair_event]}, C)),
|
||||
?assertEqual({ok, done}, repair(ID, {add_events, [repair_event]}, C)),
|
||||
?assertEqual({ok, lists:seq(1, 100) ++ [repair_event]}, call(ID, get_events, C)).
|
||||
|
||||
-spec ranged_repair_test(config()) -> test_return().
|
||||
@ -113,7 +113,7 @@ ranged_repair_test(C) ->
|
||||
ID = unique(),
|
||||
?assertEqual(ok, start(ID, init_numbers, C)),
|
||||
?assertError({failed, general, ID}, call(ID, fail, C)),
|
||||
?assertEqual({ok, <<"ok">>}, repair(ID, count_events, {20, 10, forward}, C)),
|
||||
?assertEqual({ok, done}, repair(ID, count_events, {20, 10, forward}, C)),
|
||||
?assertEqual({ok, lists:seq(1, 100) ++ [{count_events, 10}]}, call(ID, get_events, C)).
|
||||
|
||||
-spec notfound_repair_test(config()) -> test_return().
|
||||
@ -124,9 +124,10 @@ notfound_repair_test(C) ->
|
||||
-spec failed_repair_test(config()) -> test_return().
|
||||
failed_repair_test(C) ->
|
||||
ID = unique(),
|
||||
Reason = fail,
|
||||
?assertEqual(ok, start(ID, init_numbers, C)),
|
||||
?assertError({failed, general, ID}, call(ID, fail, C)),
|
||||
?assertError({failed, general, ID}, repair(ID, fail, C)),
|
||||
?assertEqual({error, {failed, {Reason, #{machine_ns => general, machine_ref => ID}}}}, repair(ID, Reason, C)),
|
||||
?assertError({failed, general, ID}, call(ID, get_events, C)).
|
||||
|
||||
-spec unexpected_failed_repair_test(config()) -> test_return().
|
||||
|
Loading…
Reference in New Issue
Block a user