From 736fa26b352e140925dee605679d5e51ec41d762 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Wed, 4 Apr 2018 14:08:50 -0500 Subject: [PATCH] Add excoveralls Resolves #88 --- .circleci/config.yml | 2 +- .gitignore | 1 + README.md | 4 ++-- apps/explorer/README.md | 2 +- apps/explorer/mix.exs | 9 +++++++++ apps/explorer_web/README.md | 2 +- apps/explorer_web/mix.exs | 9 +++++++++ coveralls.json | 9 +++++++++ mix.exs | 14 ++++++++++++-- mix.lock | 1 + 10 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 coveralls.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 23b86ed41d..fbe85915be 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -334,7 +334,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 936a2006d1..0f0b2f21c0 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 5d54dbffbe..92adf92f05 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# POA Explorer [![CircleCI](https://circleci.com/gh/poanetwork/poa-explorer.svg?style=svg&circle-token=f8823a3d0090407c11f87028c73015a331dbf604)](https://circleci.com/gh/poanetwork/poa-explorer) +# POA Explorer [![CircleCI](https://circleci.com/gh/poanetwork/poa-explorer.svg?style=svg&circle-token=f8823a3d0090407c11f87028c73015a331dbf604)](https://circleci.com/gh/poanetwork/poa-explorer) [![Coverage Status](https://coveralls.io/repos/github/poanetwork/poa-explorer/badge.svg?branch=master)](https://coveralls.io/github/poanetwork/poa-explorer?branch=master) This is a tool for inspecting and analyzing the POA Network blockchain. @@ -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 efcd25154c..427f4674fe 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 66f326ae88..eda003c6c8 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 53923689d5..ad9c0e4730 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 813e8a460c..15caa9f3a2 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 0000000000..4b1f26482a --- /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 c77d924365..0ecff97879 100644 --- a/mix.exs +++ b/mix.exs @@ -11,7 +11,14 @@ defmodule ExplorerUmbrella.Mixfile do ignore_warnings: ".dialyzer-ignore" ], elixir: "~> 1.6", - 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 @@ -28,6 +35,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 cfa32dfa6f..2d6dc52da3 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"},