From de317d1389ab9bc4b1e7de58442e2c998b050761 Mon Sep 17 00:00:00 2001 From: Terence Ponce Date: Sat, 13 Apr 2024 05:48:46 +0100 Subject: [PATCH] Add Test Coverage Reports (#4) This adds ExCoveralls to provide test coverage reports. This also integrates CodeCov.io as the test coverage service. --- .github/workflows/ci.yml | 8 +++++++- README.md | 1 + coveralls.json | 15 +++++++++++++++ mix.exs | 11 ++++++++++- mix.lock | 1 + 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 coveralls.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 366d0aa..3ea69d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,4 +81,10 @@ jobs: run: mix lint.ci - name: Run Tests - run: mix test + run: mix coveralls.json + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: DashFloat/DashFloat diff --git a/README.md b/README.md index fb4c6e6..3b40728 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # DashFloat [![gh-actions](https://github.com/DashFloat/DashFloat/workflows/CI/badge.svg)](https://github.com/DashFloat/DashFloat/actions?workflow=CI) +[![codecov](https://codecov.io/gh/DashFloat/DashFloat/graph/badge.svg?token=UMdAUsjjpF)](https://codecov.io/gh/DashFloat/DashFloat) To start your Phoenix server: diff --git a/coveralls.json b/coveralls.json new file mode 100644 index 0000000..0b1b652 --- /dev/null +++ b/coveralls.json @@ -0,0 +1,15 @@ +{ + "skip_files": [ + "lib/dash_float.ex", + "lib/dash_float/application.ex", + "lib/dash_float/repo.ex", + "lib/dash_float_web.ex", + "lib/dash_float_web/components/core_components.ex", + "lib/dash_float_web/components/layouts.ex", + "lib/dash_float_web/endpoint.ex", + "lib/dash_float_web/gettext.ex", + "lib/dash_float_web/router.ex", + "lib/dash_float_web/telemetry.ex", + "test" + ] +} diff --git a/mix.exs b/mix.exs index 1d1254a..0710346 100644 --- a/mix.exs +++ b/mix.exs @@ -9,7 +9,15 @@ defmodule DashFloat.MixProject do elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, aliases: aliases(), - deps: deps() + deps: deps(), + test_coverage: [tool: ExCoveralls], + preferred_cli_env: [ + coveralls: :test, + "coveralls.detail": :test, + "coveralls.post": :test, + "coveralls.html": :test, + "coveralls.cobertura": :test + ] ] end @@ -36,6 +44,7 @@ defmodule DashFloat.MixProject do {:dns_cluster, "0.1.3"}, {:ecto_sql, "3.11.1"}, {:esbuild, "0.8.1", runtime: Mix.env() == :dev}, + {:excoveralls, "0.18.1", only: :test}, {:finch, "0.18.0"}, {:floki, "0.36.1", only: :test}, {:gettext, "0.24.0"}, diff --git a/mix.lock b/mix.lock index d654ee4..75daa8a 100644 --- a/mix.lock +++ b/mix.lock @@ -7,6 +7,7 @@ "ecto": {:hex, :ecto, "3.11.2", "e1d26be989db350a633667c5cda9c3d115ae779b66da567c68c80cfb26a8c9ee", [:mix], [{:decimal, "~> 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", "3c38bca2c6f8d8023f2145326cc8a80100c3ffe4dcbd9842ff867f7fc6156c65"}, "ecto_sql": {:hex, :ecto_sql, "3.11.1", "e9abf28ae27ef3916b43545f9578b4750956ccea444853606472089e7d169470", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.11.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.6.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.16.0 or ~> 0.17.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ce14063ab3514424276e7e360108ad6c2308f6d88164a076aac8a387e1fea634"}, "esbuild": {:hex, :esbuild, "0.8.1", "0cbf919f0eccb136d2eeef0df49c4acf55336de864e63594adcea3814f3edf41", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "25fc876a67c13cb0a776e7b5d7974851556baeda2085296c14ab48555ea7560f"}, + "excoveralls": {:hex, :excoveralls, "0.18.1", "a6f547570c6b24ec13f122a5634833a063aec49218f6fff27de9df693a15588c", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "d65f79db146bb20399f23046015974de0079668b9abb2f5aac074d078da60b8d"}, "expo": {:hex, :expo, "0.5.2", "beba786aab8e3c5431813d7a44b828e7b922bfa431d6bfbada0904535342efe2", [:mix], [], "hexpm", "8c9bfa06ca017c9cb4020fabe980bc7fdb1aaec059fd004c2ab3bff03b1c599c"}, "file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"}, "finch": {:hex, :finch, "0.18.0", "944ac7d34d0bd2ac8998f79f7a811b21d87d911e77a786bc5810adb75632ada4", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6 or ~> 1.0", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "69f5045b042e531e53edc2574f15e25e735b522c37e2ddb766e15b979e03aa65"},