Skip to content

Commit

Permalink
Update to Elixir 1.15
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultzer committed Aug 30, 2023
1 parent 974f6a6 commit 856e997
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 36 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:

jobs:
test:
# This ensures we run the test for only the PR or the push
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
services:
postgres:
image: postgres:latest
Expand All @@ -26,8 +28,8 @@ jobs:
strategy:
matrix:
include:
- otp: 25.0
elixir: 1.14.0
- otp: 26.0
elixir: 1.15.0
os: ubuntu-latest
- otp: 22.0
elixir: 1.12.0
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## v1.0.32 (TBA)

Removed deprecation warnings for Elixir 1.15.

## Bug fixes

- [`Pow.Phoenix.Controller`] Now uses `Phoenix.View` when it's available with `:namespace` option to prevent upgrade issues
Expand Down
2 changes: 1 addition & 1 deletion guides/configuring_mailer.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ defmodule MyAppWeb.Pow.Mailer do
end

defp log_warnings({:error, reason}) do
Logger.warn("Mailer backend failed with: #{inspect(reason)}")
Logger.warning("Mailer backend failed with: #{inspect(reason)}")
end

defp log_warnings({:ok, response}), do: {:ok, response}
Expand Down
2 changes: 1 addition & 1 deletion guides/production_checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ defmodule MyAppWeb.Pow.Mailer do
def process(email) do
case check_rate(email) do
{:allow, _count} -> deliver(email)
{:deny, _count} -> Logger.warn("Mailer backend failed due to rate limitation: #{inspect(email)}")
{:deny, _count} -> Logger.warning("Mailer backend failed due to rate limitation: #{inspect(email)}")
end
end

Expand Down
4 changes: 2 additions & 2 deletions guides/redis_cache_store_backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ defmodule MyAppWeb.Pow.RedisCache do
end)
end

@spec raise_ttl_error! :: no_return()
defp raise_ttl_error!,
@spec raise_ttl_error!() :: no_return()
defp raise_ttl_error!(),
do: Config.raise_error("`:ttl` configuration option is required for #{inspect(__MODULE__)}")
end
```
Expand Down
2 changes: 1 addition & 1 deletion lib/extensions/persistent_session/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ defmodule PowPersistentSession.Plug do
end

@spec raise_no_plug_error!() :: no_return()
defp raise_no_plug_error!,
defp raise_no_plug_error!(),
do: Config.raise_error("PowPersistentSession plug module not installed. Please add the PowPersistentSession.Plug.Cookie plug to your endpoint.")
end
5 changes: 3 additions & 2 deletions lib/pow/ecto/schema/password.ex
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ defmodule Pow.Ecto.Schema.Password do
end

@spec raise_not_valid_password_hash!() :: no_return()
defp raise_not_valid_password_hash!,
do: raise ArgumentError, "not a valid encoded password hash"
defp raise_not_valid_password_hash!() do
raise ArgumentError, "not a valid encoded password hash"
end
end
5 changes: 3 additions & 2 deletions lib/pow/extension/ecto/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ defmodule Pow.Extension.Ecto.Schema do
end

@spec raise_missing_field_error!(module(), atom(), atom()) :: no_return()
defp raise_missing_field_error!(module, field, extension),
do: raise SchemaError, message: "A `#{inspect field}` schema field should be defined in #{inspect module} to use #{inspect extension}"
defp raise_missing_field_error!(module, field, extension) do
raise SchemaError, message: "A `#{inspect field}` schema field should be defined in #{inspect module} to use #{inspect extension}"
end
end
5 changes: 3 additions & 2 deletions lib/pow/phoenix/mailer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ defmodule Pow.Phoenix.Mailer do
end

@spec raise_no_mailer_backend_set!() :: no_return()
defp raise_no_mailer_backend_set!,
do: Config.raise_error("No :mailer_backend configuration option found for plug.")
defp raise_no_mailer_backend_set!() do
Config.raise_error("No :mailer_backend configuration option found for plug.")
end
end
9 changes: 4 additions & 5 deletions lib/pow/phoenix/template.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ defmodule Pow.Phoenix.Template do
"""
@spec template(atom(), atom(), binary() | {atom(), any()}) :: Macro.t()
defmacro template(action, :html, content) do
import_functions = [{__MODULE__, [__inline_route__: 2, __user_id_field__: 2]}]
content = "<% import #{__MODULE__}, only: [__inline_route__: 2, __user_id_field__: 2] %>#{content}"

import_functions =
content =
# Credo will complain about unless statement but we want this first
# credo:disable-for-next-line
unless Pow.dependency_vsn_match?(:phoenix, "< 1.7.0") do
import_functions
content
else
# TODO: Remove when Phoenix 1.7 required
import_functions ++ [{Pow.Phoenix.HTML.FormTemplate, [render_form: 1, render_form: 2]}]
"<% import #{Pow.Phoenix.HTML.FormTemplate}, only: [render_form: 1, render_form: 2] %>#{content}"
end

content =
Expand All @@ -115,7 +115,6 @@ defmodule Pow.Phoenix.Template do
EEx.eval_string(
content,
[],
functions: import_functions,
file: __CALLER__.file,
line: __CALLER__.line + 1,
caller: __CALLER__)
Expand Down
4 changes: 2 additions & 2 deletions lib/pow/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ defmodule Pow.Plug do
def delete(conn, config), do: get_plug(config).do_delete(conn, config)

@spec no_config_error!() :: no_return()
defp no_config_error!,
defp no_config_error!(),
do: Config.raise_error("Pow configuration not found in connection. Please use a Pow plug that puts the Pow configuration in the plug connection.")

@spec no_plug_error!() :: no_return()
defp no_plug_error!,
defp no_plug_error!(),
do: Config.raise_error("Pow plug was not found in config. Please use a Pow plug that puts the `:plug` in the Pow configuration.")

@doc false
Expand Down
12 changes: 8 additions & 4 deletions lib/pow/plug/message_verifier.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ defmodule Pow.Plug.MessageVerifier do
|> KeyGenerator.generate(key, key_opts)
end

defp validate_secret_key_base(nil),
do: raise ArgumentError, "No conn.secret_key_base set"
defp validate_secret_key_base(secret_key_base) when byte_size(secret_key_base) < 64,
do: raise ArgumentError, "conn.secret_key_base has to be at least 64 bytes"
defp validate_secret_key_base(nil) do
raise ArgumentError, "No conn.secret_key_base set"
end

defp validate_secret_key_base(secret_key_base) when byte_size(secret_key_base) < 64 do
raise ArgumentError, "conn.secret_key_base has to be at least 64 bytes"
end

defp validate_secret_key_base(secret_key_base), do: secret_key_base

defp key_opts(config), do: Keyword.get(config, :key_generator_opts, [])
Expand Down
2 changes: 1 addition & 1 deletion lib/pow/plug/require_authenticated.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ defmodule Pow.Plug.RequireAuthenticated do
defp maybe_halt(_user, conn, _handler), do: conn

@spec raise_no_error_handler!() :: no_return()
defp raise_no_error_handler!,
defp raise_no_error_handler!(),
do: Config.raise_error("No :error_handler configuration option provided. It's required to set this when using #{inspect __MODULE__}.")
end
2 changes: 1 addition & 1 deletion lib/pow/plug/require_not_authenticated.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ defmodule Pow.Plug.RequireNotAuthenticated do
end

@spec raise_no_error_handler!() :: no_return()
defp raise_no_error_handler!,
defp raise_no_error_handler!(),
do: Config.raise_error("No :error_handler configuration option provided. It's required to set this when using #{inspect __MODULE__}.")
end
6 changes: 3 additions & 3 deletions lib/pow/store/backend/mnesia_cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,14 @@ defmodule Pow.Store.Backend.MnesiaCache do

# TODO: Remove by 1.1.0
{@mnesia_cache_tab, key, {_key, _value, _config, expire}}, invalidators when is_binary(key) and is_number(expire) ->
Logger.warn("Deleting old record in the mnesia cache: #{inspect key}")
Logger.warning("Deleting old record in the mnesia cache: #{inspect key}")

:mnesia.delete({@mnesia_cache_tab, key})

invalidators

{@mnesia_cache_tab, key, _value}, invalidators ->
Logger.warn("Found an unexpected record in the mnesia cache, please delete it: #{inspect key}")
Logger.warning("Found an unexpected record in the mnesia cache, please delete it: #{inspect key}")

invalidators
end,
Expand All @@ -494,7 +494,7 @@ defmodule Pow.Store.Backend.MnesiaCache do
end

@spec raise_ttl_error!() :: no_return()
defp raise_ttl_error!,
defp raise_ttl_error!(),
do: Config.raise_error("`:ttl` configuration option is required for #{inspect(__MODULE__)}")

# TODO: Remove by 1.1.0
Expand Down
4 changes: 2 additions & 2 deletions lib/pow/store/backend/mnesia_cache/unsplit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ defmodule Pow.Store.Backend.MnesiaCache.Unsplit do
end

defp reset_node(node, _config) do
Logger.warn("Resetting mnesia on #{inspect node()} and restarting the mnesia cache to connect to #{inspect node}")
Logger.warning("Resetting mnesia on #{inspect node()} and restarting the mnesia cache to connect to #{inspect node}")

:mnesia.stop()
:mnesia.delete_schema([node()])
Expand All @@ -183,7 +183,7 @@ defmodule Pow.Store.Backend.MnesiaCache.Unsplit do
:ok

false ->
Logger.warn("Detected a netsplit in the mnesia cluster with node #{inspect node}")
Logger.warning("Detected a netsplit in the mnesia cluster with node #{inspect node}")

heal(node, config)
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Pow.MixProject do

def application do
[
extra_applications: [:logger],
extra_applications: [:logger, :mnesia],
mod: {Pow.Application, []}
]
end
Expand Down
6 changes: 3 additions & 3 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"},
"credo": {:hex, :credo, "1.7.0", "6119bee47272e85995598ee04f2ebbed3e947678dee048d10b5feca139435f75", [:mix], [{:bunt, "~> 0.2.1", [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", "6839fcf63d1f0d1c0f450abc8564a57c43d644077ab96f2934563e68b8a769d7"},
"db_connection": {:hex, :db_connection, "2.4.3", "3b9aac9f27347ec65b271847e6baeb4443d8474289bd18c1d6f4de655b70c94d", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c127c15b0fa6cfb32eed07465e05da6c815b032508d4ed7c116122871df73c12"},
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
"earmark_parser": {:hex, :earmark_parser, "1.4.31", "a93921cdc6b9b869f519213d5bc79d9e218ba768d7270d46fdcf1c01bacff9e2", [:mix], [], "hexpm", "317d367ee0335ef037a87e46c91a2269fef6306413f731e8ec11fc45a7efd059"},
"ecto": {:hex, :ecto, "3.9.4", "3ee68e25dbe0c36f980f1ba5dd41ee0d3eb0873bccae8aeaf1a2647242bffa35", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "de5f988c142a3aa4ec18b85a4ec34a2390b65b24f02385c1144252ff6ff8ee75"},
"ecto": {:hex, :ecto, "3.9.6", "2f420c173efcb2e22fa4f8fc41e75e02b3c5bd4cffef12085cae5418c12e530d", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "df17bc06ba6f78a7b764e4a14ef877fe5f4499332c5a105ace11fe7013b72c84"},
"ecto_sql": {:hex, :ecto_sql, "3.9.2", "34227501abe92dba10d9c3495ab6770e75e79b836d114c41108a4bf2ce200ad5", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.9.2", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.6.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.16.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1eb5eeb4358fdbcd42eac11c1fbd87e3affd7904e639d77903c1358b2abd3f70"},
"ex_doc": {:hex, :ex_doc, "0.29.3", "f07444bcafb302db86e4f02d8bbcd82f2e881a0dcf4f3e4740e4b8128b9353f7", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "3dc6787d7b08801ec3b51e9bd26be5e8826fbf1a17e92d1ebc252e1a1c75bfe1"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"floki": {:hex, :floki, "0.34.2", "5fad07ef153b3b8ec110b6b155ec3780c4b2c4906297d0b4be1a7162d04a7e02", [:mix], [], "hexpm", "26b9d50f0f01796bc6be611ca815c5e0de034d2128e39cc9702eee6b66a4d1c8"},
"jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Application.put_env(:mnesia, :dir, 'tmp/mnesia')
Application.ensure_all_started(:mnesia)

Logger.configure(level: :warn)
Logger.configure(level: :warning)

:ok = Supervisor.terminate_child(Pow.Supervisor, Pow.Store.Backend.EtsCache)

Expand Down

0 comments on commit 856e997

Please sign in to comment.