From 50ac2fbbbdcca310aec84bbdea8479f798fbb25a Mon Sep 17 00:00:00 2001 From: gilacost Date: Fri, 3 Apr 2020 07:17:40 +0200 Subject: [PATCH] chore: adds codecoverage and clean up --- .github/workflows/elixir.yml | 9 ++++++ README.md | 8 ++--- config/config.exs | 5 ++++ mix.exs | 36 ++++++++++++++++++----- mix.lock | 24 ++++++++++----- test/fixtures/silent_io/config/config.exs | 2 +- test/lettuce_test.exs | 3 +- 7 files changed, 65 insertions(+), 22 deletions(-) create mode 100644 config/config.exs diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 086d5db..76af5eb 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -50,3 +50,12 @@ jobs: - name: Check Typespec run: mix dialyzer --halt-exit-status + + - name: Build Code Coverage Report + run: mix coveralls.json + + - name: Upload Code Coverage Report + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./cover/excoveralls.json diff --git a/README.md b/README.md index fdf99de..93c0d5f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ initialises the state of the generic server with the `.ex` files inside `lib` and their last modified time. By default `lib` is used but you may specify which folders you want to be watched. -![Elixir CI status](https://github.com/gilacost/lettuce/workflows/Elixir%20CI/badge.svg) ![Hex version badge](https://img.shields.io/hexpm/v/lettuce.svg) +![Elixir CI status](https://github.com/gilacost/lettuce/workflows/Elixir%20CI/badge.svg) ![Hex version badge](https://img.shields.io/hexpm/v/lettuce.svg) [![codecov](https://codecov.io/gh/gilacost/lettuce/branch/master/graph/badge.svg)](https://codecov.io/gh/gilacost/lettuce) ## Installation @@ -81,11 +81,9 @@ details. - [x] caching plts in github actions - [x] pass the initial time from the setup to fix the flaky test - [x] capture log with silent - -- [ ] code coverage +- [x] remove redefined module warning +- [x] code coverage - [ ] all elixir run parameters as options - -- [ ] remove redefined module warning - [ ] use option parser - [ ] package publishing when tagging - [ ] how it works diff --git a/config/config.exs b/config/config.exs new file mode 100644 index 0000000..7572d66 --- /dev/null +++ b/config/config.exs @@ -0,0 +1,5 @@ +use Mix.Config + +config :lettuce, + folders_to_watch: ["lib"], + silent?: true diff --git a/mix.exs b/mix.exs index 54f2623..cc771fb 100644 --- a/mix.exs +++ b/mix.exs @@ -4,23 +4,21 @@ defmodule Lettuce.MixProject do def project do [ app: :lettuce, - version: "0.1.4", + version: "0.1.41", elixir: "~> 1.10.2", start_permanent: Mix.env() == :prod, build_embedded: Mix.env() == :prod, deps: deps(), + package: package(), + dialyzer: dialyzer(), + test_coverage: test_coverage(), + preferred_cli_env: preferred_cli_env(), description: """ Lettuce checks the files within an elixir project and then runs `iex -S mix`. It initialises the state of a generic server with the `.ex` files inside `lib` and their last modified time. By default `lib` is used but you can specify which folders you want to be watched. """, - package: package(), - dialyzer: [ - plt_add_deps: [:apps_direct], - plt_add_apps: [:mix], - plt_file: {:no_warn, "priv/plts/dialyzer.plt"} - ], docs: [ main: "readme", extras: ["README.md"] @@ -28,6 +26,29 @@ defmodule Lettuce.MixProject do ] end + defp dialyzer() do + [ + plt_add_deps: [:apps_direct], + plt_add_apps: [:mix], + plt_file: {:no_warn, "priv/plts/dialyzer.plt"} + ] + end + + defp test_coverage do + [ + tool: ExCoveralls + ] + end + + defp preferred_cli_env do + [ + "coveralls.detail": :test, + "coveralls.html": :test, + "coveralls.json": :test, + coveralls: :test + ] + end + def application do [ extra_applications: [:logger], @@ -38,6 +59,7 @@ defmodule Lettuce.MixProject do defp deps do [ {:ex_doc, "~> 0.21", only: :dev, runtime: false}, + {:excoveralls, "~> 0.10", only: :test}, {:dialyxir, "~> 1.0.0-rc.7", only: [:dev, :test], runtime: false} ] end diff --git a/mix.lock b/mix.lock index 9a87d5c..1256948 100644 --- a/mix.lock +++ b/mix.lock @@ -1,9 +1,19 @@ %{ - "dialyxir": {:hex, :dialyxir, "1.0.0-rc.7", "6287f8f2cb45df8584317a4be1075b8c9b8a69de8eeb82b4d9e6c761cf2664cd", [:mix], [{:erlex, ">= 0.2.5", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm"}, - "earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm"}, - "erlex": {:hex, :erlex, "0.2.5", "e51132f2f472e13d606d808f0574508eeea2030d487fc002b46ad97e738b0510", [:mix], [], "hexpm"}, - "ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, - "makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, - "nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm"}, + "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"}, + "dialyxir": {:hex, :dialyxir, "1.0.0-rc.7", "6287f8f2cb45df8584317a4be1075b8c9b8a69de8eeb82b4d9e6c761cf2664cd", [:mix], [{:erlex, ">= 0.2.5", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "506294d6c543e4e5282d4852aead19ace8a35bedeb043f9256a06a6336827122"}, + "earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"}, + "erlex": {:hex, :erlex, "0.2.5", "e51132f2f472e13d606d808f0574508eeea2030d487fc002b46ad97e738b0510", [:mix], [], "hexpm", "756d3e19b056339af674b715fdd752c5dac468cf9d0e2d1a03abf4574e99fbf8"}, + "ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"}, + "excoveralls": {:hex, :excoveralls, "0.12.3", "2142be7cb978a3ae78385487edda6d1aff0e482ffc6123877bb7270a8ffbcfe0", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "568a3e616c264283f5dea5b020783ae40eef3f7ee2163f7a67cbd7b35bcadada"}, + "hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "e0100f8ef7d1124222c11ad362c857d3df7cb5f4204054f9f0f4a728666591fc"}, + "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"}, + "jason": {:hex, :jason, "1.2.0", "10043418c42d2493d0ee212d3fddd25d7ffe484380afad769a0a38795938e448", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "116747dbe057794c3a3e4e143b7c8390b29f634e16c78a7f59ba75bfa6852e7f"}, + "makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "a10c6eb62cca416019663129699769f0c2ccf39428b3bb3c0cb38c718a0c186d"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, + "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, + "nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm", "589b5af56f4afca65217a1f3eb3fee7e79b09c40c742fddc1c312b3ac0b3399f"}, + "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm", "13104d7897e38ed7f044c4de953a6c28597d1c952075eb2e328bc6d6f2bfc496"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"}, } diff --git a/test/fixtures/silent_io/config/config.exs b/test/fixtures/silent_io/config/config.exs index 7572d66..c3d0787 100644 --- a/test/fixtures/silent_io/config/config.exs +++ b/test/fixtures/silent_io/config/config.exs @@ -2,4 +2,4 @@ use Mix.Config config :lettuce, folders_to_watch: ["lib"], - silent?: true + ilent?: true diff --git a/test/lettuce_test.exs b/test/lettuce_test.exs index 6192452..bc38ac0 100644 --- a/test/lettuce_test.exs +++ b/test/lettuce_test.exs @@ -87,8 +87,7 @@ defmodule LettuceTest do defp touch_in_project(initial_times, project, beam_file) do project |> String.to_existing_atom() - |> Mix.Project.in_project("test/fixtures/#{project}", fn module -> - IO.puts("Project: #{project} \n Module: #{module}") + |> Mix.Project.in_project("test/fixtures/#{project}", fn _module -> Mix.Tasks.Loadconfig.run(["config/config.exs"]) Process.sleep(2000)