GithubActionsFormatter

Hex.pmDocs

An ExUnit.Formatter that emits GitHub Actions workflow commands so that failing tests show up as inline annotations within the PR diff.

Installation

Add to mix.exs:

def deps do
  [{:github_actions_formatter, "~> 0.1", only: :test}]
end

Usage

In test/test_helper.exs:

ExUnit.start(formatters: [ExUnit.CLIFormatter, GithubActionsFormatter])

The formatter auto-detects GITHUB_ACTIONS=true and will stay silent elsewhere. Local mix test runs are unaffected.

Output

For each failing test, the formatter prints one line like:

::error file=test/widget_test.exs,line=42,title=My.Test failing test::Assertion failed: expected 10, got 9

GitHub renders this as a red annotation on the failing line in the PR diff.

Configuration

:enabled defaults to System.get_env("GITHUB_ACTIONS") == "true". Force it on locally:

config :github_actions_formatter, enabled: true

License

MIT — see LICENSE.