diff --git a/.circleci/config.yml b/.circleci/config.yml index ee6dd51b2110..e5487fcd5ebb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -330,7 +330,7 @@ jobs: name: Wait for Redis command: dockerize -wait tcp://localhost:6379 -timeout 1m - - run: mix test + - run: mix coveralls.circle --umbrella - store_test_results: path: _build/test/junit diff --git a/.gitignore b/.gitignore index 936a2006d19d..0f0b2f21c04e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # App artifacts /_build +/cover /db /deps /*.ez diff --git a/README.md b/README.md index 07f7e81bf766..89e57705c9eb 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Configure your local CCMenu with the following url: [`https://circleci.com/gh/po * Build the assets: `$ cd apps/explorer_web/assets && yarn build && cd -` * Format the Elixir code: `$ mix format` - * Run the test suite: `$ mix test` + * Run the test suite with coverage for whole umbrella project: `$ mix coveralls.html --umbrella` * Lint the Elixir code: `$ mix credo --strict` * Run the dialyzer: `mix dialyzer --halt-exit-status` * Check the Elixir code for vulnerabilities: `$ mix sobelow --config` diff --git a/apps/explorer/README.md b/apps/explorer/README.md index efcd25154cdf..427f4674fe4c 100644 --- a/apps/explorer/README.md +++ b/apps/explorer/README.md @@ -30,7 +30,7 @@ To get POA Explorer up and running locally: ### Testing * Format the Elixir code: `$ mix format` - * Run the test suite: `$ mix test` + * Run the test suite with coverage: `$ mix coveralls.html` * Lint the Elixir code: `$ mix credo --strict` * Run the dialyzer: `mix dialyzer --halt-exit-status` * Check the Elixir code for vulnerabilities: `$ mix sobelow --config` diff --git a/apps/explorer/mix.exs b/apps/explorer/mix.exs index 5d6c9cf50792..b4f0d59e283e 100644 --- a/apps/explorer/mix.exs +++ b/apps/explorer/mix.exs @@ -18,7 +18,14 @@ defmodule Explorer.Mixfile do elixirc_paths: elixirc_paths(Mix.env()), lockfile: "../../mix.lock", package: package(), + preferred_cli_env: [ + coveralls: :test, + "coveralls.detail": :test, + "coveralls.post": :test, + "coveralls.html": :test + ], start_permanent: Mix.env() == :prod, + test_coverage: [tool: ExCoveralls], version: "0.0.1" ] end @@ -68,6 +75,8 @@ defmodule Explorer.Mixfile do {:dialyxir, "~> 0.5", only: [:dev, :test], runtime: false}, {:ethereumex, "~> 0.3"}, {:ex_machina, "~> 2.1", only: [:test]}, + # Code coverage + {:excoveralls, "~> 0.8.1", only: [:test]}, {:exq, "~> 0.9.1"}, {:exq_ui, "~> 0.9.0"}, {:exvcr, "~> 0.10", only: :test}, diff --git a/apps/explorer_web/README.md b/apps/explorer_web/README.md index 53923689d519..ad9c0e4730f5 100644 --- a/apps/explorer_web/README.md +++ b/apps/explorer_web/README.md @@ -34,7 +34,7 @@ You can also run IEx (Interactive Elixir): `$ iex -S mix phx.server` (This can b * Build the assets: `$ cd assets && yarn build` * Format the Elixir code: `$ mix format` - * Run the test suite: `$ mix test` + * Run the test suite with coverage: `$ mix coveralls.html` * Lint the Elixir code: `$ mix credo --strict` * Run the dialyzer: `mix dialyzer --halt-exit-status` * Check the Elixir code for vulnerabilities: `$ mix sobelow --config` diff --git a/apps/explorer_web/mix.exs b/apps/explorer_web/mix.exs index fd85ba95891d..2cfdb5fa6a78 100644 --- a/apps/explorer_web/mix.exs +++ b/apps/explorer_web/mix.exs @@ -18,7 +18,14 @@ defmodule ExplorerWeb.Mixfile do elixirc_paths: elixirc_paths(Mix.env()), lockfile: "../../mix.lock", package: package(), + preferred_cli_env: [ + coveralls: :test, + "coveralls.detail": :test, + "coveralls.post": :test, + "coveralls.html": :test + ], start_permanent: Mix.env() == :prod, + test_coverage: [tool: ExCoveralls], version: "0.0.1" ] end @@ -72,6 +79,8 @@ defmodule ExplorerWeb.Mixfile do {:ex_cldr_units, "~> 1.0"}, {:ex_jasmine, github: "minifast/ex_jasmine", branch: "master"}, {:ex_machina, "~> 2.1", only: [:test]}, + # Code coverage + {:excoveralls, "~> 0.8.1", only: [:test]}, {:explorer, in_umbrella: true}, {:exvcr, "~> 0.10", only: :test}, {:flow, "~> 0.12"}, diff --git a/coveralls.json b/coveralls.json new file mode 100644 index 000000000000..4b1f26482a34 --- /dev/null +++ b/coveralls.json @@ -0,0 +1,9 @@ +{ + "coverage_options": { + "treat_no_relevant_lines_as_covered": true, + "minimum_coverage": 77.8 + }, + "terminal_options": { + "file_column_width": 120 + } +} diff --git a/mix.exs b/mix.exs index 9cf38d65fdab..0d906ab12e77 100644 --- a/mix.exs +++ b/mix.exs @@ -10,7 +10,14 @@ defmodule ExplorerUmbrella.Mixfile do plt_add_apps: [:mix], ignore_warnings: ".dialyzer-ignore" ], - start_permanent: Mix.env() == :prod + preferred_cli_env: [ + coveralls: :test, + "coveralls.detail": :test, + "coveralls.post": :test, + "coveralls.html": :test + ], + start_permanent: Mix.env() == :prod, + test_coverage: [tool: ExCoveralls] ] end @@ -27,6 +34,9 @@ defmodule ExplorerUmbrella.Mixfile do # Dependencies listed here are available only for this project # and cannot be accessed from applications inside the apps folder defp deps do - [] + [ + # Code coverage + {:excoveralls, "~> 0.8.1", only: [:test]} + ] end end diff --git a/mix.lock b/mix.lock index cfa32dfa6f87..2d6dc52da3c0 100644 --- a/mix.lock +++ b/mix.lock @@ -19,6 +19,7 @@ "ex_jasmine": {:git, "https://github.com/minifast/ex_jasmine.git", "f2c906e36b469a9bf0891c23cd72135ba6a257f1", [branch: "master"]}, "ex_machina": {:hex, :ex_machina, "2.1.0", "4874dc9c78e7cf2d429f24dc3c4005674d4e4da6a08be961ffccc08fb528e28b", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "exactor": {:hex, :exactor, "2.2.4", "5efb4ddeb2c48d9a1d7c9b465a6fffdd82300eb9618ece5d34c3334d5d7245b1", [:mix], [], "hexpm"}, + "excoveralls": {:hex, :excoveralls, "0.8.1", "0bbf67f22c7dbf7503981d21a5eef5db8bbc3cb86e70d3798e8c802c74fa5e27", [:mix], [{:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"}, "exq": {:hex, :exq, "0.9.1", "77ee12c117411ddddd9810aec714eaa704fb8f327949551d9efaea19606122c3", [:mix], [{:poison, ">= 1.2.0 or ~> 2.0", [hex: :poison, repo: "hexpm", optional: false]}, {:redix, ">= 0.5.0", [hex: :redix, repo: "hexpm", optional: false]}, {:uuid, ">= 1.1.0", [hex: :uuid, repo: "hexpm", optional: false]}], "hexpm"}, "exq_ui": {:hex, :exq_ui, "0.9.0", "e97e9fa9009f30d2926b51a166e40a3a521e83f61f3f333fede8335b2aa57f09", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: false]}, {:exq, "~> 0.9", [hex: :exq, repo: "hexpm", optional: false]}, {:plug, ">= 0.8.1 and < 2.0.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},