diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml index 683900cad..08b8412e4 100644 --- a/.github/workflows/code_coverage.yml +++ b/.github/workflows/code_coverage.yml @@ -7,7 +7,7 @@ on: jobs: test: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 name: Test OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} strategy: @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: erlef/setup-elixir@v1.12 + - uses: erlef/setup-beam@v1 with: otp-version: ${{matrix.otp}} elixir-version: ${{matrix.elixir}} diff --git a/.github/workflows/test-legacy.yml b/.github/workflows/test-legacy.yml new file mode 100644 index 000000000..77cefa6db --- /dev/null +++ b/.github/workflows/test-legacy.yml @@ -0,0 +1,76 @@ +name: Test Legacy + +on: + push: + branches: + - main + pull_request: + branches: + - '*' + +jobs: + test-elixir-legacy: + runs-on: ubuntu-20.04 + name: Test OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} + + strategy: + fail-fast: false + matrix: + otp: [22.x, 23.x] + elixir: [1.11.x, 1.12.x] + + steps: + - uses: actions/checkout@v3 + + - uses: erlef/setup-beam@v1 + with: + otp-version: ${{matrix.otp}} + elixir-version: ${{matrix.elixir}} + + - name: Cache Dependencies + uses: actions/cache@v3.0.9 + with: + path: | + deps + _build/dev + _build/test + key: elixir-cache-${{secrets.CACHE_VERSION}}-${{matrix.elixir}}-otp-${{matrix.otp}}-${{runner.os}}-${{hashFiles('mix.lock')}}-${{github.ref}} + restore-keys: | + elixir-cache-${{secrets.CACHE_VERSION}}-${{matrix.elixir}}-otp-${{matrix.otp}}-${{runner.os}}-${{hashFiles('mix.lock')}}- + elixir-cache-${{secrets.CACHE_VERSION}}-${{matrix.elixir}}-otp-${{matrix.otp}}-${{runner.os}}- + + - name: Install Dependencies + run: mix deps.get + + - name: Test + env: + CI: true + BINANCE_API_KEY: ./secrets/ci/binance_api_key + BINANCE_API_SECRET: ./secrets/ci/binance_api_secret + BITMEX_API_KEY: ./secrets/ci/bitmex_api_key + BITMEX_API_SECRET: ./secrets/ci/bitmex_api_secret + GDAX_API_KEY: ./secrets/ci/gdax_api_key + GDAX_API_PASSPHRASE: ./secrets/ci/gdax_api_passphrase + GDAX_API_SECRET: ./secrets/ci/gdax_api_secret + OKEX_API_KEY: ./secrets/ci/okex_api_key + OKEX_API_PASSPHRASE: ./secrets/ci/okex_api_passphrase + OKEX_API_SECRET: ./secrets/ci/okex_api_secret + DERIBIT_CLIENT_ID: ./secrets/ci/deribit_client_id + DERIBIT_CLIENT_SECRET: ./secrets/ci/deribit_client_secret + FTX_API_KEY: ./secrets/ci/ftx_api_key + FTX_API_SECRET: ./secrets/ci/ftx_api_secret + DELTA_EXCHANGE_API_KEY: ./secrets/ci/delta_exchange_api_key + DELTA_EXCHANGE_API_SECRET: ./secrets/ci/delta_exchange_api_secret + run: | + mix tai.gen.migration + mix test + + - uses: actions/upload-artifact@v3 + with: + name: log artifacts + path: | + apps/tai/log + apps/examples/log + + - name: Dialyzer + run: mix dialyzer diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8fab3bb04..d803bcf28 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,18 +10,19 @@ on: jobs: test-elixir: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 name: Test OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} strategy: + fail-fast: false matrix: - otp: [22.x, 23.x, 24.x] - elixir: [1.11.x, 1.12.x, 1.13.x] + otp: [24.x, 25.x] + elixir: [1.13.x, 1.14.x, 1.15.x] steps: - uses: actions/checkout@v3 - - uses: erlef/setup-elixir@v1.12 + - uses: erlef/setup-beam@v1 with: otp-version: ${{matrix.otp}} elixir-version: ${{matrix.elixir}} diff --git a/apps/examples/mix.exs b/apps/examples/mix.exs index 5850d6af4..12b5b2974 100644 --- a/apps/examples/mix.exs +++ b/apps/examples/mix.exs @@ -27,7 +27,9 @@ defmodule Examples.MixProject do defp deps do [ {:tai, in_umbrella: true}, - {:libcluster, "~> 3.2"} + {:libcluster, "~> 3.2"}, + + {:dialyxir, "~> 1.3", only: [:dev, :test], runtime: false} # TODO: remove after dialyzer umbprella support is added ] end diff --git a/apps/tai/lib/tai/fleets/queries/search.ex b/apps/tai/lib/tai/fleets/queries/search.ex index 52918761e..2f04c5f44 100644 --- a/apps/tai/lib/tai/fleets/queries/search.ex +++ b/apps/tai/lib/tai/fleets/queries/search.ex @@ -8,7 +8,7 @@ defmodule Tai.Fleets.Queries.Search do @type result :: [Tai.Fleets.FleetConfig.t()] @default_filters [] - @default_order [:fleet_id] + @default_order [:id] @default_store_id Tai.Fleets.FleetConfigStore.default_store_id() @spec call([opt]) :: result diff --git a/apps/tai/mix.exs b/apps/tai/mix.exs index 57b353a8c..f261e3f64 100644 --- a/apps/tai/mix.exs +++ b/apps/tai/mix.exs @@ -84,7 +84,9 @@ defmodule Tai.Mixfile do {:logger_file_backend_with_formatters_stackdriver, "~> 0.0.4", only: [:dev, :test]}, {:echo_boy, "~> 0.6", runtime: false, optional: true}, {:mock, "~> 0.3", only: :test}, - {:ex_doc, ">= 0.0.0", only: :dev} + {:ex_doc, ">= 0.0.0", only: :dev}, + + {:dialyxir, "~> 1.3", only: [:dev, :test], runtime: false} # TODO: remove after dialyzer umbrella support is added ] end diff --git a/apps/tai/test/tai/events/advisor_handle_event_error_test.exs b/apps/tai/test/tai/events/advisor_handle_event_error_test.exs index 7241ca610..c5015da6a 100644 --- a/apps/tai/test/tai/events/advisor_handle_event_error_test.exs +++ b/apps/tai/test/tai/events/advisor_handle_event_error_test.exs @@ -17,6 +17,6 @@ defmodule Tai.Events.AdvisorHandleMarketQuoteErrorTest do assert json.error == "%RuntimeError{message: \"!!!This is an ERROR!!!\"}" assert json.stacktrace == - "[{MyAdvisor, :execute_handle_market_quote, 2, [file: 'lib/tai/advisor.ex', line: 226]}]" + inspect([{MyAdvisor, :execute_handle_market_quote, 2, [file: 'lib/tai/advisor.ex', line: 226]}]) end end diff --git a/apps/tai/test/tai/events_logger_test.exs b/apps/tai/test/tai/events_logger_test.exs index a88a49b4b..1bab0d06d 100644 --- a/apps/tai/test/tai/events_logger_test.exs +++ b/apps/tai/test/tai/events_logger_test.exs @@ -35,10 +35,12 @@ defmodule Tai.EventsLoggerTest do test "logs info events" do logger = start_supervised!({Tai.EventsLogger, id: __MODULE__}) - assert capture_log(fn -> + log = capture_log(fn -> send(logger, {TaiEvents.Event, @event, :info}) :timer.sleep(100) - end) =~ "[info] {\"data\":{\"hello\":\"custom\"},\"type\":\"Support.CustomEvent\"}" + end) + assert log =~ "[info" + assert log =~ "{\"data\":{\"hello\":\"custom\"},\"type\":\"Support.CustomEvent\"}" end test "logs debug events" do @@ -61,9 +63,11 @@ defmodule Tai.EventsLoggerTest do logger = start_supervised!({Tai.EventsLogger, id: __MODULE__, logger: CustomLogger}) - assert capture_log(fn -> + log = capture_log(fn -> send(logger, {TaiEvents.Event, @event, :info}) :timer.sleep(100) - end) =~ "[info] message from custom logger" + end) + assert log =~ "[info" + assert log =~ "message from custom logger" end end diff --git a/mix.exs b/mix.exs index 4a38640dd..f889c5891 100644 --- a/mix.exs +++ b/mix.exs @@ -30,7 +30,7 @@ defmodule TaiMonorepo.MixProject do [ {:excoveralls, "~> 0.8", only: :test}, {:ex_unit_notifier, "~> 1.0", only: :test}, - {:dialyxir, "~> 1.0", only: :dev, runtime: false}, + {:dialyxir, "~> 1.3", only: [:dev, :test], runtime: false}, {:mix_test_watch, "~> 1.0", only: :dev, runtime: false}, {:licensir, "~> 0.6", only: :dev, runtime: false} ] diff --git a/mix.lock b/mix.lock index c21d56bcf..138f52863 100644 --- a/mix.lock +++ b/mix.lock @@ -10,7 +10,7 @@ "credo": {:hex, :credo, "1.6.7", "323f5734350fd23a456f2688b9430e7d517afb313fbd38671b8a4449798a7854", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "41e110bfb007f7eda7f897c10bf019ceab9a0b269ce79f015d54b0dcf4fc7dd3"}, "db_connection": {:hex, :db_connection, "2.4.2", "f92e79aff2375299a16bcb069a14ee8615c3414863a6fef93156aee8e86c2ff3", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4fe53ca91b99f55ea249693a0229356a08f4d1a7931d8ffa79289b145fe83668"}, "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, - "dialyxir": {:hex, :dialyxir, "1.2.0", "58344b3e87c2e7095304c81a9ae65cb68b613e28340690dfe1a5597fd08dec37", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "61072136427a851674cab81762be4dbeae7679f85b1272b6d25c3a839aff8463"}, + "dialyxir": {:hex, :dialyxir, "1.3.0", "fd1672f0922b7648ff9ce7b1b26fcf0ef56dda964a459892ad15f6b4410b5284", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "00b2a4bcd6aa8db9dcb0b38c1225b7277dca9bc370b6438715667071a304696f"}, "earmark_parser": {:hex, :earmark_parser, "1.4.26", "f4291134583f373c7d8755566122908eb9662df4c4b63caa66a0eabe06569b0a", [:mix], [], "hexpm", "48d460899f8a0c52c5470676611c01f64f3337bad0b26ddab43648428d94aabc"}, "echo_boy": {:hex, :echo_boy, "0.6.1", "2e0c166bf377f28080fa98a533db45b0ac960acf505df0048cbe5162810bcccc", [:mix], [{:cowboy, "~> 2.6", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: false]}], "hexpm", "b824bc9bd3bb6829203b8b63035130322188c6939c9b75cc123d244f2d2a28a4"}, "ecto": {:hex, :ecto, "3.9.0", "7c74fc0d950a700eb7019057ff32d047ed7f19b57c1b2ca260cf0e565829101d", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "fed5ebc5831378b916afd0b5852a0c5bb3e7390665cc2b0ec8ab0c712495b73d"}, @@ -75,7 +75,7 @@ "postgrex": {:hex, :postgrex, "0.16.5", "fcc4035cc90e23933c5d69a9cd686e329469446ef7abba2cf70f08e2c4b69810", [:mix], [{:connection, "~> 1.1", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "edead639dc6e882618c01d8fc891214c481ab9a3788dfe38dd5e37fd1d5fb2e8"}, "proper_case": {:hex, :proper_case, "1.3.1", "5f51cabd2d422a45f374c6061b7379191d585b5154456b371432d0fa7cb1ffda", [:mix], [], "hexpm", "6cc715550cc1895e61608060bbe67aef0d7c9cf55d7ddb013c6d7073036811dd"}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"}, "stored": {:hex, :stored, "0.0.8", "48f4fbd874a43586f542fb3b3ba0766befca6b24c04ab2464208b52e0ab6d623", [:mix], [], "hexpm", "8f62b6fe2c3413ed630921b19bdcb7d8db5db2b4596dd0842ca0078b37871fbe"}, "table_rex": {:hex, :table_rex, "3.1.1", "0c67164d1714b5e806d5067c1e96ff098ba7ae79413cc075973e17c38a587caa", [:mix], [], "hexpm", "678a23aba4d670419c23c17790f9dcd635a4a89022040df7d5d772cb21012490"}, "tai_events": {:hex, :tai_events, "0.0.2", "8cd2875e753db7b4db0a850d084879cb534bfc1941a3b9a2997bcd5c4320628a", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "9326f121b99acd39c1b970d993764cf37f5eb15c2d18cf1ba25386204f01d12f"},