app: coverage floor (86) + framework-glue exclusions

Measured before choosing: 86.17%, identical via `mix test --cover` and via the
exported sample + `mix test.coverage`, stable across seeds. Floor is the integer
below that, with the rule written next to it: a FLOOR, ratcheted up as
behavior-test yaks land, never lowered (a drop means the change or an exclusion
is wrong).

Exclusions are the modules the suite cannot or should not exercise, each
justified in the config comment: `use`-generated glue (Repo, Mailer, Telemetry,
ErrorHTML/ErrorJSON), the `use FirehoseWeb` macro, production release tasks
(Release), the lib_dev credo check (NoConnShadowing), and test scaffolding
(DataCase, ConnCase, AccountsFixtures, Test.FakeBlog). Everything else counts,
CoreComponents/controllers/LiveViews included.

Wiring matches blogex and the fast/push split: `test.coverage` runs the suite
once with `--cover --export-coverage default` (deleting stale exports first,
since `mix test.coverage` imports every .coverdata it finds and would pool
them), then the `coverage` sensor enforces the floor from that export. The
sensor guards on the export existing because `mix test.coverage` exits 0 when it
finds nothing — a floor check that did not run must not pass.
This commit is contained in:
Willem van den Ende
2026-10-26 18:40:09 +00:00
parent 754c8fa1b9
commit abb712f8a2
2 changed files with 83 additions and 8 deletions
+57
View File
@@ -10,6 +10,7 @@ defmodule Firehose.MixProject do
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps(),
test_coverage: test_coverage(),
compilers: [:phoenix_live_view] ++ Mix.compilers(),
listeners: [Phoenix.CodeReloader]
]
@@ -99,4 +100,60 @@ defmodule Firehose.MixProject do
precommit: ["compile --warning-as-errors", "deps.unlock --unused", "format", "test"]
]
end
# The coverage floor the Lens pass enforces (`make verify` -> `make coverage`
# in app/). Rule: the threshold is a FLOOR. Raise it as behavior-test yaks
# land; never lower it. A drop means the change (or an exclusion) is wrong,
# not the floor.
#
# Measured 2026-10-26 (PostgreSQL on localhost:5432, exclusions below):
# 86.17%, identical via `mix test --cover` and via
# `mix test --cover --export-coverage default` + `mix test.coverage`, and
# stable across seeds. Floor is the integer below that.
#
# `test.coverage` deletes stale exports before sampling: `mix test.coverage`
# imports *every* .coverdata it finds, so leftover exports from earlier runs
# pool into the total and quietly inflate it.
#
# Excluded are modules the suite cannot or should not exercise; counting them
# would move the number without saying anything about app behavior:
#
# * framework glue generated by `use`:
# Firehose.Repo `use Ecto.Repo`
# Firehose.Mailer `use Swoosh.Mailer`
# FirehoseWeb.Telemetry Phoenix's telemetry supervisor + metric list
# FirehoseWeb.ErrorHTML Phoenix error renderers, both delegating to
# FirehoseWeb.ErrorJSON Phoenix.Controller.status_message_from_template/1
# * FirehoseWeb the `use FirehoseWeb` macro: imports and aliases
# only, nothing that executes
# * Firehose.Release production release tasks (`mix ecto.migrate` on
# Dokku); the suite never runs them
# * Firehose.Checks.NoConnShadowing
# lib_dev credo check, exercised by `mix credo`
# and not by tests
# * test scaffolding Firehose.DataCase, FirehoseWeb.ConnCase,
# Firehose.AccountsFixtures, Firehose.Test.FakeBlog:
# fixtures measure the tests, not the app
#
# Everything else counts — CoreComponents, controllers, LiveViews included:
# that is where the behavior-test work shows up as a higher floor.
defp test_coverage do
[
summary: [threshold: 86],
ignore_modules: [
Firehose.Repo,
Firehose.Mailer,
Firehose.Release,
FirehoseWeb,
FirehoseWeb.Telemetry,
FirehoseWeb.ErrorHTML,
FirehoseWeb.ErrorJSON,
Firehose.Checks.NoConnShadowing,
Firehose.DataCase,
FirehoseWeb.ConnCase,
Firehose.AccountsFixtures,
Firehose.Test.FakeBlog
]
]
end
end