ref:2a55e4ed70675d2cbe41a1d66e8233dd9612ba78

ci: add inline LCOV coverage generation and coverage config

Generate LCOV from coverdata inline in test step for Anvil coverage ingestion. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SHA: 2a55e4ed70675d2cbe41a1d66e8233dd9612ba78
Author: Cole Christensen <cole.christensen@macmillan.com>
Date: 2026-03-14 06:23
Parents: a57f1f5
1 files changed +28 -1
Type
.anvil.yml +28 −1
@@ -30,5 +30,32 @@
git config --global user.email "ci@anvil.test"
git config --global user.name "CI"
export MIX_HOME=/workspace/.mix
mix test --cover --export-coverage default
mix run --no-start -e '
:cover.start()
:cover.import(~c"cover/default.coverdata")
modules = :cover.imported_modules()
lcov = Enum.map_join(modules, "", fn mod ->
case :cover.analyse(mod, :calls, :line) do
{:ok, lines} ->
source = try do
mod.module_info(:compile)[:source] |> to_string()
|> String.replace(File.cwd!() <> "/", "")
rescue _ -> nil end
if source do
data = Enum.filter(lines, fn {{_, l}, _} -> l > 0 end)
da = Enum.map_join(data, "", fn {{_, l}, c} -> "DA:#{l},#{c}\n" end)
mix test --cover
h = Enum.count(data, fn {_, c} -> c > 0 end)
"SF:#{source}\n#{da}LH:#{h}\nLF:#{length(data)}\nend_of_record\n"
else "" end
_ -> ""
end
end)
File.write!("cover/lcov.info", lcov)
IO.puts("LCOV written to cover/lcov.info")
'
depends_on: [compile]
coverage:
reports:
- path: cover/lcov.info
format: lcov