Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests against Elixir 1.13 #72

Merged
merged 6 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ jobs:
fail-fast: false
matrix:
include:
- elixir: '1.7'
otp: '21'
- elixir: '1.7'
otp: '22'
- elixir: '1.8'
otp: '21'
- elixir: '1.8'
Expand Down Expand Up @@ -44,9 +40,17 @@ jobs:
otp: '23'
- elixir: '1.12'
otp: '24'
lint: lint
- elixir: '1.12'
otp: '24'
- elixir: '1.13'
otp: '22'
- elixir: '1.13'
otp: '23'
- elixir: '1.13'
otp: '24'
lint: lint
- elixir: '1.13'
otp: '24'
deps: latest

steps:
Expand Down
4 changes: 3 additions & 1 deletion lib/boom_notifier/error_info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ defmodule ErrorInfo do
@enforce_keys [:reason, :stack, :timestamp]
defstruct [:name, :reason, :stack, :controller, :action, :request, :timestamp, :metadata]

@type t :: %ErrorInfo{}

@type option ::
:logger
| [logger: [fields: list(atom())]]
Expand All @@ -24,7 +26,7 @@ defmodule ErrorInfo do
},
map(),
custom_data_strategy_type
) :: {atom(), %ErrorInfo{}}
) :: {atom(), ErrorInfo.t()}
def build(%{reason: reason, stack: stack} = error, conn, custom_data_strategy) do
{error_reason, error_name} = error_reason(reason)

Expand Down
4 changes: 2 additions & 2 deletions lib/boom_notifier/error_storage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule BoomNotifier.ErrorStorage do
Agent.start_link(fn -> %{} end, name: :boom_notifier)
end

@spec add_errors(atom(), %ErrorInfo{}) :: :ok
@spec add_errors(atom(), ErrorInfo.t()) :: :ok
def add_errors(error_kind, error_info) do
Agent.update(
:boom_notifier,
Expand All @@ -21,7 +21,7 @@ defmodule BoomNotifier.ErrorStorage do
)
end

@spec get_errors(atom()) :: list(%ErrorInfo{})
@spec get_errors(atom()) :: list(ErrorInfo.t())
def get_errors(error_kind) do
Agent.get(:boom_notifier, fn state -> state end)
|> Map.get(error_kind)
Expand Down
7 changes: 3 additions & 4 deletions lib/boom_notifier/mail_notifier.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ defmodule BoomNotifier.MailNotifier do
"""
@spec validate_config(keyword(String.t())) :: :ok | {:error, String.t()}
def validate_config(options) do
with :ok <- validate_required_config_keys(options),
:ok <- validate_config_values(options) do
:ok
with :ok <- validate_required_config_keys(options) do
validate_config_values(options)
end
end

@doc """
Creates mail subject line from a subject prefix and error reason message.
"""
@spec build_subject(String.t(), list(%ErrorInfo{}), non_neg_integer()) :: String.t()
@spec build_subject(String.t(), list(ErrorInfo.t()), non_neg_integer()) :: String.t()
def build_subject(prefix, [%ErrorInfo{reason: reason} | _], max_length) do
String.slice("#{prefix}: #{reason}", 0..(max_length - 1))
end
Expand Down
2 changes: 1 addition & 1 deletion lib/boom_notifier/mail_notifier/bamboo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if Code.ensure_loaded?(Bamboo) do
defdelegate validate_config(options), to: MailNotifier

@impl BoomNotifier.Notifier
@spec notify(list(%ErrorInfo{}), options) :: no_return()
@spec notify(list(ErrorInfo.t()), options) :: no_return()
def notify(error_info, options) do
subject =
MailNotifier.build_subject(
Expand Down
2 changes: 1 addition & 1 deletion lib/boom_notifier/mail_notifier/swoosh.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if Code.ensure_loaded?(Swoosh) do
defdelegate validate_config(options), to: MailNotifier

@impl BoomNotifier.Notifier
@spec notify(list(%ErrorInfo{}), options) :: no_return()
@spec notify(list(ErrorInfo.t()), options) :: no_return()
def notify(error_info, options) do
# Note, unlike Bamboo, Swoosh will raise while creating the mail if it is
# invalid (has a bad recipient, etc).
Expand Down
2 changes: 1 addition & 1 deletion lib/boom_notifier/webhook_notifier.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule BoomNotifier.WebhookNotifier do
end

@impl BoomNotifier.Notifier
@spec notify(list(%ErrorInfo{}), options) :: no_return()
@spec notify(list(ErrorInfo.t()), options) :: no_return()
def notify(errors_info, options) do
payload =
errors_info
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule BoomNotifier.MixProject do
[
app: :boom_notifier,
version: "0.7.0",
elixir: "~> 1.7",
elixir: "~> 1.8",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down Expand Up @@ -73,7 +73,7 @@ defmodule BoomNotifier.MixProject do
{:phoenix, "~> 1.4", only: [:test]},

# Dev dependencies
{:credo, "~> 1.1", only: [:dev], runtime: false},
{:credo, "~> 1.6.1", only: [:dev], runtime: false},
{:dialyxir, "~> 1.1", only: [:dev], runtime: false},
{:ex_doc, "~> 0.23", only: :dev}
]
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"},
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.3.1", "ebd1a1d7aff97f27c66654e78ece187abdc646992714164380d8a041eda16754", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3a6efd3366130eab84ca372cbd4a7d3c3a97bdfcfb4911233b035d117063f0af"},
"cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"},
"credo": {:hex, :credo, "1.5.6", "e04cc0fdc236fefbb578e0c04bd01a471081616e741d386909e527ac146016c6", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "4b52a3e558bd64e30de62a648518a5ea2b6e3e5d2b164ef5296244753fc7eb17"},
"credo": {:hex, :credo, "1.6.1", "7dc76dcdb764a4316c1596804c48eada9fff44bd4b733a91ccbf0c0f368be61e", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "698607fb5993720c7e93d2d8e76f2175bba024de964e160e2f7151ef3ab82ac5"},
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
"earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
Expand Down
5 changes: 4 additions & 1 deletion test/error_info_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,12 @@ defmodule ErrorInfoTest do
ErrorInfoTest.TestController,
:index,
2,
[file: 'test/error_info_test.exs', line: _]
error_info
} = hd(error_info_stack)

assert 'test/error_info_test.exs' = Keyword.fetch!(error_info, :file)
assert 16 = Keyword.fetch!(error_info, :line)

assert {
ExUnit.Runner,
_,
Expand Down