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

Test with Elixir 1.18 #736

Merged
merged 7 commits into from
Jan 10, 2025
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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
- uses: actions/checkout@v3
- uses: erlef/setup-beam@v1
with:
otp-version: 26.0
elixir-version: 1.16
otp-version: 27.0
elixir-version: 1.18
- run: mix deps.get
- run: mix compile --warnings-as-errors
- run: mix credo --ignore design.tagtodo
Expand All @@ -40,11 +40,11 @@ jobs:
strategy:
matrix:
version:
- otp: 26.0
elixir: 1.16.0
- otp: 27.0
elixir: 1.18
os: ubuntu-latest
- otp: 22.0
elixir: 1.12.0
- otp: 24.0
elixir: 1.14
# It's necessary to run on ubunto 20.04 for OTP 20 - 25
# See https://github.com/erlef/setup-beam
os: ubuntu-20.04
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
with:
otp-version: 26.0
elixir-version: 1.16
otp-version: 27.0
elixir-version: 1.18
- run: mix deps.get
- run: mix hex.publish --yes
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

## v1.0.39 (TBA)

Now requires Elixir 1.14+.

### Bug fixes

* [`Pow.Extension.Ecto.Schema`] Fixed deprecation warning in Elixir 1.18
* [`Mix.Pow.Ecto.Migration`] Fixed compilation warning in Elixir 1.18
* [`Pow.Ecto.Schema`] Fixed issues caused by changes in Ecto 3.12.0

## v1.0.38 (2024-04-11)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ config :my_app, :pow,
cache_store_backend: Pow.Store.Backend.MnesiaCache
```

Remember to add `:mnesia` to your `:extra_applications` so it'll be available for your release build. Mnesia will write files to the current working directory. The path can be changed with `config :mnesia, dir: '/path/to/dir'`.
Remember to add `:mnesia` to your `:extra_applications` so it'll be available for your release build. Mnesia will write files to the current working directory. The path can be changed with `config :mnesia, dir: ~c"/path/to/dir"`.

The MnesiaCache requires write access. If you've got a read-only file system you should take a look at the [Redis cache backend store guide](guides/redis_cache_store_backend.md).

Expand Down
2 changes: 1 addition & 1 deletion guides/production_checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Update the config with `cache_store_backend: Pow.Store.Backend.MnesiaCache`.
Mnesia will store the database files in the directory `./Mnesia.NODE` in the current working directory where `NODE` is the node name. By default, this is `./Mnesia.nonode@nohost`. You may wish to change the location to a shared directory so you can roll deploys:

```elixir
config :mnesia, :dir, '/path/to/dir'
config :mnesia, :dir, ~c"/path/to/dir"
```

`:mnesia` should be added to `:extra_applications` in `mix.exs` for it to be included in releases.
Expand Down
11 changes: 5 additions & 6 deletions lib/mix/pow/ecto/migration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,11 @@ defmodule Mix.Pow.Ecto.Migration do
defp pad(i), do: to_string(i)

# TODO: Remove by 1.1.0 and only use Ecto 3.0
defp source_repo_priv(repo) do
mod =
if Pow.dependency_vsn_match?(:ecto, "< 3.0.0"),
do: Mix.Ecto,
else: Mix.EctoSQL
@mod Pow.dependency_vsn_match?(:ecto, "< 3.0.0") && Mix.Ecto || Mix.EctoSQL

Code.ensure_loaded(@mod)

mod.source_repo_priv(repo)
defp source_repo_priv(repo) do
@mod.source_repo_priv(repo)
end
end
23 changes: 17 additions & 6 deletions lib/pow/ecto/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,15 @@ defmodule Pow.Ecto.Schema do

@doc false
def __filter_new_fields__(fields, existing_fields) do
Enum.filter(fields, &not Enum.member?(existing_fields, {elem(&1, 0), elem(&1, 1)}))
Enum.reject(fields, fn {key, type, _opts} ->
Enum.find_value(existing_fields, fn
{^key, {^type, _writable}} -> true
{_key, {_type, _writable}} -> false
# TODO: Remove the below once Ecto >= 3.12.0 is required
{^key, ^type} -> true
{_key, _type} -> false
end)
end)
end

# TODO: Remove by 1.1.0
Expand Down Expand Up @@ -410,11 +418,14 @@ defmodule Pow.Ecto.Schema do
end

defp missing_field?(name, type, existing_fields) when is_atom(name) do
not Enum.any?(existing_fields, fn
{^name, ^type} -> true
{^name, e_type} -> not Type.primitive?(e_type)
_any -> false
end)
case Keyword.get(existing_fields, name) do
nil -> true
{^type, _writable} -> false
{e_type, _writable} -> Type.primitive?(e_type)
# TODO: Remove the below once Ecto >= 3.12.0 is required
^type -> false
e_type -> Type.primitive?(e_type)
end
end

defp warn_missing_fields_error(module, field_defs) do
Expand Down
2 changes: 1 addition & 1 deletion lib/pow/store/backend/mnesia_cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule Pow.Store.Backend.MnesiaCache do
Mnesia will create a `Mnesia.Node` directory in the current working directory
to write files to. This can be changed by setting the `-mnesia dir` config:

config :mnesia, dir: '/path/to/dir'
config :mnesia, dir: ~c"/path/to/dir"

The directory path should be accessible, otherwise MnesiaCache will crash on
startup.
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Pow.MixProject do
[
app: :pow,
version: @version,
elixir: "~> 1.12",
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
compilers: Mix.compilers(),
Expand Down
Loading
Loading