From 4954bd423efdc1897696d22f18d57e5c1f203d1c Mon Sep 17 00:00:00 2001 From: kehitt Date: Fri, 14 Jan 2022 16:03:30 +0300 Subject: [PATCH 01/40] change woody.error-reason missing message to be more readable --- src/woody_client_thrift_http_transport.erl | 7 ++++--- src/woody_client_thrift_v2.erl | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/woody_client_thrift_http_transport.erl b/src/woody_client_thrift_http_transport.erl index 7cc56f1..e8d8aeb 100644 --- a/src/woody_client_thrift_http_transport.erl +++ b/src/woody_client_thrift_http_transport.erl @@ -300,9 +300,10 @@ check_error_reason(Headers, Code, WoodyState) -> -spec do_check_error_reason(header_parse_value(), woody:http_code(), woody_state:st()) -> woody_error:details(). do_check_error_reason(none, 200, _WoodyState) -> <<>>; -do_check_error_reason(none, Code, WoodyState) -> - _ = log_event(?EV_TRACE, WoodyState, #{event => woody_util:to_binary([?HEADER_E_REASON, " header missing"])}), - woody_util:to_binary(["got response with http code ", Code, " and without ", ?HEADER_E_REASON, " header"]); +do_check_error_reason(none, _Code, WoodyState) -> + EventMessage = <<"server receiving this request does not implement the woody protocol">>, + _ = log_event(?EV_TRACE, WoodyState, #{event => EventMessage}), + EventMessage; do_check_error_reason(Reason, _, _) -> Reason. diff --git a/src/woody_client_thrift_v2.erl b/src/woody_client_thrift_v2.erl index b2f6046..13cabef 100644 --- a/src/woody_client_thrift_v2.erl +++ b/src/woody_client_thrift_v2.erl @@ -294,9 +294,10 @@ check_error_reason(Headers, Code, WoodyState) -> -spec do_check_error_reason(header_parse_value(), woody:http_code(), woody_state:st()) -> woody_error:details(). do_check_error_reason(none, 200, _WoodyState) -> <<>>; -do_check_error_reason(none, Code, WoodyState) -> - _ = log_event(?EV_TRACE, WoodyState, #{event => woody_util:to_binary([?HEADER_E_REASON, " header missing"])}), - woody_util:to_binary(["got response with http code ", Code, " and without ", ?HEADER_E_REASON, " header"]); +do_check_error_reason(none, _Code, WoodyState) -> + EventMessage = <<"server receiving this request does not implement the woody protocol">>, + _ = log_event(?EV_TRACE, WoodyState, #{event => EventMessage}), + EventMessage; do_check_error_reason(Reason, _, _) -> Reason. From e372d869a88cea789abbb53ed8f702676101db60 Mon Sep 17 00:00:00 2001 From: kehitt Date: Fri, 14 Jan 2022 16:40:07 +0300 Subject: [PATCH 02/40] switch to forked deps, employ actions for CI --- .github/workflows/code-checks.yml | 51 +++++++++++++++++++++++++++++++ .gitmodules | 4 --- Jenkinsfile | 42 ------------------------- Makefile | 32 ++----------------- README.md | 10 +++--- build_utils | 1 - rebar.config | 14 ++++----- rebar.lock | 6 ++-- src/woody.app.src | 3 -- 9 files changed, 69 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/code-checks.yml delete mode 100644 .gitmodules delete mode 100644 Jenkinsfile delete mode 160000 build_utils diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml new file mode 100644 index 0000000..15ac6b4 --- /dev/null +++ b/.github/workflows/code-checks.yml @@ -0,0 +1,51 @@ +name: Erlang CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + + container: + image: erlang:24.1.6 + + steps: + - uses: actions/checkout@v2 + + - name: Cache rebar3 + if: ${{ !env.ACT }} + id: cache-rebar3 + uses: actions/cache@v2 + with: + path: "~/.cache/rebar3" + key: rebar-global-cache-${{ hashFiles('rebar.lock') }} + + - name: Cache _build + if: ${{ !env.ACT }} + id: cache-build + uses: actions/cache@v2 + with: + path: "_build/default/" + key: ${{ runner.os }}-${{ hashFiles('rebar.lock') }}-build-default + + - name: Compile + run: make compile + + - name: Check formatting + run: make check_format + + - name: Run xref + run: make xref + + - name: Run linting + run: make lint + + - name: Run dialyzer + run: make dialyze + + - name: Run tests + run: make test diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index ca5a761..0000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "build_utils"] - path = build_utils - url = git@github.com:rbkmoney/build_utils.git - branch = master diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 34abea0..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,42 +0,0 @@ -#!groovy -// -*- mode: groovy -*- -// -// Copyright 2017 RBKmoney -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -def finalHook = { - runStage('store CT logs') { - archive '_build/test/logs/' - } -} - -build('woody_erlang', '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") - } - - // NOTE: Parallel pipeline almost always fails because of - // rebar3's design (it uses link for libraries, so - // parallel runs with different profiles brake each other) - // To prevent this use sequential pipleine here - - pipeErlangLib.runPipe(false, false, 'test') -} diff --git a/Makefile b/Makefile index 4c591d6..3537f9a 100644 --- a/Makefile +++ b/Makefile @@ -1,39 +1,13 @@ REBAR := $(shell which rebar3 2>/dev/null || which ./rebar3) -SUBMODULES = build_utils -SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES)) -UTILS_PATH := build_utils -# ToDo: remove unused TEMPLATES_PATH here, when the bug -# with handling of the varriable in build_utils is fixed -TEMPLATES_PATH := . -SERVICE_NAME := woody - -BUILD_IMAGE_NAME := build-erlang -BUILD_IMAGE_TAG := c60896ef07d41e7ae2e5f9b6ce845a60ad79acc7 - -CALL_W_CONTAINER := all submodules compile xref lint test bench dialyze clean distclean \ - check_format format - -.PHONY: $(CALL_W_CONTAINER) - -all: compile - --include $(UTILS_PATH)/make_lib/utils_container.mk - -$(SUBTARGETS): %/.git: % - git submodule update --init $< - touch $@ - -submodules: $(SUBTARGETS) - -compile: submodules +compile: $(REBAR) compile -test: submodules +test: $(REBAR) eunit $(REBAR) ct -xref: submodules +xref: $(REBAR) xref lint: compile diff --git a/README.md b/README.md index 76e42b2..318a622 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -Woody [![Build Status](http://ci.rbkmoney.com/buildStatus/icon?job=rbkmoney_private/woody_erlang/master)](http://ci.rbkmoney.com/job/rbkmoney_private/view/Erlang/job/woody_erlang/job/master/) +Woody ====== -Erlang реализация [Библиотеки RPC вызовов для общения между микросервисами](http://coredocs.rbkmoney.com/design/ms/platform/rpc-lib/) +Erlang реализация [Библиотеки RPC вызовов для общения между микросервисами](#coredocs/design/ms/platform/rpc-lib/) версия требований: __ac4d40cc22d649d03369fcd52fb1230e51cdf52e__ @@ -58,7 +58,7 @@ Erlang реализация [Библиотеки RPC вызовов для об В случае вызова _thrift_ `oneway` функции (_thrift_ реализация _cast_) `woody_client:call/3` вернет `{ok, ok}`. -Если сервер бросает `Exception`, описанный в _.thrift_ файле сервиса (т.е. _Бизнес ошибку_ в [терминологии](http://coredocs.rbkmoney.com/design/ms/platform/overview/#_7) макросервис платформы), `woody_client:call/3` вернет это исключение в виде: `{exception, Exception}`. +Если сервер бросает `Exception`, описанный в _.thrift_ файле сервиса (т.е. _Бизнес ошибку_ в [терминологии](#coredocs/design/ms/platform/overview/#_7) макросервис платформы), `woody_client:call/3` вернет это исключение в виде: `{exception, Exception}`. В случае получения _Системной_ ошибки клиент выбрасывает _erlang:error_ типа `{woody_error, woody_error:system_error()}`. @@ -74,7 +74,7 @@ Erlang реализация [Библиотеки RPC вызовов для об 18> {ok, Result2} = woody_client:call(Request, Opts1, Context2). ``` -`Context` позволяет аннотировать RPC запросы дополнительными мета данными в виде _key-value_. `Context` передается только в запросах и изменение мета данных возможно только в режиме _append-only_ (т.е. на попытку переопределить уже существующую запись в `context meta`, библиотека вернет ошибку). Поскольку на транспортном уровне контекст передается в виде custom HTTP заголовков, синтаксис метаданных _key-value_ должен следовать ограничениям [RFC7230 ](https://tools.ietf.org/html/rfc7230#section-3.2.6). Размер ключа записи метаданных не должен превышать _53 байта_ (см. остальные требования к метаданным в [описании библиотеки](http://coredocs.rbkmoney.com/design/ms/platform/rpc-lib/#rpc_2)). +`Context` позволяет аннотировать RPC запросы дополнительными мета данными в виде _key-value_. `Context` передается только в запросах и изменение мета данных возможно только в режиме _append-only_ (т.е. на попытку переопределить уже существующую запись в `context meta`, библиотека вернет ошибку). Поскольку на транспортном уровне контекст передается в виде custom HTTP заголовков, синтаксис метаданных _key-value_ должен следовать ограничениям [RFC7230 ](https://tools.ietf.org/html/rfc7230#section-3.2.6). Размер ключа записи метаданных не должен превышать _53 байта_ (см. остальные требования к метаданным в [описании библиотеки](#coredocs/design/ms/platform/rpc-lib/#rpc_2)). ```erlang 19> Meta1 = #{<<"client1-name">> => <<"Vasya">>}. @@ -87,7 +87,7 @@ Erlang реализация [Библиотеки RPC вызовов для об 26> FullMeta = woody_context:get_meta(Context4). ``` -`Context` также позволяет задать [deadline](http://coredocs.rbkmoney.com/design/ms/platform/rpc-lib/#deadline) на исполнение запроса. Значение _deadline_ вложенных запросов можно менять произвольным образом. Также таймауты на запрос, [вычисляемые по deadline](src/woody_client_thrift_http_transport.erl), можно явно переопределить из приложения через _transport_opts_ в `woody_client:options()`. Модуль [woody_deadline](src/woody_deadline.erl) содержит API для работы с deadline. +`Context` также позволяет задать [deadline](#coredocs/design/ms/platform/rpc-lib/#deadline) на исполнение запроса. Значение _deadline_ вложенных запросов можно менять произвольным образом. Также таймауты на запрос, [вычисляемые по deadline](src/woody_client_thrift_http_transport.erl), можно явно переопределить из приложения через _transport_opts_ в `woody_client:options()`. Модуль [woody_deadline](src/woody_deadline.erl) содержит API для работы с deadline. ```erlang 27> Deadline = {{{2017, 12, 31}, {23, 59, 59}}, 350}. diff --git a/build_utils b/build_utils deleted file mode 160000 index e131872..0000000 --- a/build_utils +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e1318727d4d0c3e48f5122bf3197158b6695f50e diff --git a/rebar.config b/rebar.config index e99fd0d..5dca717 100644 --- a/rebar.config +++ b/rebar.config @@ -24,9 +24,9 @@ {hackney, "1.18.0"}, {gproc , "0.9.0"}, {cache , "2.3.3"}, - {thrift, {git, "https://github.com/rbkmoney/thrift_erlang.git", {branch, "master"}}}, - {snowflake, {git, "https://github.com/rbkmoney/snowflake.git", {branch, "master"}}}, - {genlib, {git, "https://github.com/rbkmoney/genlib.git", {branch, "master"}}} + {thrift, {git, "https://github.com/valitydev/thrift_erlang.git", {branch, "master"}}}, + {snowflake, {git, "https://github.com/valitydev/snowflake.git", {branch, "master"}}}, + {genlib, {git, "https://github.com/valitydev/genlib.git", {branch, "master"}}} ]}. {xref_checks, [ @@ -70,9 +70,9 @@ {deps, [ {cth_readable, "1.4.9"}, {proper, "1.4.0"}, - {woody_api_hay,{git, "https://github.com/rbkmoney/woody_api_hay.git", {branch, "master"}}}, - {damsel , {git, "https://github.com/rbkmoney/damsel.git", {ref, "8911ac3"}}}, - {mg_proto , {git, "https://github.com/rbkmoney/machinegun_proto.git", {ref, "ebae56f"}}} + {woody_api_hay,{git, "https://github.com/valitydev/woody_api_hay.git", {branch, "master"}}}, + {damsel , {git, "https://github.com/valitydev/damsel.git", {ref, "8911ac3"}}}, + {mg_proto , {git, "https://github.com/valitydev/machinegun-proto.git", {ref, "ebae56f"}}} ]}, {dialyzer, [ {plt_extra_apps, [how_are_you, eunit, proper, common_test, cth_readable]} @@ -81,7 +81,7 @@ ]}. {plugins, [ - {rebar3_thrift_compiler, {git, "https://github.com/rbkmoney/rebar3_thrift_compiler.git", {branch, "master"}}}, + {rebar3_thrift_compiler, {git, "https://github.com/valitydev/rebar3_thrift_compiler.git", {branch, "master"}}}, {erlfmt, "0.14.1"} ]}. diff --git a/rebar.lock b/rebar.lock index 1fa17dc..a2dc820 100644 --- a/rebar.lock +++ b/rebar.lock @@ -4,7 +4,7 @@ {<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.9.0">>},0}, {<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},1}, {<<"genlib">>, - {git,"https://github.com/rbkmoney/genlib.git", + {git,"https://github.com/valitydev/genlib.git", {ref,"4565a8d73f34a0b78cca32c9cd2b97d298bdadf8"}}, 0}, {<<"gproc">>,{pkg,<<"gproc">>,<<"0.9.0">>},0}, @@ -15,12 +15,12 @@ {<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.1">>},1}, {<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},1}, {<<"snowflake">>, - {git,"https://github.com/rbkmoney/snowflake.git", + {git,"https://github.com/valitydev/snowflake.git", {ref,"de159486ef40cec67074afe71882bdc7f7deab72"}}, 0}, {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.6">>},1}, {<<"thrift">>, - {git,"https://github.com/rbkmoney/thrift_erlang.git", + {git,"https://github.com/valitydev/thrift_erlang.git", {ref,"c280ff266ae1c1906fb0dcee8320bb8d8a4a3c75"}}, 0}, {<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},1}]}. diff --git a/src/woody.app.src b/src/woody.app.src index 1f9bc53..4dcb2f9 100644 --- a/src/woody.app.src +++ b/src/woody.app.src @@ -17,9 +17,6 @@ {enable_debug, false} ]}, {modules, []}, - {maintainers, [ - "Anton Belyaev " - ]}, {licenses, []}, {links, []} ]}. From f947d7114f4b04a1a6fdd25fd4471d6dee4041ff Mon Sep 17 00:00:00 2001 From: kehitt Date: Fri, 14 Jan 2022 16:44:30 +0300 Subject: [PATCH 03/40] lint with rebar3 lint --- Makefile | 4 ++-- rebar.config | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3537f9a..8bb42fd 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,8 @@ test: xref: $(REBAR) xref -lint: compile - elvis rock +lint: + $(REBAR) lint check_format: $(REBAR) fmt -c diff --git a/rebar.config b/rebar.config index 5dca717..82df4fa 100644 --- a/rebar.config +++ b/rebar.config @@ -82,7 +82,8 @@ {plugins, [ {rebar3_thrift_compiler, {git, "https://github.com/valitydev/rebar3_thrift_compiler.git", {branch, "master"}}}, - {erlfmt, "0.14.1"} + {erlfmt, "0.14.1"}, + {rebar3_lint, "1.0.1"} ]}. {erlfmt, [ From 6199ab439677dc523293769ae836be64455b08ee Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 15:08:05 +0300 Subject: [PATCH 04/40] fix elvis, update workflow --- .github/workflows/code-checks.yml | 51 ---------------- .github/workflows/erlang-library.yml | 90 ++++++++++++++++++++++++++++ Makefile | 5 ++ elvis.config | 59 ++++++++++-------- rebar.config | 27 ++++++--- rebar.config.script | 5 -- 6 files changed, 146 insertions(+), 91 deletions(-) delete mode 100644 .github/workflows/code-checks.yml create mode 100644 .github/workflows/erlang-library.yml delete mode 100644 rebar.config.script diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml deleted file mode 100644 index 15ac6b4..0000000 --- a/.github/workflows/code-checks.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Erlang CI - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - - container: - image: erlang:24.1.6 - - steps: - - uses: actions/checkout@v2 - - - name: Cache rebar3 - if: ${{ !env.ACT }} - id: cache-rebar3 - uses: actions/cache@v2 - with: - path: "~/.cache/rebar3" - key: rebar-global-cache-${{ hashFiles('rebar.lock') }} - - - name: Cache _build - if: ${{ !env.ACT }} - id: cache-build - uses: actions/cache@v2 - with: - path: "_build/default/" - key: ${{ runner.os }}-${{ hashFiles('rebar.lock') }}-build-default - - - name: Compile - run: make compile - - - name: Check formatting - run: make check_format - - - name: Run xref - run: make xref - - - name: Run linting - run: make lint - - - name: Run dialyzer - run: make dialyze - - - name: Run tests - run: make test diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml new file mode 100644 index 0000000..a5f54a2 --- /dev/null +++ b/.github/workflows/erlang-library.yml @@ -0,0 +1,90 @@ +name: Erlang library CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ '*' ] + +jobs: + build: + name: Build (${{ matrix.os }}, OTP-${{ matrix.otp_version }}) + + runs-on: ${{ matrix.os }} + + defaults: + run: + shell: bash + + strategy: + matrix: + otp_version: [24.1] + os: [ubuntu-latest] + + env: + THRIFT_COMPILER_VERSION: 0.14.2 + + container: + image: erlang:${{ matrix.otp_version }} + + steps: + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Cache Hex packages + uses: actions/cache@v1 + with: + path: ~/.cache/rebar3/hex/hexpm/packages + key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- + + - name: Cache PLTs + uses: actions/cache@v1 + with: + path: | + ~/.cache/rebar3/rebar3_*_plt + _build/default/rebar3_*_plt + key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt- + + - name: Install thrift compiler (temporary) + run: | + wget -c https://github.com/valitydev/thrift/releases/download/${{ env.THRIFT_COMPILER_VERSION }}/thrift-${{ env.THRIFT_COMPILER_VERSION }}-linux-x86_64.tar.gz -O - | tar -xz -C /usr/local/bin/ + chmod +x /usr/local/bin/thrift + + - name: Compile + run: make compile + + - name: Check formatting + run: make check_format + + - name: Run xref + run: make xref + + - name: Run linting + run: make lint + + - name: Run dialyzer + run: make dialyze + + - name: Run tests + id: run_tests + run: make test + + - name: Store CT Logs + if: ${{ failure() && steps.run_tests.outcome == 'failure' }} + uses: actions/upload-artifact@v2 + with: + name: ct-logs + path: _build/test/logs + + - name: Run cover + run: make cover + + - name: Upload cover to codecov + - uses: codecov/codecov-action@v2 + with: + files: _build/test/cover/ct.coverdata diff --git a/Makefile b/Makefile index 8bb42fd..26b9097 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ REBAR := $(shell which rebar3 2>/dev/null || which ./rebar3) +.PHONY: compile test xref lint check_format format clean distclean dialyze cover bench + compile: $(REBAR) compile @@ -31,6 +33,9 @@ distclean: dialyze: $(REBAR) as test dialyzer +cover: + $(REBAR) cover + bench: $(REBAR) as test bench -m bench_woody_event_handler -n 1000 $(REBAR) as test bench -m bench_woody_formatter -n 10 diff --git a/elvis.config b/elvis.config index ed26d1d..b9be246 100644 --- a/elvis.config +++ b/elvis.config @@ -2,29 +2,28 @@ {elvis, [ {config, [ #{ - dirs => ["src", "test"], + dirs => ["src", "include", "test"], filter => "*.erl", + ruleset => erl_files, rules => [ - {elvis_style, line_length, #{limit => 120, skip_comments => false}}, - {elvis_style, no_tabs}, - {elvis_style, no_trailing_whitespace}, - {elvis_style, operator_spaces, #{rules => [{right, ","}, {right, "++"}, {left, "++"}]}}, + % common conventions + {elvis_text_style, line_length, #{limit => 120}}, + {elvis_text_style, no_trailing_whitespace, #{ignore_empty_lines => true}}, {elvis_style, nesting_level, #{level => 3}}, - {elvis_style, god_modules, #{limit => 25, ignore => [woody_tests_SUITE]}}, - {elvis_style, no_if_expression}, + {elvis_style, no_if_expression, disable}, + {elvis_style, state_record_and_type, disable}, + % woody_erlang specific + {elvis_style, function_naming_convention, #{regex => "^([a-z][a-z0-9_]*_?)*$"}}, + {elvis_style, atom_naming_convention, #{regex => "^([a-z][a-zA-Z0-9_]*_?)*$"}}, + {elvis_style, macro_names, #{ignore => [woody_transport_opts_SUITE]}}, + {elvis_style, macro_module_names, disable}, {elvis_style, invalid_dynamic_call, #{ ignore => [ - woody_client_thrift, woody_event_formatter, + woody_event_handler, woody_util ] }}, - {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, no_spec_with_records}, - {elvis_style, dont_repeat_yourself, #{min_complexity => 17, ignore => [woody_test_thrift, woody_tests_SUITE]}}, {elvis_style, no_debug_call, #{ ignore => [ woody_ssl_SUITE, @@ -33,18 +32,14 @@ woody_ct_event_h, benchmark_memory_pressure ] + }}, + {elvis_style, god_modules, #{limit => 25, ignore => [woody_tests_SUITE]}}, + {elvis_style, dont_repeat_yourself, #{ + min_complexity => 17, + ignore => [woody_test_thrift, woody_tests_SUITE] }} ] }, - #{ - dirs => ["src"], - filter => "*.app.src", - rules => [ - {elvis_style, line_length, #{limit => 120, skip_comments => false}}, - {elvis_style, no_tabs}, - {elvis_style, no_trailing_whitespace} - ] - }, #{ dirs => ["."], filter => "Makefile", @@ -58,10 +53,22 @@ #{ dirs => ["."], filter => "rebar.config", + ruleset => rebar_config, + rules => [ + {elvis_text_style, line_length, #{limit => 120, skip_comments => false}}, + {elvis_text_style, no_tabs}, + {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_style, line_length, #{limit => 120, skip_comments => false}}, - {elvis_style, no_tabs}, - {elvis_style, no_trailing_whitespace} + {elvis_text_style, line_length, #{limit => 120, skip_comments => false}}, + {elvis_text_style, no_tabs}, + {elvis_text_style, no_trailing_whitespace} ] } ]} diff --git a/rebar.config b/rebar.config index 82df4fa..cd8faa6 100644 --- a/rebar.config +++ b/rebar.config @@ -22,8 +22,8 @@ {deps, [ {cowboy, "2.9.0"}, {hackney, "1.18.0"}, - {gproc , "0.9.0"}, - {cache , "2.3.3"}, + {gproc, "0.9.0"}, + {cache, "2.3.3"}, {thrift, {git, "https://github.com/valitydev/thrift_erlang.git", {branch, "master"}}}, {snowflake, {git, "https://github.com/valitydev/snowflake.git", {branch, "master"}}}, {genlib, {git, "https://github.com/valitydev/genlib.git", {branch, "master"}}} @@ -70,9 +70,14 @@ {deps, [ {cth_readable, "1.4.9"}, {proper, "1.4.0"}, - {woody_api_hay,{git, "https://github.com/valitydev/woody_api_hay.git", {branch, "master"}}}, - {damsel , {git, "https://github.com/valitydev/damsel.git", {ref, "8911ac3"}}}, - {mg_proto , {git, "https://github.com/valitydev/machinegun-proto.git", {ref, "ebae56f"}}} + {woody_api_hay, + {git, "https://github.com/valitydev/woody_api_hay.git", + {ref, "4c39134cddaa9bf6fb8db18e7030ae64f1efb3a9"}}}, + {damsel, + {git, "https://github.com/valitydev/damsel.git", {ref, "3fa6f31db54b2ae781b27898ab4daf56bb36eb36"}}}, + {mg_proto, + {git, "https://github.com/valitydev/machinegun-proto.git", + {ref, "e4784ab4647ae9dfdf1733ff2ec97578632f137d"}}} ]}, {dialyzer, [ {plt_extra_apps, [how_are_you, eunit, proper, common_test, cth_readable]} @@ -81,15 +86,19 @@ ]}. {plugins, [ - {rebar3_thrift_compiler, {git, "https://github.com/valitydev/rebar3_thrift_compiler.git", {branch, "master"}}}, - {erlfmt, "0.14.1"}, + {rebar3_thrift_compiler, + {git, "https://github.com/valitydev/rebar3_thrift_compiler.git", + {ref, "cd78af5f30ebaa88f84c144d63f9548d3e3b5d3f"}}}, + {erlfmt, "1.0.0"}, {rebar3_lint, "1.0.1"} ]}. {erlfmt, [ {print_width, 120}, {files, [ - "{src,include,test}/*.{hrl,erl}", - "test/*/*.{hrl,erl}" + "{src,include}/*.{hrl,erl}", + "test/*.{hrl,erl}", + "rebar.config", + "elvis.config" ]} ]}. diff --git a/rebar.config.script b/rebar.config.script deleted file mode 100644 index 93ee90c..0000000 --- a/rebar.config.script +++ /dev/null @@ -1,5 +0,0 @@ -case os:getenv("WERCKER_CACHE_DIR") of - false -> CONFIG; - [] -> CONFIG; - Dir -> lists:keystore(global_rebar_dir, 1, CONFIG, {global_rebar_dir, Dir}) -end. From 1a17cca23cecb3b65e5e5261272193d640c5511a Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 15:10:13 +0300 Subject: [PATCH 05/40] fix workflow branches --- .github/workflows/erlang-library.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index a5f54a2..a85d308 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -4,7 +4,7 @@ on: push: branches: [ master ] pull_request: - branches: [ '*' ] + branches: [ '**' ] jobs: build: From 504951f2283bac94af86486fb0d511e4ce834025 Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 15:11:24 +0300 Subject: [PATCH 06/40] fix workflow step typo --- .github/workflows/erlang-library.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index a85d308..2114cd2 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -85,6 +85,6 @@ jobs: run: make cover - name: Upload cover to codecov - - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v2 with: files: _build/test/cover/ct.coverdata From 187315dc4c95eff461da6bf73e99a6aaa8b85383 Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 15:16:20 +0300 Subject: [PATCH 07/40] fix workflow thrift dep --- .github/workflows/erlang-library.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index 2114cd2..4142169 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -52,6 +52,7 @@ jobs: - name: Install thrift compiler (temporary) run: | + apt-get -y install libstdc++6 wget -c https://github.com/valitydev/thrift/releases/download/${{ env.THRIFT_COMPILER_VERSION }}/thrift-${{ env.THRIFT_COMPILER_VERSION }}-linux-x86_64.tar.gz -O - | tar -xz -C /usr/local/bin/ chmod +x /usr/local/bin/thrift From b43e7101369984acb2358f4cc2ec79e33600b01f Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 15:21:18 +0300 Subject: [PATCH 08/40] once more --- .github/workflows/erlang-library.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index 4142169..ce3f61f 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -52,7 +52,10 @@ jobs: - name: Install thrift compiler (temporary) run: | - apt-get -y install libstdc++6 + apt-get -y install software-properties-common + sudo add-apt-repository ppa:ubuntu-toolchain-r/test + apt-get update + apt-get -y install gcc-9 libstdc++6 wget -c https://github.com/valitydev/thrift/releases/download/${{ env.THRIFT_COMPILER_VERSION }}/thrift-${{ env.THRIFT_COMPILER_VERSION }}-linux-x86_64.tar.gz -O - | tar -xz -C /usr/local/bin/ chmod +x /usr/local/bin/thrift From bbd4d655fc855a5d22f4f3668fdadd5477773066 Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 15:21:32 +0300 Subject: [PATCH 09/40] fix --- .github/workflows/erlang-library.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index ce3f61f..e3239f1 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -53,7 +53,7 @@ jobs: - name: Install thrift compiler (temporary) run: | apt-get -y install software-properties-common - sudo add-apt-repository ppa:ubuntu-toolchain-r/test + add-apt-repository ppa:ubuntu-toolchain-r/test apt-get update apt-get -y install gcc-9 libstdc++6 wget -c https://github.com/valitydev/thrift/releases/download/${{ env.THRIFT_COMPILER_VERSION }}/thrift-${{ env.THRIFT_COMPILER_VERSION }}-linux-x86_64.tar.gz -O - | tar -xz -C /usr/local/bin/ From 7df8f5bbe59523fda63800d41aa998b638c4f700 Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 16:27:08 +0300 Subject: [PATCH 10/40] test --- .github/workflows/erlang-library.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index e3239f1..ae58cba 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -11,14 +11,10 @@ jobs: name: Build (${{ matrix.os }}, OTP-${{ matrix.otp_version }}) runs-on: ${{ matrix.os }} - - defaults: - run: - shell: bash strategy: matrix: - otp_version: [24.1] + otp_version: [24.2] os: [ubuntu-latest] env: @@ -33,6 +29,7 @@ jobs: uses: actions/checkout@v2 - name: Cache Hex packages + if: ${{ !env.ACT }} uses: actions/cache@v1 with: path: ~/.cache/rebar3/hex/hexpm/packages @@ -41,6 +38,7 @@ jobs: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- - name: Cache PLTs + if: ${{ !env.ACT }} uses: actions/cache@v1 with: path: | @@ -52,10 +50,6 @@ jobs: - name: Install thrift compiler (temporary) run: | - apt-get -y install software-properties-common - add-apt-repository ppa:ubuntu-toolchain-r/test - apt-get update - apt-get -y install gcc-9 libstdc++6 wget -c https://github.com/valitydev/thrift/releases/download/${{ env.THRIFT_COMPILER_VERSION }}/thrift-${{ env.THRIFT_COMPILER_VERSION }}-linux-x86_64.tar.gz -O - | tar -xz -C /usr/local/bin/ chmod +x /usr/local/bin/thrift @@ -79,7 +73,7 @@ jobs: run: make test - name: Store CT Logs - if: ${{ failure() && steps.run_tests.outcome == 'failure' }} + if: ${{ failure() && steps.run_tests.outcome == 'failure' && !env.ACT }} uses: actions/upload-artifact@v2 with: name: ct-logs @@ -89,6 +83,7 @@ jobs: run: make cover - name: Upload cover to codecov + if: ${{ !env.ACT }} uses: codecov/codecov-action@v2 with: files: _build/test/cover/ct.coverdata From f3d1008298b9fe9a755dcae89e2bf924f96fd631 Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 18:36:53 +0300 Subject: [PATCH 11/40] roll back test deps, change error message again, fix workflow --- .github/workflows/erlang-library.yml | 16 +++++----------- rebar.config | 2 +- src/woody_client_thrift_http_transport.erl | 7 ++++--- src/woody_client_thrift_v2.erl | 7 ++++--- src/woody_event_handler.erl | 6 +++--- test/woody_tests_SUITE.erl | 5 ++--- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index ae58cba..4ba7082 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -17,9 +17,6 @@ jobs: otp_version: [24.2] os: [ubuntu-latest] - env: - THRIFT_COMPILER_VERSION: 0.14.2 - container: image: erlang:${{ matrix.otp_version }} @@ -29,7 +26,6 @@ jobs: uses: actions/checkout@v2 - name: Cache Hex packages - if: ${{ !env.ACT }} uses: actions/cache@v1 with: path: ~/.cache/rebar3/hex/hexpm/packages @@ -38,7 +34,6 @@ jobs: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- - name: Cache PLTs - if: ${{ !env.ACT }} uses: actions/cache@v1 with: path: | @@ -47,11 +42,11 @@ jobs: key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt-${{ hashFiles('**/rebar.lock') }} restore-keys: | ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt- - - - name: Install thrift compiler (temporary) - run: | - wget -c https://github.com/valitydev/thrift/releases/download/${{ env.THRIFT_COMPILER_VERSION }}/thrift-${{ env.THRIFT_COMPILER_VERSION }}-linux-x86_64.tar.gz -O - | tar -xz -C /usr/local/bin/ - chmod +x /usr/local/bin/thrift + + - name: Setup thrift compiler + uses: valitydev/action-setup-thrift@v0.0.4 + with: + thrift-version: '0.14.2' - name: Compile run: make compile @@ -83,7 +78,6 @@ jobs: run: make cover - name: Upload cover to codecov - if: ${{ !env.ACT }} uses: codecov/codecov-action@v2 with: files: _build/test/cover/ct.coverdata diff --git a/rebar.config b/rebar.config index cd8faa6..eab5c46 100644 --- a/rebar.config +++ b/rebar.config @@ -77,7 +77,7 @@ {git, "https://github.com/valitydev/damsel.git", {ref, "3fa6f31db54b2ae781b27898ab4daf56bb36eb36"}}}, {mg_proto, {git, "https://github.com/valitydev/machinegun-proto.git", - {ref, "e4784ab4647ae9dfdf1733ff2ec97578632f137d"}}} + {ref, "ebae56fe2b3e79e4eb34afc8cb55c9012ae989f8"}}} ]}, {dialyzer, [ {plt_extra_apps, [how_are_you, eunit, proper, common_test, cth_readable]} diff --git a/src/woody_client_thrift_http_transport.erl b/src/woody_client_thrift_http_transport.erl index e8d8aeb..d9ba61d 100644 --- a/src/woody_client_thrift_http_transport.erl +++ b/src/woody_client_thrift_http_transport.erl @@ -301,9 +301,10 @@ check_error_reason(Headers, Code, WoodyState) -> do_check_error_reason(none, 200, _WoodyState) -> <<>>; do_check_error_reason(none, _Code, WoodyState) -> - EventMessage = <<"server receiving this request does not implement the woody protocol">>, - _ = log_event(?EV_TRACE, WoodyState, #{event => EventMessage}), - EventMessage; + _ = log_event(?EV_TRACE, WoodyState, #{event => woody_util:to_binary([?HEADER_E_REASON, " header missing"])}), + woody_util:to_binary([ + "This server does not implement the woody protocol ('", ?HEADER_E_REASON, "' header missing)." + ]); do_check_error_reason(Reason, _, _) -> Reason. diff --git a/src/woody_client_thrift_v2.erl b/src/woody_client_thrift_v2.erl index 13cabef..e204d23 100644 --- a/src/woody_client_thrift_v2.erl +++ b/src/woody_client_thrift_v2.erl @@ -295,9 +295,10 @@ check_error_reason(Headers, Code, WoodyState) -> do_check_error_reason(none, 200, _WoodyState) -> <<>>; do_check_error_reason(none, _Code, WoodyState) -> - EventMessage = <<"server receiving this request does not implement the woody protocol">>, - _ = log_event(?EV_TRACE, WoodyState, #{event => EventMessage}), - EventMessage; + _ = log_event(?EV_TRACE, WoodyState, #{event => woody_util:to_binary([?HEADER_E_REASON, " header missing"])}), + woody_util:to_binary([ + "This server does not implement the woody protocol ('", ?HEADER_E_REASON, "' header missing)." + ]); do_check_error_reason(Reason, _, _) -> Reason. diff --git a/src/woody_event_handler.erl b/src/woody_event_handler.erl index 5b43c95..f819d41 100644 --- a/src/woody_event_handler.erl +++ b/src/woody_event_handler.erl @@ -661,14 +661,14 @@ format_service_request_test_() -> ), ?_assertEqual( "[1012689088739803136 1012689108264288256 1012689088534282240][client] calling " - "CustomerManagement:Create(params=CustomerParams{party_id='1CQdDqPROyW',shop_id='1CQdDwgt3R3'," - "contact_info=ContactInfo{email='invalid_shop'},metadata=Value{nl=Null{}}})", + "CustomerManagement:Create(params=CustomerParams{customer_id='1',party_id='1CQdDqPROyW'," + "shop_id='1CQdDwgt3R3',contact_info=ContactInfo{email='invalid_shop'},metadata=Value{nl=Null{}}})", format_msg_limited( format_event( ?EV_CALL_SERVICE, #{ args => - {{payproc_CustomerParams, <<"1CQdDqPROyW">>, <<"1CQdDwgt3R3">>, + {{payproc_CustomerParams, <<"1">>, <<"1CQdDqPROyW">>, <<"1CQdDwgt3R3">>, {domain_ContactInfo, undefined, <<"invalid_shop">>}, {nl, {json_Null}}}}, function => 'Create', metadata => #{ diff --git a/test/woody_tests_SUITE.erl b/test/woody_tests_SUITE.erl index 3c28e2e..a081c38 100644 --- a/test/woody_tests_SUITE.erl +++ b/test/woody_tests_SUITE.erl @@ -760,13 +760,12 @@ call_no_headers_503_test(_) -> call_no_headers_504_test(_) -> call_fail_w_no_headers(<<"call_no_headers_404">>, result_unknown, 504). -call_fail_w_no_headers(Id, Class, Code) -> +call_fail_w_no_headers(Id, Class, _Code) -> Gun = <<"Enforcer">>, Context = make_context(Id), {Url, Service} = get_service_endpoint('Weapons'), - BinCode = integer_to_binary(Code), ?assertError( - {woody_error, {external, Class, <<"got response with http code ", BinCode:3/binary, _/binary>>}}, + {woody_error, {external, Class, <<"This server does not implement the woody protocol", _/binary>>}}, woody_client:call( {Service, get_weapon, {Gun, self_to_bin()}}, #{url => Url, event_handler => ?MODULE}, From 5afa4813f13e7027fcc8b484fdc0e41e79ef4ad1 Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 18:40:29 +0300 Subject: [PATCH 12/40] revert thift compiler install step --- .github/workflows/erlang-library.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index 4ba7082..26b3713 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -16,7 +16,10 @@ jobs: matrix: otp_version: [24.2] os: [ubuntu-latest] - + + env: + THRIFT_COMPILER_VERSION: 0.14.2 + container: image: erlang:${{ matrix.otp_version }} @@ -43,10 +46,10 @@ jobs: restore-keys: | ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt- - - name: Setup thrift compiler - uses: valitydev/action-setup-thrift@v0.0.4 - with: - thrift-version: '0.14.2' + - name: Install thrift compiler (temporary) + run: | + wget -c https://github.com/valitydev/thrift/releases/download/${{ env.THRIFT_COMPILER_VERSION }}/thrift-${{ env.THRIFT_COMPILER_VERSION }}-linux-x86_64.tar.gz -O - | tar -xz -C /usr/local/bin/ + chmod +x /usr/local/bin/thrift - name: Compile run: make compile From 57f6b23c779aa5dae277e855a401c953c6ab9768 Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 19:13:57 +0300 Subject: [PATCH 13/40] try running multi-achitecture --- .github/workflows/erlang-library.yml | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index 26b3713..d3fd1ec 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -10,16 +10,24 @@ jobs: build: name: Build (${{ matrix.os }}, OTP-${{ matrix.otp_version }}) - runs-on: ${{ matrix.os }} + env: + OTP_VERSION: 24.2 + THRIFT_COMPILER_VERSION: 0.14.2 strategy: matrix: - otp_version: [24.2] - os: [ubuntu-latest] - - env: - THRIFT_COMPILER_VERSION: 0.14.2 + include: + - os: ubuntu-latest + otp_version: ${{ env.OTP_VERSION }} + thrift_version: ${{ env.THRIFT_COMPILER_VERSION }} + thrift_architecture: linux-x86_64 + - os: macos-latest + otp_version: ${{ env.OTP_VERSION }} + thrift_version: ${{ env.THRIFT_COMPILER_VERSION }} + thrift_architecture: darwin-arm64 + runs-on: ${{ matrix.os }} + container: image: erlang:${{ matrix.otp_version }} @@ -48,7 +56,7 @@ jobs: - name: Install thrift compiler (temporary) run: | - wget -c https://github.com/valitydev/thrift/releases/download/${{ env.THRIFT_COMPILER_VERSION }}/thrift-${{ env.THRIFT_COMPILER_VERSION }}-linux-x86_64.tar.gz -O - | tar -xz -C /usr/local/bin/ + wget -c https://github.com/valitydev/thrift/releases/download/${{ matrix.thrift_version }}/thrift-${{ matrix.thrift_version }}-${{ matrix.thrift_architecture }}.tar.gz -O - | tar -xz -C /usr/local/bin/ chmod +x /usr/local/bin/thrift - name: Compile @@ -71,16 +79,8 @@ jobs: run: make test - name: Store CT Logs - if: ${{ failure() && steps.run_tests.outcome == 'failure' && !env.ACT }} + if: ${{ failure() && steps.run_tests.outcome == 'failure' }} uses: actions/upload-artifact@v2 with: - name: ct-logs + name: ct-logs-${{ runner.os }} path: _build/test/logs - - - name: Run cover - run: make cover - - - name: Upload cover to codecov - uses: codecov/codecov-action@v2 - with: - files: _build/test/cover/ct.coverdata From e7dc68d4a0b0f7132039f436683a34bdf9fde3e8 Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 19:17:10 +0300 Subject: [PATCH 14/40] fix workflow matrix --- .github/workflows/erlang-library.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index d3fd1ec..5c46481 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -9,21 +9,17 @@ on: jobs: build: name: Build (${{ matrix.os }}, OTP-${{ matrix.otp_version }}) - - env: - OTP_VERSION: 24.2 - THRIFT_COMPILER_VERSION: 0.14.2 strategy: matrix: include: - os: ubuntu-latest - otp_version: ${{ env.OTP_VERSION }} - thrift_version: ${{ env.THRIFT_COMPILER_VERSION }} + otp_version: 24.2 + thrift_version: 0.14.2 thrift_architecture: linux-x86_64 - os: macos-latest - otp_version: ${{ env.OTP_VERSION }} - thrift_version: ${{ env.THRIFT_COMPILER_VERSION }} + otp_version: 24.2 + thrift_version: 0.14.2 thrift_architecture: darwin-arm64 runs-on: ${{ matrix.os }} From a2bafa3be48f1ecb775bd924a292c3d0da2b0312 Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 19:30:53 +0300 Subject: [PATCH 15/40] drop container from ci --- .github/workflows/erlang-library.yml | 35 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index 5c46481..2560887 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -8,30 +8,33 @@ on: jobs: build: - name: Build (${{ matrix.os }}, OTP-${{ matrix.otp_version }}) - strategy: matrix: include: - os: ubuntu-latest otp_version: 24.2 + rebar_version: 3.18 thrift_version: 0.14.2 - thrift_architecture: linux-x86_64 - - os: macos-latest - otp_version: 24.2 - thrift_version: 0.14.2 - thrift_architecture: darwin-arm64 - - runs-on: ${{ matrix.os }} - container: - image: erlang:${{ matrix.otp_version }} + name: Build (${{ matrix.os }}, OTP-${{ matrix.otp_version }}) + runs-on: ${{ matrix.os }} steps: - name: Checkout repository uses: actions/checkout@v2 + - name: Setup Thrift compiler + uses: valitydev/action-setup-thrift@v0.0.4 + with: + thrift-version: ${{ matrix.thrift_version }} + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ matrix.otp_version }} + rebar3-version: ${{ matrix.rebar_version }} + - name: Cache Hex packages uses: actions/cache@v1 with: @@ -50,11 +53,6 @@ jobs: restore-keys: | ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt- - - name: Install thrift compiler (temporary) - run: | - wget -c https://github.com/valitydev/thrift/releases/download/${{ matrix.thrift_version }}/thrift-${{ matrix.thrift_version }}-${{ matrix.thrift_architecture }}.tar.gz -O - | tar -xz -C /usr/local/bin/ - chmod +x /usr/local/bin/thrift - - name: Compile run: make compile @@ -78,5 +76,8 @@ jobs: if: ${{ failure() && steps.run_tests.outcome == 'failure' }} uses: actions/upload-artifact@v2 with: - name: ct-logs-${{ runner.os }} + name: ct-logs path: _build/test/logs + + - name: Run cover + run: make cover From 21c7d6f379308e72011fc0f631bf035562a70733 Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 19:51:13 +0300 Subject: [PATCH 16/40] fix cache --- .github/workflows/erlang-library.yml | 8 +++----- Makefile | 3 --- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index 2560887..d84c9a8 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -17,6 +17,7 @@ jobs: thrift_version: 0.14.2 name: Build (${{ matrix.os }}, OTP-${{ matrix.otp_version }}) + runs-on: ${{ matrix.os }} steps: @@ -36,7 +37,7 @@ jobs: rebar3-version: ${{ matrix.rebar_version }} - name: Cache Hex packages - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ~/.cache/rebar3/hex/hexpm/packages key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex-${{ hashFiles('**/rebar.lock') }} @@ -44,7 +45,7 @@ jobs: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- - name: Cache PLTs - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: | ~/.cache/rebar3/rebar3_*_plt @@ -78,6 +79,3 @@ jobs: with: name: ct-logs path: _build/test/logs - - - name: Run cover - run: make cover diff --git a/Makefile b/Makefile index 26b9097..58f705a 100644 --- a/Makefile +++ b/Makefile @@ -33,9 +33,6 @@ distclean: dialyze: $(REBAR) as test dialyzer -cover: - $(REBAR) cover - bench: $(REBAR) as test bench -m bench_woody_event_handler -n 1000 $(REBAR) as test bench -m bench_woody_formatter -n 10 From c0a686d3a7986a0f33e28427f4495d2cffb35a0e Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 19:58:05 +0300 Subject: [PATCH 17/40] break ct as a test --- test/woody_tests_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/woody_tests_SUITE.erl b/test/woody_tests_SUITE.erl index a081c38..db3f316 100644 --- a/test/woody_tests_SUITE.erl +++ b/test/woody_tests_SUITE.erl @@ -765,7 +765,7 @@ call_fail_w_no_headers(Id, Class, _Code) -> Context = make_context(Id), {Url, Service} = get_service_endpoint('Weapons'), ?assertError( - {woody_error, {external, Class, <<"This server does not implement the woody protocol", _/binary>>}}, + {woody_error, {external, Class, <<"🅱️This server does not implement the woody protocol", _/binary>>}}, woody_client:call( {Service, get_weapon, {Gun, self_to_bin()}}, #{url => Url, event_handler => ?MODULE}, From 46614c000fcf8ce0b0c40c8c52344e36ab2d2ce6 Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 20:01:59 +0300 Subject: [PATCH 18/40] break the break --- .github/workflows/erlang-library.yml | 20 ++++++++++---------- test/woody_tests_SUITE.erl | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index d84c9a8..39f9c23 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -44,16 +44,6 @@ jobs: restore-keys: | ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- - - name: Cache PLTs - uses: actions/cache@v2 - with: - path: | - ~/.cache/rebar3/rebar3_*_plt - _build/default/rebar3_*_plt - key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt-${{ hashFiles('**/rebar.lock') }} - restore-keys: | - ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt- - - name: Compile run: make compile @@ -66,6 +56,16 @@ jobs: - name: Run linting run: make lint + - name: Cache PLTs + uses: actions/cache@v2 + with: + path: | + ~/.cache/rebar3/rebar3_*_plt + _build/default/rebar3_*_plt + key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt- + - name: Run dialyzer run: make dialyze diff --git a/test/woody_tests_SUITE.erl b/test/woody_tests_SUITE.erl index db3f316..43cabca 100644 --- a/test/woody_tests_SUITE.erl +++ b/test/woody_tests_SUITE.erl @@ -765,7 +765,7 @@ call_fail_w_no_headers(Id, Class, _Code) -> Context = make_context(Id), {Url, Service} = get_service_endpoint('Weapons'), ?assertError( - {woody_error, {external, Class, <<"🅱️This server does not implement the woody protocol", _/binary>>}}, + {woody_error, {external, Class, <<"This serber does not implement the woody protocol", _/binary>>}}, woody_client:call( {Service, get_weapon, {Gun, self_to_bin()}}, #{url => Url, event_handler => ?MODULE}, From fcb6ac2fbc769b7548dc7005d1e36b95d4a269bb Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 20:03:45 +0300 Subject: [PATCH 19/40] fix wrong plt --- .github/workflows/erlang-library.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index 39f9c23..e5ee5e4 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -61,7 +61,7 @@ jobs: with: path: | ~/.cache/rebar3/rebar3_*_plt - _build/default/rebar3_*_plt + _build/test/rebar3_*_plt key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt-${{ hashFiles('**/rebar.lock') }} restore-keys: | ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt- From b9bb9a04aab936aa2dcd6663da3654775ca35f70 Mon Sep 17 00:00:00 2001 From: kehitt Date: Mon, 17 Jan 2022 20:10:04 +0300 Subject: [PATCH 20/40] unbreak tests --- test/woody_tests_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/woody_tests_SUITE.erl b/test/woody_tests_SUITE.erl index 43cabca..a081c38 100644 --- a/test/woody_tests_SUITE.erl +++ b/test/woody_tests_SUITE.erl @@ -765,7 +765,7 @@ call_fail_w_no_headers(Id, Class, _Code) -> Context = make_context(Id), {Url, Service} = get_service_endpoint('Weapons'), ?assertError( - {woody_error, {external, Class, <<"This serber does not implement the woody protocol", _/binary>>}}, + {woody_error, {external, Class, <<"This server does not implement the woody protocol", _/binary>>}}, woody_client:call( {Service, get_weapon, {Gun, self_to_bin()}}, #{url => Url, event_handler => ?MODULE}, From bb55a88ac7e70b88f44968f0dfda1121704aae62 Mon Sep 17 00:00:00 2001 From: kehitt Date: Tue, 18 Jan 2022 12:42:18 +0300 Subject: [PATCH 21/40] experimental multi-job CI --- .github/workflows/erlang-library.yml | 201 ++++++++++++++++++--------- 1 file changed, 138 insertions(+), 63 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index e5ee5e4..a80ef8e 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -6,76 +6,151 @@ on: pull_request: branches: [ '**' ] +env: + OTP_VERSION: 24.2 + REBAR_VERSION: 3.18 + THRIFT_VERSION: 0.14.2 + jobs: build: - strategy: - matrix: - include: - - os: ubuntu-latest - otp_version: 24.2 - rebar_version: 3.18 - thrift_version: 0.14.2 - - name: Build (${{ matrix.os }}, OTP-${{ matrix.otp_version }}) - - runs-on: ${{ matrix.os }} + name: Build (OTP-${{ env.OTP_VERSION }}) + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Thrift compiler + uses: valitydev/action-setup-thrift@v0.0.4 + with: + thrift-version: ${{ env.THRIFT_VERSION }} + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ env.OTP_VERSION }} + rebar3-version: ${{ env.REBAR_VERSION }} + + - name: Cache Hex packages + uses: actions/cache@v2 + with: + path: ~/.cache/rebar3/hex/hexpm/packages + key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- + + - name: Compile + run: make compile + analyze: + name: Analyze (OTP-${{ env.OTP_VERSION }}) + needs: build + runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Thrift compiler + uses: valitydev/action-setup-thrift@v0.0.4 + with: + thrift-version: ${{ env.THRIFT_VERSION }} + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ env.OTP_VERSION }} + rebar3-version: ${{ env.REBAR_VERSION }} + + - name: Cache Hex packages + uses: actions/cache@v2 + with: + path: ~/.cache/rebar3/hex/hexpm/packages + key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- + + - name: Check formatting + run: make check_format + + - name: Run xref + run: make xref + + - name: Run linting + run: make lint - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Setup Thrift compiler - uses: valitydev/action-setup-thrift@v0.0.4 - with: - thrift-version: ${{ matrix.thrift_version }} + - name: Cache PLTs + uses: actions/cache@v2 + with: + path: | + ~/.cache/rebar3/rebar3_*_plt + _build/test/rebar3_*_plt + key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt- - - name: Setup BEAM - uses: erlef/setup-beam@v1.10 - with: - otp-version: ${{ matrix.otp_version }} - rebar3-version: ${{ matrix.rebar_version }} + - name: Run dialyzer + run: make dialyze - - name: Cache Hex packages - uses: actions/cache@v2 - with: - path: ~/.cache/rebar3/hex/hexpm/packages - key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex-${{ hashFiles('**/rebar.lock') }} - restore-keys: | - ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- + test: + name: Test (OTP-${{ env.OTP_VERSION }}) + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Thrift compiler + uses: valitydev/action-setup-thrift@v0.0.4 + with: + thrift-version: ${{ env.THRIFT_VERSION }} + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ env.OTP_VERSION }} + rebar3-version: ${{ env.REBAR_VERSION }} + + - name: Cache Hex packages + uses: actions/cache@v2 + with: + path: ~/.cache/rebar3/hex/hexpm/packages + key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- - - name: Compile - run: make compile - - - name: Check formatting - run: make check_format - - - name: Run xref - run: make xref - - - name: Run linting - run: make lint - - - name: Cache PLTs - uses: actions/cache@v2 - with: - path: | - ~/.cache/rebar3/rebar3_*_plt - _build/test/rebar3_*_plt - key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt-${{ hashFiles('**/rebar.lock') }} - restore-keys: | - ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt- + - name: Run tests + id: run_tests + run: make test - - name: Run dialyzer - run: make dialyze - - - name: Run tests - id: run_tests - run: make test + - name: Store CT Logs + if: ${{ steps.run_tests.outcome == 'failure' }} + uses: actions/upload-artifact@v2 + with: + name: ct-logs + path: _build/test/logs - - name: Store CT Logs - if: ${{ failure() && steps.run_tests.outcome == 'failure' }} - uses: actions/upload-artifact@v2 - with: - name: ct-logs - path: _build/test/logs + cover: + name: Cover (OTP-${{ env.OTP_VERSION }}) + needs: [build, test, analyze] + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Thrift compiler + uses: valitydev/action-setup-thrift@v0.0.4 + with: + thrift-version: ${{ env.THRIFT_VERSION }} + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ env.OTP_VERSION }} + rebar3-version: ${{ env.REBAR_VERSION }} + + - name: Cache Hex packages + uses: actions/cache@v2 + with: + path: ~/.cache/rebar3/hex/hexpm/packages + key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- From 8a061f00a6a2479865a419a6682d4b27dd17c366 Mon Sep 17 00:00:00 2001 From: kehitt Date: Tue, 18 Jan 2022 12:47:04 +0300 Subject: [PATCH 22/40] fix --- .github/workflows/erlang-library.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index a80ef8e..b67d7f9 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -13,7 +13,7 @@ env: jobs: build: - name: Build (OTP-${{ env.OTP_VERSION }}) + name: Build runs-on: ubuntu-latest steps: - name: Checkout repository @@ -42,7 +42,7 @@ jobs: run: make compile analyze: - name: Analyze (OTP-${{ env.OTP_VERSION }}) + name: Analyze needs: build runs-on: ubuntu-latest steps: @@ -91,7 +91,7 @@ jobs: run: make dialyze test: - name: Test (OTP-${{ env.OTP_VERSION }}) + name: Test needs: build runs-on: ubuntu-latest steps: @@ -129,7 +129,7 @@ jobs: path: _build/test/logs cover: - name: Cover (OTP-${{ env.OTP_VERSION }}) + name: Cover needs: [build, test, analyze] runs-on: ubuntu-latest steps: From 177336f0db3cc3f2ca469b02a1e7e7397f13fcab Mon Sep 17 00:00:00 2001 From: kehitt Date: Tue, 18 Jan 2022 13:16:50 +0300 Subject: [PATCH 23/40] separate deps cache step --- .github/workflows/erlang-library.yml | 73 +++++++++++++++++++--------- 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index b67d7f9..c3f53e4 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -12,18 +12,13 @@ env: THRIFT_VERSION: 0.14.2 jobs: - build: - name: Build + deps: + name: Cache dependencies runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 - - name: Setup Thrift compiler - uses: valitydev/action-setup-thrift@v0.0.4 - with: - thrift-version: ${{ env.THRIFT_VERSION }} - - name: Setup BEAM uses: erlef/setup-beam@v1.10 with: @@ -31,20 +26,22 @@ jobs: rebar3-version: ${{ env.REBAR_VERSION }} - name: Cache Hex packages + id: hex_cache uses: actions/cache@v2 with: path: ~/.cache/rebar3/hex/hexpm/packages - key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex-${{ hashFiles('**/rebar.config') }} restore-keys: | - ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex- - - name: Compile - run: make compile + - name: Get dependencies + if: steps.hex_cache.outputs.cache-hit != 'true' + run: rebar3 deps - analyze: - name: Analyze - needs: build + build: + name: Build / Check runs-on: ubuntu-latest + needs: deps steps: - name: Checkout repository uses: actions/checkout@v2 @@ -64,10 +61,13 @@ jobs: uses: actions/cache@v2 with: path: ~/.cache/rebar3/hex/hexpm/packages - key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex-${{ hashFiles('**/rebar.config') }} restore-keys: | - ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex- + - name: Compile + run: make compile + - name: Check formatting run: make check_format @@ -77,22 +77,49 @@ jobs: - name: Run linting run: make lint + analyze: + name: Dialyze + needs: deps + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Thrift compiler + uses: valitydev/action-setup-thrift@v0.0.4 + with: + thrift-version: ${{ env.THRIFT_VERSION }} + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ env.OTP_VERSION }} + rebar3-version: ${{ env.REBAR_VERSION }} + + - name: Cache Hex packages + uses: actions/cache@v2 + with: + path: ~/.cache/rebar3/hex/hexpm/packages + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex-${{ hashFiles('**/rebar.config') }} + restore-keys: | + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex- + - name: Cache PLTs uses: actions/cache@v2 with: path: | ~/.cache/rebar3/rebar3_*_plt _build/test/rebar3_*_plt - key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt-${{ hashFiles('**/rebar.lock') }} restore-keys: | - ${{ runner.os }}-otp-${{ matrix.otp_version }}-plt- + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt- - name: Run dialyzer run: make dialyze test: name: Test - needs: build + needs: deps runs-on: ubuntu-latest steps: - name: Checkout repository @@ -113,9 +140,9 @@ jobs: uses: actions/cache@v2 with: path: ~/.cache/rebar3/hex/hexpm/packages - key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex-${{ hashFiles('**/rebar.config') }} restore-keys: | - ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex- - name: Run tests id: run_tests @@ -151,6 +178,6 @@ jobs: uses: actions/cache@v2 with: path: ~/.cache/rebar3/hex/hexpm/packages - key: ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex-${{ hashFiles('**/rebar.config') }} restore-keys: | - ${{ runner.os }}-otp-${{ matrix.otp_version }}-hex- + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex- From 29da4daabbd59a3f4ee69e9082f704a44d64be4a Mon Sep 17 00:00:00 2001 From: kehitt Date: Tue, 18 Jan 2022 13:20:46 +0300 Subject: [PATCH 24/40] fix skip step --- .github/workflows/erlang-library.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index c3f53e4..b09308c 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -35,7 +35,7 @@ jobs: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex- - name: Get dependencies - if: steps.hex_cache.outputs.cache-hit != 'true' + if: ${{ steps.hex_cache.outputs.cache-hit != 'true' }} run: rebar3 deps build: From b611a86452179e43cdc1c4724a3559d132e2124b Mon Sep 17 00:00:00 2001 From: kehitt Date: Tue, 18 Jan 2022 13:33:16 +0300 Subject: [PATCH 25/40] add try adding coverage --- .github/workflows/erlang-library.yml | 37 +++++++--------------------- Makefile | 4 +++ rebar.config | 10 +++++++- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index b09308c..2fc20a6 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -71,12 +71,12 @@ jobs: - name: Check formatting run: make check_format - - name: Run xref - run: make xref - - name: Run linting run: make lint + - name: Run xref + run: make xref + analyze: name: Dialyze needs: deps @@ -155,29 +155,10 @@ jobs: name: ct-logs path: _build/test/logs - cover: - name: Cover - needs: [build, test, analyze] - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Setup Thrift compiler - uses: valitydev/action-setup-thrift@v0.0.4 - with: - thrift-version: ${{ env.THRIFT_VERSION }} - - - name: Setup BEAM - uses: erlef/setup-beam@v1.10 - with: - otp-version: ${{ env.OTP_VERSION }} - rebar3-version: ${{ env.REBAR_VERSION }} - - - name: Cache Hex packages - uses: actions/cache@v2 + - name: Run cover analysis + run: make cover + + - name: Upload cover stats + uses: codecov/codecov-action@v2 with: - path: ~/.cache/rebar3/hex/hexpm/packages - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex-${{ hashFiles('**/rebar.config') }} - restore-keys: | - ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex- + files: _build/test/covertool/woody.covertool.xml diff --git a/Makefile b/Makefile index 58f705a..3f550d3 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,10 @@ distclean: dialyze: $(REBAR) as test dialyzer +cover: + $(REBAR) cover + $(REBAR) covertool generate + bench: $(REBAR) as test bench -m bench_woody_event_handler -n 1000 $(REBAR) as test bench -m bench_woody_formatter -n 10 diff --git a/rebar.config b/rebar.config index eab5c46..38843e7 100644 --- a/rebar.config +++ b/rebar.config @@ -90,7 +90,8 @@ {git, "https://github.com/valitydev/rebar3_thrift_compiler.git", {ref, "cd78af5f30ebaa88f84c144d63f9548d3e3b5d3f"}}}, {erlfmt, "1.0.0"}, - {rebar3_lint, "1.0.1"} + {rebar3_lint, "1.0.1"}, + {covertool, "2.0.4"} ]}. {erlfmt, [ @@ -102,3 +103,10 @@ "elvis.config" ]} ]}. + +{covertool, [ + {coverdata_files, [ + "eunit.coverdata", + "ct.coverdata" + ]} +]}. From d4d034f53039174478e6403cc66088708bfd756f Mon Sep 17 00:00:00 2001 From: kehitt Date: Tue, 18 Jan 2022 14:09:24 +0300 Subject: [PATCH 26/40] more universal cover filename --- .github/workflows/erlang-library.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index 2fc20a6..fa4f95e 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -161,4 +161,4 @@ jobs: - name: Upload cover stats uses: codecov/codecov-action@v2 with: - files: _build/test/covertool/woody.covertool.xml + files: _build/test/covertool/*.covertool.xml From a6991b3ef7a04b226d6c75decdf83ddf156baa6b Mon Sep 17 00:00:00 2001 From: kehitt Date: Tue, 18 Jan 2022 14:59:12 +0300 Subject: [PATCH 27/40] configure codecov limits --- .github/workflows/codecov.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000..1e7b7db --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,11 @@ +coverage: + status: + project: + default: + # Allow total coverage to drop by at most 2% + target: auto + threshold: 2% + patch: + default: + # Force any given PR to be at least 70% covered + target: 70% From 39a1e35f14c15756283c79f0cf0d839739fb01f9 Mon Sep 17 00:00:00 2001 From: kehitt Date: Tue, 18 Jan 2022 15:01:19 +0300 Subject: [PATCH 28/40] move config to the correct folder --- .github/{workflows => }/codecov.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflows => }/codecov.yml (100%) diff --git a/.github/workflows/codecov.yml b/.github/codecov.yml similarity index 100% rename from .github/workflows/codecov.yml rename to .github/codecov.yml From 60e9bd26846dfee67382410c09ea6299eac85bcc Mon Sep 17 00:00:00 2001 From: kehitt Date: Wed, 19 Jan 2022 13:11:22 +0300 Subject: [PATCH 29/40] experimental cache _build --- .github/workflows/erlang-library.yml | 62 +++++++++------------------- 1 file changed, 20 insertions(+), 42 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index fa4f95e..e20cd3f 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -12,8 +12,8 @@ env: THRIFT_VERSION: 0.14.2 jobs: - deps: - name: Cache dependencies + build: + name: Build runs-on: ubuntu-latest steps: - name: Checkout repository @@ -25,23 +25,22 @@ jobs: otp-version: ${{ env.OTP_VERSION }} rebar3-version: ${{ env.REBAR_VERSION }} - - name: Cache Hex packages - id: hex_cache + - &cache_build + name: Cache _build uses: actions/cache@v2 with: - path: ~/.cache/rebar3/hex/hexpm/packages - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex-${{ hashFiles('**/rebar.config') }} + path: _build/default/lib + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} restore-keys: | - ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex- - - - name: Get dependencies - if: ${{ steps.hex_cache.outputs.cache-hit != 'true' }} - run: rebar3 deps + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- - build: - name: Build / Check + - name: Compile + run: make compile + + check: + name: Check runs-on: ubuntu-latest - needs: deps + needs: build steps: - name: Checkout repository uses: actions/checkout@v2 @@ -57,17 +56,8 @@ jobs: otp-version: ${{ env.OTP_VERSION }} rebar3-version: ${{ env.REBAR_VERSION }} - - name: Cache Hex packages - uses: actions/cache@v2 - with: - path: ~/.cache/rebar3/hex/hexpm/packages - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex-${{ hashFiles('**/rebar.config') }} - restore-keys: | - ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex- + - *cache_build - - name: Compile - run: make compile - - name: Check formatting run: make check_format @@ -79,7 +69,7 @@ jobs: analyze: name: Dialyze - needs: deps + needs: build runs-on: ubuntu-latest steps: - name: Checkout repository @@ -95,14 +85,8 @@ jobs: with: otp-version: ${{ env.OTP_VERSION }} rebar3-version: ${{ env.REBAR_VERSION }} - - - name: Cache Hex packages - uses: actions/cache@v2 - with: - path: ~/.cache/rebar3/hex/hexpm/packages - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex-${{ hashFiles('**/rebar.config') }} - restore-keys: | - ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex- + + - *cache_build - name: Cache PLTs uses: actions/cache@v2 @@ -119,7 +103,7 @@ jobs: test: name: Test - needs: deps + needs: build runs-on: ubuntu-latest steps: - name: Checkout repository @@ -135,14 +119,8 @@ jobs: with: otp-version: ${{ env.OTP_VERSION }} rebar3-version: ${{ env.REBAR_VERSION }} - - - name: Cache Hex packages - uses: actions/cache@v2 - with: - path: ~/.cache/rebar3/hex/hexpm/packages - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex-${{ hashFiles('**/rebar.config') }} - restore-keys: | - ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-hex- + + - *cache_build - name: Run tests id: run_tests From 8d9f5005d9be67a0ed1d1175131a1d4c8b3e0e78 Mon Sep 17 00:00:00 2001 From: kehitt Date: Wed, 19 Jan 2022 13:13:32 +0300 Subject: [PATCH 30/40] anchors away --- .github/workflows/erlang-library.yml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index e20cd3f..f75aed0 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -25,8 +25,7 @@ jobs: otp-version: ${{ env.OTP_VERSION }} rebar3-version: ${{ env.REBAR_VERSION }} - - &cache_build - name: Cache _build + - name: Cache _build uses: actions/cache@v2 with: path: _build/default/lib @@ -56,7 +55,13 @@ jobs: otp-version: ${{ env.OTP_VERSION }} rebar3-version: ${{ env.REBAR_VERSION }} - - *cache_build + - name: Cache _build + uses: actions/cache@v2 + with: + path: _build/default/lib + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- - name: Check formatting run: make check_format @@ -86,7 +91,13 @@ jobs: otp-version: ${{ env.OTP_VERSION }} rebar3-version: ${{ env.REBAR_VERSION }} - - *cache_build + - name: Cache _build + uses: actions/cache@v2 + with: + path: _build/default/lib + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- - name: Cache PLTs uses: actions/cache@v2 @@ -120,7 +131,13 @@ jobs: otp-version: ${{ env.OTP_VERSION }} rebar3-version: ${{ env.REBAR_VERSION }} - - *cache_build + - name: Cache _build + uses: actions/cache@v2 + with: + path: _build/default/lib + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- - name: Run tests id: run_tests From 5d256183db02dc14c428ca00e16cf756fabdfe18 Mon Sep 17 00:00:00 2001 From: kehitt Date: Wed, 19 Jan 2022 13:20:57 +0300 Subject: [PATCH 31/40] fix thrift compiler plugin to tag, lock build cache completely --- .github/workflows/erlang-library.yml | 8 -------- rebar.config | 4 +--- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/erlang-library.yml b/.github/workflows/erlang-library.yml index f75aed0..89cff94 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/workflows/erlang-library.yml @@ -30,8 +30,6 @@ jobs: with: path: _build/default/lib key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} - restore-keys: | - ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- - name: Compile run: make compile @@ -60,8 +58,6 @@ jobs: with: path: _build/default/lib key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} - restore-keys: | - ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- - name: Check formatting run: make check_format @@ -96,8 +92,6 @@ jobs: with: path: _build/default/lib key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} - restore-keys: | - ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- - name: Cache PLTs uses: actions/cache@v2 @@ -136,8 +130,6 @@ jobs: with: path: _build/default/lib key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} - restore-keys: | - ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- - name: Run tests id: run_tests diff --git a/rebar.config b/rebar.config index 38843e7..c8829ea 100644 --- a/rebar.config +++ b/rebar.config @@ -86,9 +86,7 @@ ]}. {plugins, [ - {rebar3_thrift_compiler, - {git, "https://github.com/valitydev/rebar3_thrift_compiler.git", - {ref, "cd78af5f30ebaa88f84c144d63f9548d3e3b5d3f"}}}, + {rebar3_thrift_compiler, {git, "https://github.com/valitydev/rebar3_thrift_compiler.git", {tag, "0.3.1"}}}, {erlfmt, "1.0.0"}, {rebar3_lint, "1.0.1"}, {covertool, "2.0.4"} From d8a1d875ed7182334e6bd5e0e4fa777ca35c6907 Mon Sep 17 00:00:00 2001 From: kehitt Date: Wed, 19 Jan 2022 13:54:03 +0300 Subject: [PATCH 32/40] experimental reusable workflow --- .../workflows/erlang-ci.yml} | 47 ++++++++++--------- .github/workflows/ci.yml | 11 +++++ 2 files changed, 36 insertions(+), 22 deletions(-) rename .github/{workflows/erlang-library.yml => reusable/workflows/erlang-ci.yml} (82%) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/erlang-library.yml b/.github/reusable/workflows/erlang-ci.yml similarity index 82% rename from .github/workflows/erlang-library.yml rename to .github/reusable/workflows/erlang-ci.yml index 89cff94..2f4eb9d 100644 --- a/.github/workflows/erlang-library.yml +++ b/.github/reusable/workflows/erlang-ci.yml @@ -1,10 +1,10 @@ -name: Erlang library CI +name: Erlang CI on: - push: - branches: [ master ] - pull_request: - branches: [ '**' ] + workflow_call: + inputs: [] + secrets: [] + outputs: [] env: OTP_VERSION: 24.2 @@ -28,11 +28,11 @@ jobs: - name: Cache _build uses: actions/cache@v2 with: - path: _build/default/lib + path: _build/*/lib key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} - name: Compile - run: make compile + run: rebar3 compile check: name: Check @@ -56,19 +56,19 @@ jobs: - name: Cache _build uses: actions/cache@v2 with: - path: _build/default/lib + path: _build/*/lib key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} - name: Check formatting - run: make check_format + run: rebar3 fmt -c - name: Run linting - run: make lint + run: rebar3 lint - name: Run xref - run: make xref + run: rebar3 xref - analyze: + dialyze: name: Dialyze needs: build runs-on: ubuntu-latest @@ -90,7 +90,7 @@ jobs: - name: Cache _build uses: actions/cache@v2 with: - path: _build/default/lib + path: _build/*/lib key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} - name: Cache PLTs @@ -104,7 +104,7 @@ jobs: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt- - name: Run dialyzer - run: make dialyze + run: rebar3 as test dialyzer test: name: Test @@ -128,24 +128,27 @@ jobs: - name: Cache _build uses: actions/cache@v2 with: - path: _build/default/lib + path: _build/*/lib key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} - - name: Run tests - id: run_tests - run: make test + - name: Run EUnit + run: rebar3 eunit --cover + + - name: Run CT + id: run-common-test + run: rebar3 ct --cover - name: Store CT Logs - if: ${{ steps.run_tests.outcome == 'failure' }} + if: ${{ steps.run-common-test.outcome == 'failure' }} uses: actions/upload-artifact@v2 with: name: ct-logs path: _build/test/logs - - name: Run cover analysis - run: make cover + - name: Run test coverage analysis + run: rebar3 do cover, covertool generate - - name: Upload cover stats + - name: Upload coverage statistics uses: codecov/codecov-action@v2 with: files: _build/test/covertool/*.covertool.xml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6693fa0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,11 @@ +name: Erlang Library CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ '**' ] + +jobs: + run_checks: + uses: ../reusable/workflows/erlang-ci.yml From 608c97bb8398789e27fcd87d85d8f80f203856eb Mon Sep 17 00:00:00 2001 From: kehitt Date: Wed, 19 Jan 2022 13:57:55 +0300 Subject: [PATCH 33/40] nah --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6693fa0..741e384 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,4 +8,4 @@ on: jobs: run_checks: - uses: ../reusable/workflows/erlang-ci.yml + uses: ../reusable/workflows/erlang-ci.yml@${{ github.sha }} From 6c0c9e7e2ddb27a0f34aa770a6a25ce9043ed2a7 Mon Sep 17 00:00:00 2001 From: kehitt Date: Wed, 19 Jan 2022 13:59:04 +0300 Subject: [PATCH 34/40] revert to nonreusable --- .github/reusable/workflows/erlang-ci.yml | 154 ----------------------- .github/workflows/ci.yml | 147 +++++++++++++++++++++- 2 files changed, 145 insertions(+), 156 deletions(-) delete mode 100644 .github/reusable/workflows/erlang-ci.yml diff --git a/.github/reusable/workflows/erlang-ci.yml b/.github/reusable/workflows/erlang-ci.yml deleted file mode 100644 index 2f4eb9d..0000000 --- a/.github/reusable/workflows/erlang-ci.yml +++ /dev/null @@ -1,154 +0,0 @@ -name: Erlang CI - -on: - workflow_call: - inputs: [] - secrets: [] - outputs: [] - -env: - OTP_VERSION: 24.2 - REBAR_VERSION: 3.18 - THRIFT_VERSION: 0.14.2 - -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Setup BEAM - uses: erlef/setup-beam@v1.10 - with: - otp-version: ${{ env.OTP_VERSION }} - rebar3-version: ${{ env.REBAR_VERSION }} - - - name: Cache _build - uses: actions/cache@v2 - with: - path: _build/*/lib - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} - - - name: Compile - run: rebar3 compile - - check: - name: Check - runs-on: ubuntu-latest - needs: build - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Setup Thrift compiler - uses: valitydev/action-setup-thrift@v0.0.4 - with: - thrift-version: ${{ env.THRIFT_VERSION }} - - - name: Setup BEAM - uses: erlef/setup-beam@v1.10 - with: - otp-version: ${{ env.OTP_VERSION }} - rebar3-version: ${{ env.REBAR_VERSION }} - - - name: Cache _build - uses: actions/cache@v2 - with: - path: _build/*/lib - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} - - - name: Check formatting - run: rebar3 fmt -c - - - name: Run linting - run: rebar3 lint - - - name: Run xref - run: rebar3 xref - - dialyze: - name: Dialyze - needs: build - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Setup Thrift compiler - uses: valitydev/action-setup-thrift@v0.0.4 - with: - thrift-version: ${{ env.THRIFT_VERSION }} - - - name: Setup BEAM - uses: erlef/setup-beam@v1.10 - with: - otp-version: ${{ env.OTP_VERSION }} - rebar3-version: ${{ env.REBAR_VERSION }} - - - name: Cache _build - uses: actions/cache@v2 - with: - path: _build/*/lib - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} - - - name: Cache PLTs - uses: actions/cache@v2 - with: - path: | - ~/.cache/rebar3/rebar3_*_plt - _build/test/rebar3_*_plt - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt-${{ hashFiles('**/rebar.lock') }} - restore-keys: | - ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt- - - - name: Run dialyzer - run: rebar3 as test dialyzer - - test: - name: Test - needs: build - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Setup Thrift compiler - uses: valitydev/action-setup-thrift@v0.0.4 - with: - thrift-version: ${{ env.THRIFT_VERSION }} - - - name: Setup BEAM - uses: erlef/setup-beam@v1.10 - with: - otp-version: ${{ env.OTP_VERSION }} - rebar3-version: ${{ env.REBAR_VERSION }} - - - name: Cache _build - uses: actions/cache@v2 - with: - path: _build/*/lib - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} - - - name: Run EUnit - run: rebar3 eunit --cover - - - name: Run CT - id: run-common-test - run: rebar3 ct --cover - - - name: Store CT Logs - if: ${{ steps.run-common-test.outcome == 'failure' }} - uses: actions/upload-artifact@v2 - with: - name: ct-logs - path: _build/test/logs - - - name: Run test coverage analysis - run: rebar3 do cover, covertool generate - - - name: Upload coverage statistics - uses: codecov/codecov-action@v2 - with: - files: _build/test/covertool/*.covertool.xml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 741e384..8412f0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,149 @@ on: pull_request: branches: [ '**' ] +env: + OTP_VERSION: 24.2 + REBAR_VERSION: 3.18 + THRIFT_VERSION: 0.14.2 + jobs: - run_checks: - uses: ../reusable/workflows/erlang-ci.yml@${{ github.sha }} + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ env.OTP_VERSION }} + rebar3-version: ${{ env.REBAR_VERSION }} + + - name: Cache _build + uses: actions/cache@v2 + with: + path: _build/*/lib + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + + - name: Compile + run: rebar3 compile + + check: + name: Check + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Thrift compiler + uses: valitydev/action-setup-thrift@v0.0.4 + with: + thrift-version: ${{ env.THRIFT_VERSION }} + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ env.OTP_VERSION }} + rebar3-version: ${{ env.REBAR_VERSION }} + + - name: Cache _build + uses: actions/cache@v2 + with: + path: _build/*/lib + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + + - name: Check formatting + run: rebar3 fmt -c + + - name: Run linting + run: rebar3 lint + + - name: Run xref + run: rebar3 xref + + dialyze: + name: Dialyze + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Thrift compiler + uses: valitydev/action-setup-thrift@v0.0.4 + with: + thrift-version: ${{ env.THRIFT_VERSION }} + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ env.OTP_VERSION }} + rebar3-version: ${{ env.REBAR_VERSION }} + + - name: Cache _build + uses: actions/cache@v2 + with: + path: _build/*/lib + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + + - name: Cache PLTs + uses: actions/cache@v2 + with: + path: | + ~/.cache/rebar3/rebar3_*_plt + _build/test/rebar3_*_plt + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt- + + - name: Run dialyzer + run: rebar3 as test dialyzer + + test: + name: Test + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Thrift compiler + uses: valitydev/action-setup-thrift@v0.0.4 + with: + thrift-version: ${{ env.THRIFT_VERSION }} + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ env.OTP_VERSION }} + rebar3-version: ${{ env.REBAR_VERSION }} + + - name: Cache _build + uses: actions/cache@v2 + with: + path: _build/*/lib + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + + - name: Run EUnit + run: rebar3 eunit --cover + + - name: Run CT + id: run-common-test + run: rebar3 ct --cover + + - name: Store CT Logs + if: ${{ steps.run-common-test.outcome == 'failure' }} + uses: actions/upload-artifact@v2 + with: + name: ct-logs + path: _build/test/logs + + - name: Run test coverage analysis + run: rebar3 do cover, covertool generate + + - name: Upload coverage statistics + uses: codecov/codecov-action@v2 + with: + files: _build/test/covertool/*.covertool.xml From ba7ef08c5891aa519c3205ced9e51a6912e79fac Mon Sep 17 00:00:00 2001 From: kehitt Date: Wed, 19 Jan 2022 14:03:28 +0300 Subject: [PATCH 35/40] fix ct log upload --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8412f0f..22a4d71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -139,7 +139,7 @@ jobs: run: rebar3 ct --cover - name: Store CT Logs - if: ${{ steps.run-common-test.outcome == 'failure' }} + if: ${{ failure() && steps.run-common-test.outcome == 'failure' }} uses: actions/upload-artifact@v2 with: name: ct-logs From 8a7e70bd068a9a6f78396675ff7ca529a441291a Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 20 Jan 2022 18:27:24 +0300 Subject: [PATCH 36/40] review fixes --- .github/workflows/ci.yml | 27 +++++++++++++++------------ elvis.config | 1 - 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22a4d71..27b177c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: env: OTP_VERSION: 24.2 REBAR_VERSION: 3.18 - THRIFT_VERSION: 0.14.2 + THRIFT_VERSION: 0.14.2.1 jobs: build: @@ -29,7 +29,9 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-build-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-build- - name: Compile run: rebar3 compile @@ -42,11 +44,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Setup Thrift compiler - uses: valitydev/action-setup-thrift@v0.0.4 - with: - thrift-version: ${{ env.THRIFT_VERSION }} - - name: Setup BEAM uses: erlef/setup-beam@v1.10 with: @@ -57,7 +54,9 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-build-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-build- - name: Check formatting run: rebar3 fmt -c @@ -77,7 +76,7 @@ jobs: uses: actions/checkout@v2 - name: Setup Thrift compiler - uses: valitydev/action-setup-thrift@v0.0.4 + uses: valitydev/action-setup-thrift@v0.0.5 with: thrift-version: ${{ env.THRIFT_VERSION }} @@ -91,7 +90,9 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-build-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-build- - name: Cache PLTs uses: actions/cache@v2 @@ -115,7 +116,7 @@ jobs: uses: actions/checkout@v2 - name: Setup Thrift compiler - uses: valitydev/action-setup-thrift@v0.0.4 + uses: valitydev/action-setup-thrift@v0.0.5 with: thrift-version: ${{ env.THRIFT_VERSION }} @@ -129,7 +130,9 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-build-${{ hashFiles('**/rebar.lock') }} + restore-keys: | + ${{ runner.os }}-build- - name: Run EUnit run: rebar3 eunit --cover diff --git a/elvis.config b/elvis.config index b9be246..ad33777 100644 --- a/elvis.config +++ b/elvis.config @@ -8,7 +8,6 @@ rules => [ % common conventions {elvis_text_style, line_length, #{limit => 120}}, - {elvis_text_style, no_trailing_whitespace, #{ignore_empty_lines => true}}, {elvis_style, nesting_level, #{level => 3}}, {elvis_style, no_if_expression, disable}, {elvis_style, state_record_and_type, disable}, From 50a70007294dbd9c14378645c3d45a2d20eecc6b Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 20 Jan 2022 18:29:50 +0300 Subject: [PATCH 37/40] don't cache the base plt --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27b177c..062ac1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,9 +97,7 @@ jobs: - name: Cache PLTs uses: actions/cache@v2 with: - path: | - ~/.cache/rebar3/rebar3_*_plt - _build/test/rebar3_*_plt + path: _build/test/rebar3_*_plt key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt-${{ hashFiles('**/rebar.lock') }} restore-keys: | ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt- From 295dc0ef92400269d32a9d271ad409e7bdab86e2 Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 20 Jan 2022 18:52:04 +0300 Subject: [PATCH 38/40] dont need to rerun rebar3 cover if tests are run with --cover --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 062ac1e..88cbf10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -146,10 +146,10 @@ jobs: name: ct-logs path: _build/test/logs - - name: Run test coverage analysis - run: rebar3 do cover, covertool generate + - name: Generate coverage reports + run: rebar3 covertool generate - - name: Upload coverage statistics + - name: Upload coverage reports uses: codecov/codecov-action@v2 with: files: _build/test/covertool/*.covertool.xml From 77dee606bf1c674fc881abc80dc2de9f3331bfe6 Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 20 Jan 2022 20:12:36 +0300 Subject: [PATCH 39/40] bring back the otp version --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88cbf10..522d95e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,9 +29,9 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-build-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} restore-keys: | - ${{ runner.os }}-build- + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- - name: Compile run: rebar3 compile @@ -54,9 +54,9 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-build-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} restore-keys: | - ${{ runner.os }}-build- + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- - name: Check formatting run: rebar3 fmt -c @@ -90,9 +90,9 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-build-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} restore-keys: | - ${{ runner.os }}-build- + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- - name: Cache PLTs uses: actions/cache@v2 @@ -128,9 +128,9 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-build-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} restore-keys: | - ${{ runner.os }}-build- + ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- - name: Run EUnit run: rebar3 eunit --cover From e10dfdd87450ed92a49ff27370c9e1abbcfe2943 Mon Sep 17 00:00:00 2001 From: kehitt Date: Fri, 21 Jan 2022 12:45:59 +0300 Subject: [PATCH 40/40] remove rebar.lock wildcard --- .github/workflows/ci.yml | 10 +++++----- rebar.lock | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 522d95e..de3dd09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- @@ -54,7 +54,7 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- @@ -90,7 +90,7 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- @@ -98,7 +98,7 @@ jobs: uses: actions/cache@v2 with: path: _build/test/rebar3_*_plt - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt-${{ hashFiles('rebar.lock') }} restore-keys: | ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-plt- @@ -128,7 +128,7 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('**/rebar.lock') }} + key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | ${{ runner.os }}-otp-${{ env.OTP_VERSION }}-build- diff --git a/rebar.lock b/rebar.lock index a2dc820..255b17c 100644 --- a/rebar.lock +++ b/rebar.lock @@ -5,7 +5,7 @@ {<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},1}, {<<"genlib">>, {git,"https://github.com/valitydev/genlib.git", - {ref,"4565a8d73f34a0b78cca32c9cd2b97d298bdadf8"}}, + {ref,"82c5ff3866e3019eb347c7f1d8f1f847bed28c10"}}, 0}, {<<"gproc">>,{pkg,<<"gproc">>,<<"0.9.0">>},0}, {<<"hackney">>,{pkg,<<"hackney">>,<<"1.18.0">>},0},