From 518a471189447ccea095fb34aa348d39c1fed690 Mon Sep 17 00:00:00 2001 From: Tiago Moraes Date: Sat, 14 Sep 2024 17:49:42 -0300 Subject: [PATCH] Add Elixir 1.17 and OTP 27 to CI, fixing warnings (#752) --- .github/workflows/ci.yml | 10 ++++++++-- .tool-versions | 2 ++ lib/mix/tasks/surface/surface.init/ex_patcher.ex | 5 ++--- lib/surface/catalogue/data.ex | 6 +++--- test/surface/components/link_test.exs | 6 +++--- 5 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 .tool-versions diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9aa7da00b..12ec2e059 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,8 +39,14 @@ jobs: run_plugin_tests: true run_integration_tests: true warnings_as_errors: true - - elixir: '1.16.0' - otp: '26.2.1' + - elixir: '1.17.0' + otp: '27.0.1' + check_formatted: true + run_plugin_tests: true + run_integration_tests: true + warnings_as_errors: true + - elixir: '1.17.0' + otp: '27.0.1' update_deps: true run_plugin_tests: true env: diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 000000000..ce0360e0e --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +erlang 27.0.1 +elixir 1.17.2-otp-27 diff --git a/lib/mix/tasks/surface/surface.init/ex_patcher.ex b/lib/mix/tasks/surface/surface.init/ex_patcher.ex index 620afb336..014bc703f 100644 --- a/lib/mix/tasks/surface/surface.init/ex_patcher.ex +++ b/lib/mix/tasks/surface/surface.init/ex_patcher.ex @@ -419,9 +419,8 @@ defmodule Mix.Tasks.Surface.Init.ExPatcher do end defp to_string_opts() do - "mix.exs" - |> Mix.Tasks.Format.formatter_opts_for_file() - |> Keyword.take([:line_length]) + {_formatter, opts} = Mix.Tasks.Format.formatter_for_file("mix.exs") + Keyword.take(opts, [:line_length]) end defp get_code_by_range(code, range) do diff --git a/lib/surface/catalogue/data.ex b/lib/surface/catalogue/data.ex index 32f7b8780..d6143c54b 100644 --- a/lib/surface/catalogue/data.ex +++ b/lib/surface/catalogue/data.ex @@ -184,7 +184,7 @@ defmodule Surface.Catalogue.Data do Access.at(value) end - def access_fun(from..to = range) when is_integer(from) and is_integer(to) do + def access_fun(from..to//1 = range) when is_integer(from) and is_integer(to) do slice(range) end @@ -244,14 +244,14 @@ defmodule Surface.Catalogue.Data do {:lists.reverse(gets), :lists.reverse(updates)} end - defp get_and_update_slice(list, from..to, next, updates, gets, -1) do + defp get_and_update_slice(list, from..to//1, next, updates, gets, -1) do list_length = length(list) from = normalize_range_bound(from, list_length) to = normalize_range_bound(to, list_length) get_and_update_slice(list, from..to, next, updates, gets, 0) end - defp get_and_update_slice([head | rest], from..to = range, next, updates, gets, index) do + defp get_and_update_slice([head | rest], from..to//1 = range, next, updates, gets, index) do new_index = index + 1 if index >= from and index <= to do diff --git a/test/surface/components/link_test.exs b/test/surface/components/link_test.exs index 65815e69a..2736f9cdd 100644 --- a/test/surface/components/link_test.exs +++ b/test/surface/components/link_test.exs @@ -184,14 +184,14 @@ defmodule Surface.Components.LinkTest do html = render_surface(do: ~F[)"}} />]) assert html =~ ~s[foo] - html = render_surface(do: ~F[)'}} />]) + html = render_surface(do: ~F[)"}} />]) assert html =~ ~s[foo] html = render_surface(do: ~F[)"}}} />]) assert html =~ ~s[foo] - html = render_surface(do: ~F[)'}}} />]) + html = render_surface(do: ~F[)"}}} />]) assert html =~ ~s[foo] end @@ -212,7 +212,7 @@ defmodule Surface.Components.LinkTest do end assert_raise ArgumentError, ~r"unsupported scheme given to ", fn -> - render_surface(do: ~F[)'}} />]) + render_surface(do: ~F[)"}} />]) end end end