Skip to content

Commit baaae7a

Browse files
committed
ci: upload coverage report from GitHub Actions
mix coveralls.cobertura (91.6%) runs in its own job, uploads cover/cobertura.xml as an artifact and comments the summary on pull requests. mix.exs gains excoveralls (test only) and points @source_url at gilbertwong96/lovely_mermaid.
1 parent 454b18e commit baaae7a

4 files changed

Lines changed: 56 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,45 @@ jobs:
4545

4646
- name: Quality gates
4747
run: mix ci
48+
49+
coverage:
50+
runs-on: ubuntu-latest
51+
permissions:
52+
contents: read
53+
pull-requests: write
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- uses: erlef/setup-beam@v1
58+
with:
59+
elixir-version: "1.18"
60+
otp-version: "27"
61+
62+
- uses: actions/cache@v4
63+
with:
64+
path: |
65+
deps
66+
_build
67+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
68+
restore-keys: ${{ runner.os }}-mix-
69+
70+
- name: Fetch dependencies
71+
run: mix deps.get
72+
73+
- name: Generate coverage report
74+
run: mix coveralls.cobertura
75+
76+
- name: Upload coverage artifact
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: cobertura.xml
80+
path: cover/cobertura.xml
81+
82+
- name: Comment coverage summary on pull request
83+
if: github.event_name == 'pull_request'
84+
uses: irongut/CodeCoverageSummary@v1
85+
with:
86+
filename: cover/cobertura.xml
87+
badge: true
88+
format: markdown
89+
output: both

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ end
2020

2121
## API
2222

23-
| Function | Returns |
24-
|---|---|
25-
| `LovelyMermaid.render(src)` | `%LovelyMermaid.Art{}` (`plain`, `styled` [[span]], `width`, `class_defs`, `warnings`) or `nil` |
26-
| `LovelyMermaid.diagram_kind(src)` | `:flowchart \| :state \| :class \| :er \| :sequence \| :pie \| :mindmap \| :timeline \| :gitgraph \| nil` |
27-
| `LovelyMermaid.SourceBox.source_box(src, max_width \\ nil)` | Framed source lines, for when a diagram won't render |
28-
| `LovelyMermaid.Ansi.to_ansi(art, theme \\ Ansi.default_theme())` | ANSI-coloured lines from `art.styled` |
29-
| `LovelyMermaid.ClassStyle.resolve_class_style(classes, class_defs)` | Merged `classDef` style for a span, or `nil` |
23+
| Function | Returns |
24+
|---------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
25+
| `LovelyMermaid.render(src)` | `%LovelyMermaid.Art{}` (`plain`, `styled` [[span]], `width`, `class_defs`, `warnings`) or `nil` |
26+
| `LovelyMermaid.diagram_kind(src)` | `:flowchart \| :state \| :class \| :er \| :sequence \| :pie \| :mindmap \| :timeline \| :gitgraph \| nil` |
27+
| `LovelyMermaid.SourceBox.source_box(src, max_width \\ nil)` | Framed source lines, for when a diagram won't render |
28+
| `LovelyMermaid.Ansi.to_ansi(art, theme \\ Ansi.default_theme())` | ANSI-coloured lines from `art.styled` |
29+
| `LovelyMermaid.ClassStyle.resolve_class_style(classes, class_defs)` | Merged `classDef` style for a span, or `nil` |
3030

3131
Each `span` in `styled` is a `LovelyMermaid.Span``%Span{text, role}`
3232
with `classes` (author-assigned names from `:::name` / `class A,B name`)

mix.exs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule LovelyMermaid.MixProject do
22
use Mix.Project
33

44
@version "0.1.0"
5-
@source_url "https://github.com/gilbertwong/lovely_mermaid"
5+
@source_url "https://github.com/gilbertwong96/lovely_mermaid"
66

77
def project do
88
[
@@ -16,6 +16,9 @@ defmodule LovelyMermaid.MixProject do
1616
# Quality gates
1717
dialyzer: [plt_add_apps: [:mix]],
1818

19+
# Coverage
20+
test_coverage: [tool: ExCoveralls],
21+
1922
# Package
2023
description: "Render Mermaid diagrams as Unicode box-drawing art for terminals",
2124
package: package(),
@@ -46,7 +49,8 @@ defmodule LovelyMermaid.MixProject do
4649
{:ex_slop, "~> 0.4", only: [:dev, :test], runtime: false},
4750
{:reach, "~> 2.8", only: [:dev, :test], runtime: false},
4851
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
49-
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}
52+
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
53+
{:excoveralls, "~> 0.18", only: :test, runtime: false}
5054
]
5155
end
5256

mix.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"ex_dna": {:hex, :ex_dna, "1.5.4", "5a636109aeccca1c6df074367f53dc096f4280e90c075f5537ce8b8b4a843343", [:mix], [{:credo, "~> 1.7", [hex: :credo, repo: "hexpm", optional: true]}, {:gen_lsp, "~> 0.11", [hex: :gen_lsp, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: true]}], "hexpm", "66e6c7157127f023a219be16f2aa8e3a18c698e7a106f78bb24304b34df8034b"},
99
"ex_doc": {:hex, :ex_doc, "0.40.3", "4a972ffe64bc07dc605af487e98fc19b72a4185f55ca031b94c0552d6071c1d9", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "2756e357742fecd9749b489b85d67c9ce99c465f2e75728d9e6dc8d704b973de"},
1010
"ex_slop": {:hex, :ex_slop, "0.4.4", "8ca277b902e93193eb3545e414c309026a51204e5eb7d6ada5ff96555de6abcb", [:mix], [{:credo, "~> 1.7", [hex: :credo, repo: "hexpm", optional: false]}], "hexpm", "03ef1b2553ebad45c8ceb3e482eed5f1ccd08fc992215a9da0ef6196935107e2"},
11+
"excoveralls": {:hex, :excoveralls, "0.18.5", "e229d0a65982613332ec30f07940038fe451a2e5b29bce2a5022165f0c9b157e", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "523fe8a15603f86d64852aab2abe8ddbd78e68579c8525ae765facc5eae01562"},
1112
"file_system": {:hex, :file_system, "1.1.1", "31864f4685b0148f25bd3fbef2b1228457c0c89024ad67f7a81a3ffbc0bbad3a", [:mix], [], "hexpm", "7a15ff97dfe526aeefb090a7a9d3d03aa907e100e262a0f8f7746b78f8f87a5d"},
1213
"jason": {:hex, :jason, "1.4.5", "2e3a008590b0b8d7388c20293e9dcc9cf3e5d642fd2a114e4cbbb52e595d940a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b0c823996102bcd0239b3c2444eb00409b72f6a140c1950bc8b457d836b30684"},
1314
"libgraph": {:hex, :libgraph, "0.16.0", "3936f3eca6ef826e08880230f806bfea13193e49bf153f93edcf0239d4fd1d07", [:mix], [], "hexpm", "41ca92240e8a4138c30a7e06466acc709b0cbb795c643e9e17174a178982d6bf"},

0 commit comments

Comments
 (0)