From 028c2a1b8d30c5f92eca2cb2654a9abc99bab82c Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Fri, 17 Apr 2026 13:30:04 +0100 Subject: [PATCH] Configure test coverage and enable on CI --- .github/workflows/test_and_deploy.yml | 2 +- mix.exs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index e45b44dc..fd2fdb47 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -143,7 +143,7 @@ jobs: - name: 🔮 Compile for TEST run: mix compile - name: 🧪 Run tests - run: mix test --max-cases 8 + run: mix test --cover --export-coverage ci-run --max-cases 8 deploy: name: Deploy diff --git a/mix.exs b/mix.exs index 0e5f7c74..6bb1b714 100644 --- a/mix.exs +++ b/mix.exs @@ -13,10 +13,30 @@ defmodule MusicLibrary.MixProject do deps: deps(), compilers: [:phoenix_live_view] ++ Mix.compilers(), listeners: [Phoenix.CodeReloader], + test_coverage: [ + ignore_modules: ignored_coverage_modules(), + summary: [threshold: 75] + ], usage_rules: usage_rules() ] end + # Modules excluded from coverage accounting: cron-only workers that run + # operations incompatible with the Ecto sandbox (VACUUM / OPTIMIZE outside a + # transaction) or whose behaviour beyond a delegate call is untestable, and + # all Mix tasks (developer tooling not exercised by the application test + # suite). + defp ignored_coverage_modules do + [ + MusicLibrary.Worker.RepoVacuum, + MusicLibrary.Worker.RepoOptimize, + MusicLibrary.Worker.SendRecordsOnThisDayEmail, + MusicLibrary.Worker.RefreshScrobbles, + MusicLibrary.Worker.BackfillScrobbledTracks, + ~r/^Mix\.Tasks\./ + ] + end + # Configuration for the OTP application. # # Type `mix help compile.app` for more information.