diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 377fe35..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,49 +0,0 @@ -jobs: - build: - working_directory: ~/ex_rlp - docker: - - image: elixir:latest - steps: - - checkout - - run: git submodule sync --recursive - - run: git submodule update --recursive --init - - restore_cache: - keys: - - v2-dependency-cache-{{ arch }}-{{ checksum "mix.lock" }} - - v2-dependency-cache-{{ arch }} - - v2-dependency-cache - - - run: mix local.hex --force - - run: mix local.rebar --force - - run: mix deps.get - - run: mix credo - - run: mix format --check-formatted - - run: - command: mix compile - environment: - MIX_ENV: test - - - save_cache: - key: v2-dependency-cache-{{ arch }}-{{ checksum "mix.lock" }} - paths: - - _build - - deps - - ~/.mix - - - run: mix test - - - restore_cache: - keys: - - v2-plt-cache-{{ arch }}-{{ checksum "mix.lock" }} - - v2-plt-cache-{{ arch }} - - v2-plt-cache - - - run: mix dialyzer --plt - - - save_cache: - key: v2-plt-cache-{{ arch }}-{{ checksum "mix.lock" }} - paths: - - _build - - ~/.mix - - - run: mix dialyzer --halt-exit-status diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3771c99..706dd85 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,12 +1,8 @@ version: 2 updates: -- package-ecosystem: mix - directory: "/" - schedule: - interval: weekly - open-pull-requests-limit: 10 -- package-ecosystem: github-actions - directory: "/" - schedule: - interval: monthly - open-pull-requests-limit: 10 + - package-ecosystem: "mix" + directory: "/" + open-pull-requests-limit: 30 + schedule: + interval: "daily" + time: "03:37" # UTC diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..af94bbf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,70 @@ +name: ci + +on: + push: + branches: + - master + pull_request: + +jobs: + ci: + env: + MIX_ENV: test + strategy: + fail-fast: false + matrix: + include: + - pair: + elixir: '1.14' + otp: '24.3' + lint: lint + - pair: + elixir: '1.14' + otp: '25.0' + lint: lint + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - uses: erlef/setup-beam@v1 + with: + otp-version: ${{matrix.pair.otp}} + elixir-version: ${{matrix.pair.elixir}} + + - uses: actions/cache@v2 + with: + path: | + deps + _build + key: ${{ runner.os }}-mix-${{matrix.pair.elixir}}-${{matrix.pair.otp}}-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix-${{matrix.pair.elixir}}-${{matrix.pair.otp}}- + + - name: Run mix deps.get + run: mix deps.get --only test + + - name: Run mix format + run: mix format --check-formatted + if: ${{ matrix.lint }} + + - name: Run mix deps.compile + run: mix deps.compile + + - name: Run mix compile + run: mix compile --warnings-as-errors + if: ${{ matrix.lint }} + + - name: Run credo + run: mix credo --strict + if: ${{ matrix.lint }} + + - name: Run mix test + run: mix test + + - name: Run dialyzer + run: mix dialyzer + if: ${{ matrix.lint }} diff --git a/lib/ex_rlp.ex b/lib/ex_rlp.ex index 3f3d4ac..5ec8458 100644 --- a/lib/ex_rlp.ex +++ b/lib/ex_rlp.ex @@ -3,7 +3,8 @@ defmodule ExRLP do Elixir implementation of Ethereum's RLP (Recursive Length Prefix) encoding. """ - alias ExRLP.{Encode, Decode} + alias ExRLP.Decode + alias ExRLP.Encode @type t :: any() diff --git a/mix.exs b/mix.exs index c0d7794..5ae776d 100644 --- a/mix.exs +++ b/mix.exs @@ -14,7 +14,7 @@ defmodule ExRLP.Mixfile do package: package(), deps: deps(), docs: docs(), - dialyzer: [ignore_warnings: ".dialyzer.ignore-warnings"], + dialyzer: [ignore_warnings: ".dialyzer.ignore-warnings", plt_add_apps: [:jason]], elixirc_paths: elixirc_paths(Mix.env()) ] end @@ -27,7 +27,7 @@ defmodule ExRLP.Mixfile do [ {:credo, "~> 1.6", only: [:dev, :test], runtime: false}, {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, - {:dialyxir, "~> 1.1", only: [:dev], runtime: false}, + {:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false}, {:jason, "~> 1.3", only: [:dev, :test], runtime: false}, {:propcheck, "~> 1.4", only: [:test]} ] diff --git a/mix.lock b/mix.lock index dbb2bfd..f741d4b 100644 --- a/mix.lock +++ b/mix.lock @@ -2,9 +2,9 @@ "bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"}, "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"}, "dialyxir": {:hex, :dialyxir, "1.2.0", "58344b3e87c2e7095304c81a9ae65cb68b613e28340690dfe1a5597fd08dec37", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "61072136427a851674cab81762be4dbeae7679f85b1272b6d25c3a839aff8463"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.26", "f4291134583f373c7d8755566122908eb9662df4c4b63caa66a0eabe06569b0a", [:mix], [], "hexpm", "48d460899f8a0c52c5470676611c01f64f3337bad0b26ddab43648428d94aabc"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.28", "0bf6546eb7cd6185ae086cbc5d20cd6dbb4b428aad14c02c49f7b554484b4586", [:mix], [], "hexpm", "501cef12286a3231dc80c81352a9453decf9586977f917a96e619293132743fb"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_doc": {:hex, :ex_doc, "0.28.5", "3e52a6d2130ce74d096859e477b97080c156d0926701c13870a4e1f752363279", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "d2c4b07133113e9aa3e9ba27efb9088ba900e9e51caa383919676afdf09ab181"}, + "ex_doc": {:hex, :ex_doc, "0.28.6", "2bbd7a143d3014fc26de9056793e97600ae8978af2ced82c2575f130b7c0d7d7", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bca1441614654710ba37a0e173079273d619f9160cbcc8cd04e6bd59f1ad0e29"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"}, "libgraph": {:hex, :libgraph, "0.16.0", "3936f3eca6ef826e08880230f806bfea13193e49bf153f93edcf0239d4fd1d07", [:mix], [], "hexpm", "41ca92240e8a4138c30a7e06466acc709b0cbb795c643e9e17174a178982d6bf"}, diff --git a/test/ex_rlp/performance_test.exs b/test/ex_rlp/performance_test.exs index 06ef78a..203af83 100644 --- a/test/ex_rlp/performance_test.exs +++ b/test/ex_rlp/performance_test.exs @@ -15,7 +15,7 @@ defmodule ExRLP.PerformanceTest do assert elapsed(start) < 20 end - defp time_start() do + defp time_start do Time.utc_now() end diff --git a/test/ex_rlp/property_test.exs b/test/ex_rlp/property_test.exs index bd7e60e..1a346f3 100644 --- a/test/ex_rlp/property_test.exs +++ b/test/ex_rlp/property_test.exs @@ -4,14 +4,12 @@ defmodule ExRLP.PropTest do use PropCheck use ExUnit.Case - @moduletag timeout: 120_000 + @moduletag timeout: 300_000 def safe_decode(binary) do - try do - ExRLP.decode(binary) - rescue - _ -> :decoder_crashed - end + ExRLP.decode(binary) + rescue + _ -> :decoder_crashed end # Looks for cases where decoding is not one-to-one. Note: no claims about the encoder are checked here! diff --git a/test/support/log_entry.ex b/test/support/log_entry.ex index 669a841..59a3a35 100644 --- a/test/support/log_entry.ex +++ b/test/support/log_entry.ex @@ -4,7 +4,7 @@ defmodule ExRLP.LogEntry do defstruct address: nil, topics: [], data: nil @type t :: %__MODULE__{ - address: EVM.address(), + address: binary(), topics: [integer()], data: binary() } diff --git a/test/support/test_utils.ex b/test/support/test_utils.ex index 74fb3b2..ab0bab4 100644 --- a/test/support/test_utils.ex +++ b/test/support/test_utils.ex @@ -3,9 +3,10 @@ defmodule ExRLP.TestUtils do @tests_directory "test/support/ethereum_common_tests/RLPTests/" def read_json_file(file_name) do - {:ok, body} = File.read(@tests_directory <> file_name) - - Jason.decode!(body) + @tests_directory + |> Kernel.<>(file_name) + |> File.read!() + |> Jason.decode!() end def normalize_data("#" <> number) do