From 9e3f8eb930ff78a8972bf4d7b0897cfd9dc29f06 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Mon, 18 Jul 2022 19:20:03 +0300 Subject: [PATCH] TD-222: Reuse valitydev/action-deploy-docker@v2 (#16) * Drop merchstat leftovers * Cut out some unused includes --- .github/workflows/build-image.yml | 42 ++--------- .gitignore | 28 +++----- .../src/capi_handler_decoder_invoicing.erl | 6 -- apps/capi/src/capi_handler_decoder_party.erl | 3 - apps/capi/src/capi_handler_encoder.erl | 2 - .../test/capi_base_api_token_tests_SUITE.erl | 1 - apps/capi/test/capi_dummy_data.hrl | 70 ++----------------- apps/capi/test/capi_self_tests_SUITE.erl | 1 - 8 files changed, 20 insertions(+), 133 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 6f39e7c..ff53b0e 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -1,4 +1,4 @@ -name: Build Docker image +name: Build and publish Docker image on: push: @@ -12,42 +12,10 @@ env: REGISTRY: ghcr.io jobs: - build: + build-push: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Setup Buildx - uses: docker/setup-buildx-action@v1 - - # https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable - - name: Update environment variables - run: grep -v '^#' .env >> $GITHUB_ENV - - - name: Log in to the Container registry - uses: docker/login-action@v1.12.0 + - uses: valitydev/action-deploy-docker@v2 with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Construct tags / labels for an image - id: meta - uses: docker/metadata-action@v3.6.2 - with: - images: | - ${{ env.REGISTRY }}/${{ github.repository }} - tags: | - type=sha - - - name: Build and push Docker image - uses: docker/build-push-action@v2.9.0 - with: - push: ${{ github.event_name == 'push' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - SERVICE_NAME=${{ env.SERVICE_NAME }} - OTP_VERSION=${{ env.OTP_VERSION }} - THRIFT_VERSION=${{ env.THRIFT_VERSION }} + registry-username: ${{ github.actor }} + registry-access-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index a8d7fec..8b14b84 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,13 @@ -# general -log +# Build artifacts /_build/ -*~ -erl_crash.dump -.tags* -*.sublime-* - -.DS_Store - -# rebar -/_checkouts/ - -# generated +*.o *.beam -.image.dev +*.plt -# containerization -\#* -.\#* -tags +# Run artifacts +erl_crash.dump +log + +# make stuff +/.image.* +Makefile.env diff --git a/apps/capi/src/capi_handler_decoder_invoicing.erl b/apps/capi/src/capi_handler_decoder_invoicing.erl index 8e6ef22..23d8e84 100644 --- a/apps/capi/src/capi_handler_decoder_invoicing.erl +++ b/apps/capi/src/capi_handler_decoder_invoicing.erl @@ -3,7 +3,6 @@ -include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). -include_lib("damsel/include/dmsl_base_thrift.hrl"). --include_lib("damsel/include/dmsl_merchstat_thrift.hrl"). -include_lib("damsel/include/dmsl_user_interaction_thrift.hrl"). -export([decode_user_interaction_form/1]). @@ -286,11 +285,6 @@ decode_make_recurrent(Value) when is_boolean(Value) -> -spec decode_recurrent_parent(capi_handler_encoder:encode_data()) -> decode_data(). decode_recurrent_parent(#domain_RecurrentParentPayment{invoice_id = InvoiceID, payment_id = PaymentID}) -> - #{ - <<"invoiceID">> => InvoiceID, - <<"paymentID">> => PaymentID - }; -decode_recurrent_parent(#merchstat_RecurrentParentPayment{invoice_id = InvoiceID, payment_id = PaymentID}) -> #{ <<"invoiceID">> => InvoiceID, <<"paymentID">> => PaymentID diff --git a/apps/capi/src/capi_handler_decoder_party.erl b/apps/capi/src/capi_handler_decoder_party.erl index 19dbfea..2f0891c 100644 --- a/apps/capi/src/capi_handler_decoder_party.erl +++ b/apps/capi/src/capi_handler_decoder_party.erl @@ -1,9 +1,6 @@ -module(capi_handler_decoder_party). --include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). --include_lib("damsel/include/dmsl_base_thrift.hrl"). --include_lib("damsel/include/dmsl_merchstat_thrift.hrl"). -export([decode_shop_location/1]). -export([decode_shop_details/1]). diff --git a/apps/capi/src/capi_handler_encoder.erl b/apps/capi/src/capi_handler_encoder.erl index ce60f3c..2398045 100644 --- a/apps/capi/src/capi_handler_encoder.erl +++ b/apps/capi/src/capi_handler_encoder.erl @@ -1,7 +1,5 @@ -module(capi_handler_encoder). --include_lib("damsel/include/dmsl_payproc_thrift.hrl"). --include_lib("damsel/include/dmsl_merchstat_thrift.hrl"). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). -include_lib("damsel/include/dmsl_base_thrift.hrl"). diff --git a/apps/capi/test/capi_base_api_token_tests_SUITE.erl b/apps/capi/test/capi_base_api_token_tests_SUITE.erl index 749a707..061823d 100644 --- a/apps/capi/test/capi_base_api_token_tests_SUITE.erl +++ b/apps/capi/test/capi_base_api_token_tests_SUITE.erl @@ -6,7 +6,6 @@ -include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -include_lib("damsel/include/dmsl_payproc_error_thrift.hrl"). -include_lib("damsel/include/dmsl_webhooker_thrift.hrl"). --include_lib("damsel/include/dmsl_merchstat_thrift.hrl"). -include_lib("damsel/include/dmsl_base_thrift.hrl"). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). -include_lib("reporter_proto/include/reporter_reports_thrift.hrl"). diff --git a/apps/capi/test/capi_dummy_data.hrl b/apps/capi/test/capi_dummy_data.hrl index 8a598e7..49c1c1e 100644 --- a/apps/capi/test/capi_dummy_data.hrl +++ b/apps/capi/test/capi_dummy_data.hrl @@ -1,3 +1,6 @@ +-ifndef(__CAPI_DUMMY_DATA_HRL__). +-define(__CAPI_DUMMY_DATA_HRL__, 42). + -define(STRING, <<"TEST">>). -define(RUB, <<"RUB">>). -define(USD, <<"USD">>). @@ -912,19 +915,6 @@ approval_code = <<"808080">> }). --define(STAT_PAYER(PaymentTool), ?STAT_PAYER(PaymentTool, ?STRING)). - --define(STAT_PAYER(PaymentTool, SessionId), - {payment_resource, #merchstat_PaymentResourcePayer{ - payment_tool = PaymentTool, - ip_address = ?STRING, - fingerprint = ?STRING, - phone_number = ?STRING, - email = <<"test@test.ru">>, - session_id = SessionId - }} -). - -define(STAT_CUSTOMER_PAYER(PaymentTool), {customer, #magista_CustomerPayer{ customer_id = ?STRING, @@ -933,16 +923,6 @@ }} ). --define(STAT_RECURRENT_PAYER(PaymentTool), - {recurrent, #merchstat_RecurrentPayer{ - payment_tool = PaymentTool, - recurrent_parent = ?RECURRENT_PARENT, - phone_number = ?STRING - }} -). - --define(RECURRENT_PARENT, #merchstat_RecurrentParentPayment{invoice_id = ?STRING, payment_id = ?STRING}). - -define(STAT_PAYMENT_STATUS_PENDING, {pending, #domain_InvoicePaymentPending{}}). -define(STAT_PAYMENT_STATUS_CAPTURED, {captured, #domain_InvoicePaymentCaptured{}}). @@ -964,48 +944,6 @@ <<"payment_system">> => <<"visa">> }). --define(STAT_REFUND, #merchstat_StatRefund{ - id = ?STRING, - payment_id = ?STRING, - invoice_id = ?STRING, - owner_id = ?STRING, - shop_id = ?STRING, - status = {succeeded, #merchstat_InvoicePaymentRefundSucceeded{at = ?TIMESTAMP}}, - created_at = ?TIMESTAMP, - amount = ?INTEGER, - fee = ?INTEGER, - currency_symbolic_code = ?RUB, - external_id = ?STRING, - allocation = ?ALLOCATION -}). - --define(STAT_PAYOUT(Type), #merchstat_StatPayout{ - id = ?STRING, - party_id = ?STRING, - shop_id = ?STRING, - created_at = ?TIMESTAMP, - status = {paid, #merchstat_PayoutPaid{}}, - amount = ?INTEGER, - fee = ?INTEGER, - currency_symbolic_code = ?RUB, - payout_tool_info = Type -}). - --define(STAT_BANK_CARD, #merchstat_BankCard{ - token = ?STRING, - payment_system = #domain_PaymentSystemRef{id = <<"visa">>}, - bin = <<"411111">>, - masked_pan = <<"411111******1111">> -}). - --define(STAT_BANK_CARD_WITH_TP, #merchstat_BankCard{ - token = ?STRING, - payment_system = #domain_PaymentSystemRef{id = <<"visa">>}, - bin = <<"411111">>, - masked_pan = <<"411111******1111">>, - payment_token = #domain_BankCardTokenServiceRef{id = <<"APPLE PAY">>} -}). - -define(REPORT_TYPE, <<"paymentRegistry">>). -define(REPORT, #reports_Report{ @@ -1410,3 +1348,5 @@ #{<<"product">> => ?STRING, <<"quantity">> => ?INTEGER, <<"price">> => ?INTEGER} ] }). + +-endif. diff --git a/apps/capi/test/capi_self_tests_SUITE.erl b/apps/capi/test/capi_self_tests_SUITE.erl index 4a64ce1..6f67c5c 100644 --- a/apps/capi/test/capi_self_tests_SUITE.erl +++ b/apps/capi/test/capi_self_tests_SUITE.erl @@ -3,7 +3,6 @@ -include_lib("common_test/include/ct.hrl"). -include_lib("damsel/include/dmsl_payproc_thrift.hrl"). --include_lib("damsel/include/dmsl_merchstat_thrift.hrl"). -include_lib("damsel/include/dmsl_base_thrift.hrl"). -include_lib("damsel/include/dmsl_domain_thrift.hrl").