From 53d7b205e8539795f57ded3b8c4329f0f9bbee22 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Mon, 12 May 2025 16:17:32 +0200 Subject: [PATCH 01/18] Elixir 1.18 <%# deprecated syntax warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit warning: <%# is deprecated, use <%!-- or add a space between <% and # instead │ 5 │ <%# Note: using hidden input with `unchecked_value` in order to distinguish user's empty selection from `scope` param being omitted %> │ ~ │ └─ lib/pleroma/web/templates/o_auth/o_auth/_scopes.html.eex:5: (file) --- .../web/templates/email/digest.html.eex | 20 +++++++++---------- .../templates/email/new_users_digest.html.eex | 10 +++++----- .../templates/layout/email_styled.html.eex | 4 ++-- .../templates/o_auth/o_auth/_scopes.html.eex | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/pleroma/web/templates/email/digest.html.eex b/lib/pleroma/web/templates/email/digest.html.eex index 1efc76e1a..d2918bc6f 100644 --- a/lib/pleroma/web/templates/email/digest.html.eex +++ b/lib/pleroma/web/templates/email/digest.html.eex @@ -231,8 +231,8 @@ <%= for %{data: mention, object: object, from: from} <- @mentions do %> - <%# mention START %> - <%# user card START %> + <% # mention START %> + <% # user card START %>
@@ -291,7 +291,7 @@
- <%# user card END %> + <% # user card END %>
- <%# mention END %> + <% # mention END %> <% end %> <%= if @followers != [] do %> - <%# new followers header START %> + <% # new followers header START %>
@@ -397,10 +397,10 @@
- <%# new followers header END %> + <% # new followers header END %> <%= for %{data: follow, from: from} <- @followers do %> - <%# user card START %> + <% # user card START %>
@@ -459,13 +459,13 @@
- <%# user card END %> + <% # user card END %> <% end %> <% end %> - <%# divider start %> + <% # divider start %>
@@ -514,7 +514,7 @@
- <%# divider end %> + <% # divider end %>
diff --git a/lib/pleroma/web/templates/email/new_users_digest.html.eex b/lib/pleroma/web/templates/email/new_users_digest.html.eex index 40d9b8381..78b8ac4f9 100644 --- a/lib/pleroma/web/templates/email/new_users_digest.html.eex +++ b/lib/pleroma/web/templates/email/new_users_digest.html.eex @@ -1,5 +1,5 @@ <%= for {user, total_statuses, latest_status} <- @users_and_statuses do %> - <%# user card START %> + <% # user card START %>
@@ -60,7 +60,7 @@
- <%# user card END %> + <% # user card END %> <%= if latest_status do %>
@@ -104,7 +104,7 @@
<% end %> - <%# divider start %> + <% # divider start %>
@@ -153,6 +153,6 @@
- <%# divider end %> - <%# user card END %> + <% # divider end %> + <% # user card END %> <% end %> diff --git a/lib/pleroma/web/templates/layout/email_styled.html.eex b/lib/pleroma/web/templates/layout/email_styled.html.eex index 82cabd889..a1ed4ece3 100644 --- a/lib/pleroma/web/templates/layout/email_styled.html.eex +++ b/lib/pleroma/web/templates/layout/email_styled.html.eex @@ -111,7 +111,7 @@ - <%# header %> + <% # header %>
@@ -145,7 +145,7 @@
- <%# title %> + <% # title %> <%= if @title do %>
<%= for scope <- @available_scopes do %> - <%# Note: using hidden input with `unchecked_value` in order to distinguish user's empty selection from `scope` param being omitted %> + <% # Note: using hidden input with `unchecked_value` in order to distinguish user's empty selection from `scope` param being omitted %> <%= if scope in @scopes do %>
<%= checkbox @form, :"scope_#{scope}", value: scope in @scopes && scope, checked_value: scope, unchecked_value: "", name: "authorization[scope][]" %> From 25e7b12a6bd870d96becbd79167818147f6b501c Mon Sep 17 00:00:00 2001 From: Phantasm Date: Mon, 12 May 2025 17:21:41 +0200 Subject: [PATCH 02/18] Elixir 1.18 Remove seemingly unneeded cond MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit warning: this clause in cond will always match: <<"#", name::binary>> since it has type: binary() where "name" was given the type: %{"type" => "Hashtag", "name" => name} = data typing violation found at: │ 55 │ "#" <> name -> name │ ~ │ └─ lib/pleroma/web/activity_pub/object_validators/tag_validator.ex:55:21: Pleroma.Web.ActivityPub.ObjectValidators.TagValidator.changeset/2 --- .../web/activity_pub/object_validators/tag_validator.ex | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex b/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex index 47cf7b415..411517045 100644 --- a/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex @@ -50,12 +50,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidator do end def changeset(struct, %{"type" => "Hashtag", "name" => name} = data) do - name = - cond do - "#" <> name -> name - name -> name - end - |> String.downcase() + name = String.downcase(name) data = Map.put(data, "name", name) From 59d17a5b20bac485c189bcfdeafffe7fb06c8277 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Mon, 12 May 2025 17:23:33 +0200 Subject: [PATCH 03/18] Elixir 1.18 Move Update activity validation to separate function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit warning: Pleroma.Web.ActivityPub.ObjectValidators.AcceptRejectValidator.cast_and_validate/2 is undefined or private. Did you mean: * cast_and_validate/1 │ 227 │ validator == UpdateValidator -> fn o -> validator.cast_and_validate(o, meta) end │ ~ │ └─ lib/pleroma/web/activity_pub/object_validator.ex:227:57: Pleroma.Web.ActivityPub.ObjectValidator.validate/2 --- .../web/activity_pub/object_validator.ex | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/pleroma/web/activity_pub/object_validator.ex b/lib/pleroma/web/activity_pub/object_validator.ex index ee12f3ebf..17652a0de 100644 --- a/lib/pleroma/web/activity_pub/object_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validator.ex @@ -200,14 +200,13 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do end def validate(%{"type" => type} = object, meta) - when type in ~w[Accept Reject Follow Update Like EmojiReact Announce + when type in ~w[Accept Reject Follow Like EmojiReact Announce ChatMessage Answer] do validator = case type do "Accept" -> AcceptRejectValidator "Reject" -> AcceptRejectValidator "Follow" -> FollowValidator - "Update" -> UpdateValidator "Like" -> LikeValidator "EmojiReact" -> EmojiReactValidator "Announce" -> AnnounceValidator @@ -215,16 +214,19 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do "Answer" -> AnswerValidator end - cast_func = - if type == "Update" do - fn o -> validator.cast_and_validate(o, meta) end - else - fn o -> validator.cast_and_validate(o) end - end - with {:ok, object} <- object - |> cast_func.() + |> validator.cast_and_validate() + |> Ecto.Changeset.apply_action(:insert) do + object = stringify_keys(object) + {:ok, object, meta} + end + end + + def validate(%{"type" => type} = object, meta) when type == "Update" do + with {:ok, object} <- + object + |> UpdateValidator.cast_and_validate(meta) |> Ecto.Changeset.apply_action(:insert) do object = stringify_keys(object) {:ok, object, meta} From 63cbc1208d2654ed174f7d319334aca3e08f69d7 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Mon, 12 May 2025 17:25:38 +0200 Subject: [PATCH 04/18] Elixir 1.18 Replace Tuple.append/2 with Tuple.insert_at/3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit warning: Tuple.append/2 is deprecated. Use insert_at instead │ 305 │ Enum.reduce(entity, {}, &Tuple.append(&2, to_elixir_types(&1))) │ ~ │ └─ lib/pleroma/config_db.ex:305:36: Pleroma.ConfigDB.to_elixir_types/1 --- lib/pleroma/config_db.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/config_db.ex b/lib/pleroma/config_db.ex index 89d3050d6..e9990fa35 100644 --- a/lib/pleroma/config_db.ex +++ b/lib/pleroma/config_db.ex @@ -302,7 +302,7 @@ defmodule Pleroma.ConfigDB do end def to_elixir_types(%{"tuple" => entity}) do - Enum.reduce(entity, {}, &Tuple.append(&2, to_elixir_types(&1))) + Enum.reduce(entity, {}, &Tuple.insert_at(&2, tuple_size(&2), to_elixir_types(&1))) end def to_elixir_types(entity) when is_map(entity) do From 5addbf39fbdc67d93f6b8605ce02157e14c3edb1 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Tue, 13 May 2025 00:01:34 +0200 Subject: [PATCH 05/18] Elixir 1.18 Deal with :warnings_as_errors deprecation in compiler_options/1 warning: :warnings_as_errors is deprecated as part of Code.get_compiler_option/1 (elixir 1.18.3) lib/code.ex:1597: Code.get_compiler_option/1 (elixir 1.18.3) lib/code.ex:1572: anonymous fn/2 in Code.compiler_options/1 (elixir 1.18.3) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3 (elixir 1.18.3) lib/code.ex:1571: Code.compiler_options/1 (pleroma 2.9.1-77-g8ec49c59-elixir-1-18+test) lib/pleroma/application.ex:104: Pleroma.Application.start/2 (kernel 10.2.6) application_master.erl:295: :application_master.start_it_old/4 warning: :warnings_as_errors is deprecated as part of Code.put_compiler_option/2, instead you must pass it as a --warnings-as-errors flag. If you need to set it as a default in a mix task, you can also set it under aliases: [compile: "compile --warnings-as-errors"] (elixir 1.18.3) lib/code.ex:1710: Code.put_compiler_option/2 (elixir 1.18.3) lib/code.ex:1573: anonymous fn/2 in Code.compiler_options/1 (elixir 1.18.3) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3 (elixir 1.18.3) lib/code.ex:1571: Code.compiler_options/1 (pleroma 2.9.1-77-g8ec49c59-elixir-1-18+test) lib/pleroma/application.ex:104: Pleroma.Application.start/2 (kernel 10.2.6) application_master.erl:295: :application_master.start_it_old/4 --- lib/mix/tasks/pleroma/test_runner.ex | 2 +- lib/pleroma/application.ex | 18 +++++++++++++++--- mix.exs | 2 +- test/test_helper.exs | 2 -- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/mix/tasks/pleroma/test_runner.ex b/lib/mix/tasks/pleroma/test_runner.ex index 69fefb001..d9cf0d445 100644 --- a/lib/mix/tasks/pleroma/test_runner.ex +++ b/lib/mix/tasks/pleroma/test_runner.ex @@ -4,7 +4,7 @@ defmodule Mix.Tasks.Pleroma.TestRunner do use Mix.Task def run(args \\ []) do - case System.cmd("mix", ["test"] ++ args, into: IO.stream(:stdio, :line)) do + case System.cmd("mix", ["test", "--warnings-as-errors"] ++ args, into: IO.stream(:stdio, :line)) do {_, 0} -> :ok diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index 497623ee1..fd3c66c63 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -43,9 +43,6 @@ defmodule Pleroma.Application do # every time the application is restarted, so we disable module # conflicts at runtime Code.compiler_options(ignore_module_conflict: true) - # Disable warnings_as_errors at runtime, it breaks Phoenix live reload - # due to protocol consolidation warnings - Code.compiler_options(warnings_as_errors: false) Pleroma.Telemetry.Logger.attach() Config.Holder.save_default() Pleroma.HTML.compile_scrubbers() @@ -93,6 +90,21 @@ defmodule Pleroma.Application do end end + # Disable warnings_as_errors at runtime, it breaks Phoenix live reload + # due to protocol consolidation warnings + # :warnings_as_errors is deprecated via Code.compiler_options/2 since 1.18 + if elixir_version = System.version() do + [major, minor] = + elixir_version + |> String.split(".") + |> Enum.map(&String.to_integer/1) + |> Enum.take(2) + + if major == 1 and minor < 18 do + Code.compiler_options(warnings_as_errors: false) + end + end + # Define workers and child supervisors to be supervised children = [ diff --git a/mix.exs b/mix.exs index 808a2b12c..dc6c2492f 100644 --- a/mix.exs +++ b/mix.exs @@ -236,7 +236,7 @@ defmodule Pleroma.Mixfile do "ecto.rollback": ["pleroma.ecto.rollback"], "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], "ecto.reset": ["ecto.drop", "ecto.setup"], - test: ["ecto.create --quiet", "ecto.migrate", "test"], + test: ["ecto.create --quiet", "ecto.migrate", "test --warnings-as-errors"], docs: ["pleroma.docs", "docs"], analyze: ["credo --strict --only=warnings,todo,fixme,consistency,readability"], copyright: &add_copyright/1, diff --git a/test/test_helper.exs b/test/test_helper.exs index 94661353b..dc6c05a74 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -2,8 +2,6 @@ # Copyright © 2017-2022 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only -Code.put_compiler_option(:warnings_as_errors, true) - ExUnit.configure(capture_log: true, max_cases: System.schedulers_online()) ExUnit.start(exclude: [:federated]) From 7c13abb3d98fdac4fdab67828e7fe509ad868431 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Wed, 14 May 2025 16:37:43 +0200 Subject: [PATCH 06/18] Elixir 1.18 Use NaiveDateTime.compare/2 instead of <>= comparisons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit warning: comparison with structs found: left <= right given types: dynamic() <= dynamic(%NaiveDateTime{}) where "left" (context ExUnit.Assertions) was given the type: # type: dynamic() # from: test/pleroma/web/plugs/user_tracking_plug_test.exs:25 left = user.last_active_at where "right" (context ExUnit.Assertions) was given the type: # type: dynamic(%NaiveDateTime{}) # from: test/pleroma/web/plugs/user_tracking_plug_test.exs:25 right = NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) Comparison operators (>, <, >=, <=, min, and max) perform structural and not semantic comparison. Comparing with a struct won't give meaningful results. Structs that can be compared typically define a compare/2 function within their modules that can be used for semantic comparison. typing violation found at: │ 25 │ assert user.last_active_at <= NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) │ ~ │ └─ test/pleroma/web/plugs/user_tracking_plug_test.exs:25:32: Pleroma.Web.Plugs.UserTrackingPlugTest."test updates last_active_at for a new user"/1 --- test/pleroma/user_test.exs | 10 +++++----- test/pleroma/web/plugs/user_tracking_plug_test.exs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/pleroma/user_test.exs b/test/pleroma/user_test.exs index 176e70ef9..79a480f85 100644 --- a/test/pleroma/user_test.exs +++ b/test/pleroma/user_test.exs @@ -2669,8 +2669,8 @@ defmodule Pleroma.UserTest do assert {:ok, user} = User.update_last_active_at(user) - assert user.last_active_at >= test_started_at - assert user.last_active_at <= NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) + assert NaiveDateTime.compare(user.last_active_at, test_started_at) in [:gt, :eq] + assert NaiveDateTime.compare(user.last_active_at, NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second)) in [:lt, :eq] last_active_at = NaiveDateTime.utc_now() @@ -2681,11 +2681,11 @@ defmodule Pleroma.UserTest do user |> cast(%{last_active_at: last_active_at}, [:last_active_at]) |> User.update_and_set_cache() + assert NaiveDateTime.compare(user.last_active_at, last_active_at) == :eq - assert user.last_active_at == last_active_at assert {:ok, user} = User.update_last_active_at(user) - assert user.last_active_at >= test_started_at - assert user.last_active_at <= NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) + assert NaiveDateTime.compare(user.last_active_at, test_started_at) in [:gt, :eq] + assert NaiveDateTime.compare(user.last_active_at, NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second)) in [:lt, :eq] end test "active_user_count/1" do diff --git a/test/pleroma/web/plugs/user_tracking_plug_test.exs b/test/pleroma/web/plugs/user_tracking_plug_test.exs index 742f04fea..5c67a7735 100644 --- a/test/pleroma/web/plugs/user_tracking_plug_test.exs +++ b/test/pleroma/web/plugs/user_tracking_plug_test.exs @@ -21,8 +21,8 @@ defmodule Pleroma.Web.Plugs.UserTrackingPlugTest do |> assign(:user, user) |> UserTrackingPlug.call(%{}) - assert user.last_active_at >= test_started_at - assert user.last_active_at <= NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) + assert NaiveDateTime.compare(user.last_active_at, test_started_at) in [:gt, :eq] + assert NaiveDateTime.compare(user.last_active_at, NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second)) in [:lt, :eq] end test "doesn't update last_active_at if it was updated recently", %{conn: conn} do @@ -38,7 +38,7 @@ defmodule Pleroma.Web.Plugs.UserTrackingPlugTest do |> assign(:user, user) |> UserTrackingPlug.call(%{}) - assert user.last_active_at == last_active_at + assert NaiveDateTime.compare(user.last_active_at, last_active_at) == :eq end test "skips updating last_active_at if user ID is nil", %{conn: conn} do From af81f7bf82ff4ee0ed2f5794cdf4e28a5a43eca2 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Wed, 14 May 2025 17:00:19 +0200 Subject: [PATCH 07/18] Don't use deprecated function invocation syntax warning: using map.field notation (without parentheses) to invoke function TranslationMock.configured?() is deprecated, you must add parentheses instead: remote.function() --- lib/pleroma/language/language_detector.ex | 4 ++-- lib/pleroma/language/translation.ex | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/language/language_detector.ex b/lib/pleroma/language/language_detector.ex index 16e2d4faa..68d243562 100644 --- a/lib/pleroma/language/language_detector.ex +++ b/lib/pleroma/language/language_detector.ex @@ -12,7 +12,7 @@ defmodule Pleroma.Language.LanguageDetector do def configured? do provider = get_provider() - !!provider and provider.configured? + !!provider and provider.configured?() end def missing_dependencies do @@ -41,7 +41,7 @@ defmodule Pleroma.Language.LanguageDetector do text = prepare_text(text) word_count = text |> String.split(~r/\s+/) |> Enum.count() - if word_count < @words_threshold or !provider or !provider.configured? do + if word_count < @words_threshold or !provider or !provider.configured?() do nil else with language <- provider.detect(text), diff --git a/lib/pleroma/language/translation.ex b/lib/pleroma/language/translation.ex index 3706e76eb..64f115ed8 100644 --- a/lib/pleroma/language/translation.ex +++ b/lib/pleroma/language/translation.ex @@ -8,7 +8,7 @@ defmodule Pleroma.Language.Translation do def configured? do provider = get_provider() - !!provider and provider.configured? + !!provider and provider.configured?() end def missing_dependencies do From a0dfa12b78d071164c13e88d23336a60d9bfa9a8 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Sat, 24 May 2025 21:59:24 +0200 Subject: [PATCH 08/18] Elixir 1.18 Update supported versions for Erlang OTP and Elixir --- docs/installation/generic_dependencies.include | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/installation/generic_dependencies.include b/docs/installation/generic_dependencies.include index 9f07f62c6..769347a3c 100644 --- a/docs/installation/generic_dependencies.include +++ b/docs/installation/generic_dependencies.include @@ -1,8 +1,8 @@ ## Required dependencies * PostgreSQL >=11.0 -* Elixir >=1.14.0 <1.17 -* Erlang OTP >=23.0.0 (supported: <27) +* Elixir >=1.14.0 <1.19 +* Erlang OTP >=23.0.0 (supported: <28) * git * file / libmagic * gcc or clang From 2b513fd450d0caab4ccfc7bdb8fa4c6a84764978 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Sat, 24 May 2025 22:03:23 +0200 Subject: [PATCH 09/18] Elixir 1.18 add changelog --- changelog.d/elixir-1-18.fix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/elixir-1-18.fix diff --git a/changelog.d/elixir-1-18.fix b/changelog.d/elixir-1-18.fix new file mode 100644 index 000000000..d4d5a3493 --- /dev/null +++ b/changelog.d/elixir-1-18.fix @@ -0,0 +1 @@ +Elixir 1.18: Fixed warnings and new deprecations From 286204913d6a1e65a8f75fc7277d2003827f9857 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Sat, 24 May 2025 22:17:38 +0200 Subject: [PATCH 10/18] Replace Elixir 1.17 with 1.18 for build unit-testing pipelines --- .gitlab-ci.yml | 8 ++++---- ci/elixir-1.18.3-otp-27/Dockerfile | 8 ++++++++ ci/elixir-1.18.3-otp-27/build_and_push.sh | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 ci/elixir-1.18.3-otp-27/Dockerfile create mode 100755 ci/elixir-1.18.3-otp-27/build_and_push.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 675d0e067..29ee24a05 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -79,12 +79,12 @@ build-1.14.5-otp-25: script: - mix compile --force -build-1.17.1-otp-26: +build-1.18.3-otp-27: extends: - .build_changes_policy - .using-ci-base stage: build - image: git.pleroma.social:5050/pleroma/pleroma/ci-base:elixir-1.17.1-otp-26 + image: git.pleroma.social:5050/pleroma/pleroma/ci-base:elixir-1.18.3-otp-27 script: - mix compile --force @@ -142,12 +142,12 @@ unit-testing-1.14.5-otp-25: coverage_format: cobertura path: coverage.xml -unit-testing-1.17.1-otp-26: +unit-testing-1.18.3-otp-27: extends: - .build_changes_policy - .using-ci-base stage: test - image: git.pleroma.social:5050/pleroma/pleroma/ci-base:elixir-1.17.1-otp-26 + image: git.pleroma.social:5050/pleroma/pleroma/ci-base:elixir-1.18.3-otp-27 cache: *testing_cache_policy services: *testing_services script: *testing_script diff --git a/ci/elixir-1.18.3-otp-27/Dockerfile b/ci/elixir-1.18.3-otp-27/Dockerfile new file mode 100644 index 000000000..2b42aa90d --- /dev/null +++ b/ci/elixir-1.18.3-otp-27/Dockerfile @@ -0,0 +1,8 @@ +FROM elixir:1.18.3-otp-27 + +# Single RUN statement, otherwise intermediate images are created +# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run +RUN apt-get update &&\ + apt-get install -y libmagic-dev cmake libimage-exiftool-perl ffmpeg &&\ + mix local.hex --force &&\ + mix local.rebar --force diff --git a/ci/elixir-1.18.3-otp-27/build_and_push.sh b/ci/elixir-1.18.3-otp-27/build_and_push.sh new file mode 100755 index 000000000..8a564fbf2 --- /dev/null +++ b/ci/elixir-1.18.3-otp-27/build_and_push.sh @@ -0,0 +1 @@ +docker buildx build --platform linux/amd64,linux/arm64 -t git.pleroma.social:5050/pleroma/pleroma/ci-base:elixir-1.18.3-otp-27 --push . From 9710063fdc92ca3df9005ef57f678fd78680a4f0 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Sun, 1 Jun 2025 21:25:38 +0000 Subject: [PATCH 11/18] Apply suggestions to 2 files. --- lib/pleroma/application.ex | 12 ++---------- .../activity_pub/object_validators/tag_validator.ex | 7 ++++++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index fd3c66c63..57ee7ce1f 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -93,16 +93,8 @@ defmodule Pleroma.Application do # Disable warnings_as_errors at runtime, it breaks Phoenix live reload # due to protocol consolidation warnings # :warnings_as_errors is deprecated via Code.compiler_options/2 since 1.18 - if elixir_version = System.version() do - [major, minor] = - elixir_version - |> String.split(".") - |> Enum.map(&String.to_integer/1) - |> Enum.take(2) - - if major == 1 and minor < 18 do - Code.compiler_options(warnings_as_errors: false) - end + if Version.compare(System.version(), "1.18.0") == :lt do + Code.compiler_options(warnings_as_errors: false) end # Define workers and child supervisors to be supervised diff --git a/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex b/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex index 411517045..5ce9ab36a 100644 --- a/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex @@ -50,7 +50,12 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidator do end def changeset(struct, %{"type" => "Hashtag", "name" => name} = data) do - name = String.downcase(name) + name = + case name do + "#" <> name -> name + name -> name + end + data = Map.put(data, "name", name) From 0e53cb494038b45d8281b9daba11a4a9dae2115b Mon Sep 17 00:00:00 2001 From: Phantasm Date: Mon, 2 Jun 2025 23:04:45 +0200 Subject: [PATCH 12/18] Remove unreachable checks for OTP < 22.2 OTP 22 is no longer supported at all. Pleroma's dependencies cannot be built with Elixir 1.13 and Elixir 1.14 cannot be built with OTP 22 since it depends on features not present in OTP 22. Hence why these checks cannot get triggered anymore. --- lib/pleroma/application.ex | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index 57ee7ce1f..1df38b0bd 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -68,27 +68,6 @@ defmodule Pleroma.Application do Finch.start_link(name: MyFinch) end - if adapter == Tesla.Adapter.Gun do - if version = Pleroma.OTPVersion.version() do - [major, minor] = - version - |> String.split(".") - |> Enum.map(&String.to_integer/1) - |> Enum.take(2) - - if (major == 22 and minor < 2) or major < 22 do - raise " - !!!OTP VERSION WARNING!!! - You are using gun adapter with OTP version #{version}, which doesn't support correct handling of unordered certificates chains. Please update your Erlang/OTP to at least 22.2. - " - end - else - raise " - !!!OTP VERSION WARNING!!! - To support correct handling of unordered certificates chains - OTP version must be > 22.2. - " - end - end # Disable warnings_as_errors at runtime, it breaks Phoenix live reload # due to protocol consolidation warnings From 1be8deda73add2dde23127be1f4da802dcb25b45 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Tue, 3 Jun 2025 23:17:39 +0200 Subject: [PATCH 13/18] Remove Pleroma.OTPVersion module Its last use was a check in lib/application.ex that was removed in commit 0e53cb494038b45d8281b9daba11a4a9dae2115b Major OTP version can be fetched with System.otp_release/0. If checking against minor versions and patch levels is needed, revert this commit since it uses the recommended way of getting a full OTP version string. --- lib/pleroma/otp_version.ex | 28 ----------------- test/fixtures/warnings/otp_version/21.1 | 1 - test/fixtures/warnings/otp_version/22.1 | 1 - test/fixtures/warnings/otp_version/22.4 | 1 - test/fixtures/warnings/otp_version/23.0 | 1 - test/pleroma/otp_version_test.exs | 42 ------------------------- 6 files changed, 74 deletions(-) delete mode 100644 lib/pleroma/otp_version.ex delete mode 100644 test/fixtures/warnings/otp_version/21.1 delete mode 100644 test/fixtures/warnings/otp_version/22.1 delete mode 100644 test/fixtures/warnings/otp_version/22.4 delete mode 100644 test/fixtures/warnings/otp_version/23.0 delete mode 100644 test/pleroma/otp_version_test.exs diff --git a/lib/pleroma/otp_version.ex b/lib/pleroma/otp_version.ex deleted file mode 100644 index 80b15275a..000000000 --- a/lib/pleroma/otp_version.ex +++ /dev/null @@ -1,28 +0,0 @@ -# Pleroma: A lightweight social networking server -# Copyright © 2017-2022 Pleroma Authors -# SPDX-License-Identifier: AGPL-3.0-only - -defmodule Pleroma.OTPVersion do - @spec version() :: String.t() | nil - def version do - # OTP Version https://erlang.org/doc/system_principles/versions.html#otp-version - [ - Path.join(:code.root_dir(), "OTP_VERSION"), - Path.join([:code.root_dir(), "releases", :erlang.system_info(:otp_release), "OTP_VERSION"]) - ] - |> get_version_from_files() - end - - @spec get_version_from_files([Path.t()]) :: String.t() | nil - def get_version_from_files([]), do: nil - - def get_version_from_files([path | paths]) do - if File.exists?(path) do - path - |> File.read!() - |> String.replace(~r/\r|\n|\s/, "") - else - get_version_from_files(paths) - end - end -end diff --git a/test/fixtures/warnings/otp_version/21.1 b/test/fixtures/warnings/otp_version/21.1 deleted file mode 100644 index 90cd64c4f..000000000 --- a/test/fixtures/warnings/otp_version/21.1 +++ /dev/null @@ -1 +0,0 @@ -21.1 \ No newline at end of file diff --git a/test/fixtures/warnings/otp_version/22.1 b/test/fixtures/warnings/otp_version/22.1 deleted file mode 100644 index d9b314368..000000000 --- a/test/fixtures/warnings/otp_version/22.1 +++ /dev/null @@ -1 +0,0 @@ -22.1 \ No newline at end of file diff --git a/test/fixtures/warnings/otp_version/22.4 b/test/fixtures/warnings/otp_version/22.4 deleted file mode 100644 index 1da8ccd28..000000000 --- a/test/fixtures/warnings/otp_version/22.4 +++ /dev/null @@ -1 +0,0 @@ -22.4 \ No newline at end of file diff --git a/test/fixtures/warnings/otp_version/23.0 b/test/fixtures/warnings/otp_version/23.0 deleted file mode 100644 index 4266d8634..000000000 --- a/test/fixtures/warnings/otp_version/23.0 +++ /dev/null @@ -1 +0,0 @@ -23.0 \ No newline at end of file diff --git a/test/pleroma/otp_version_test.exs b/test/pleroma/otp_version_test.exs deleted file mode 100644 index 21701d5a8..000000000 --- a/test/pleroma/otp_version_test.exs +++ /dev/null @@ -1,42 +0,0 @@ -# Pleroma: A lightweight social networking server -# Copyright © 2017-2022 Pleroma Authors -# SPDX-License-Identifier: AGPL-3.0-only - -defmodule Pleroma.OTPVersionTest do - use ExUnit.Case, async: true - - alias Pleroma.OTPVersion - - describe "check/1" do - test "22.4" do - assert OTPVersion.get_version_from_files(["test/fixtures/warnings/otp_version/22.4"]) == - "22.4" - end - - test "22.1" do - assert OTPVersion.get_version_from_files(["test/fixtures/warnings/otp_version/22.1"]) == - "22.1" - end - - test "21.1" do - assert OTPVersion.get_version_from_files(["test/fixtures/warnings/otp_version/21.1"]) == - "21.1" - end - - test "23.0" do - assert OTPVersion.get_version_from_files(["test/fixtures/warnings/otp_version/23.0"]) == - "23.0" - end - - test "with nonexistent file" do - assert OTPVersion.get_version_from_files([ - "test/fixtures/warnings/otp_version/non-exising", - "test/fixtures/warnings/otp_version/22.4" - ]) == "22.4" - end - - test "empty paths" do - assert OTPVersion.get_version_from_files([]) == nil - end - end -end From 6fa4f08e67a2ebebca2337259e1a5b5b6862b5ef Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Wed, 4 Jun 2025 11:43:18 +0300 Subject: [PATCH 14/18] Add back String.downcase that was accidentally removed from tag_validator --- lib/pleroma/web/activity_pub/object_validators/tag_validator.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex b/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex index 5ce9ab36a..91aeb9dd7 100644 --- a/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex @@ -55,7 +55,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidator do "#" <> name -> name name -> name end - + |> String.downcase() data = Map.put(data, "name", name) From d95e1066b9858997c9137097bf00ddc2fa57e5e1 Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Wed, 4 Jun 2025 12:03:54 +0300 Subject: [PATCH 15/18] Fix formatting --- lib/mix/tasks/pleroma/test_runner.ex | 4 +++- lib/pleroma/application.ex | 1 - test/pleroma/user_test.exs | 13 +++++++++++-- test/pleroma/web/plugs/user_tracking_plug_test.exs | 6 +++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/mix/tasks/pleroma/test_runner.ex b/lib/mix/tasks/pleroma/test_runner.ex index d9cf0d445..67820247e 100644 --- a/lib/mix/tasks/pleroma/test_runner.ex +++ b/lib/mix/tasks/pleroma/test_runner.ex @@ -4,7 +4,9 @@ defmodule Mix.Tasks.Pleroma.TestRunner do use Mix.Task def run(args \\ []) do - case System.cmd("mix", ["test", "--warnings-as-errors"] ++ args, into: IO.stream(:stdio, :line)) do + case System.cmd("mix", ["test", "--warnings-as-errors"] ++ args, + into: IO.stream(:stdio, :line) + ) do {_, 0} -> :ok diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index 1df38b0bd..8e1c5de0d 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -68,7 +68,6 @@ defmodule Pleroma.Application do Finch.start_link(name: MyFinch) end - # Disable warnings_as_errors at runtime, it breaks Phoenix live reload # due to protocol consolidation warnings # :warnings_as_errors is deprecated via Code.compiler_options/2 since 1.18 diff --git a/test/pleroma/user_test.exs b/test/pleroma/user_test.exs index 79a480f85..44e2d0d65 100644 --- a/test/pleroma/user_test.exs +++ b/test/pleroma/user_test.exs @@ -2670,7 +2670,11 @@ defmodule Pleroma.UserTest do assert {:ok, user} = User.update_last_active_at(user) assert NaiveDateTime.compare(user.last_active_at, test_started_at) in [:gt, :eq] - assert NaiveDateTime.compare(user.last_active_at, NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second)) in [:lt, :eq] + + assert NaiveDateTime.compare( + user.last_active_at, + NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) + ) in [:lt, :eq] last_active_at = NaiveDateTime.utc_now() @@ -2681,11 +2685,16 @@ defmodule Pleroma.UserTest do user |> cast(%{last_active_at: last_active_at}, [:last_active_at]) |> User.update_and_set_cache() + assert NaiveDateTime.compare(user.last_active_at, last_active_at) == :eq assert {:ok, user} = User.update_last_active_at(user) assert NaiveDateTime.compare(user.last_active_at, test_started_at) in [:gt, :eq] - assert NaiveDateTime.compare(user.last_active_at, NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second)) in [:lt, :eq] + + assert NaiveDateTime.compare( + user.last_active_at, + NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) + ) in [:lt, :eq] end test "active_user_count/1" do diff --git a/test/pleroma/web/plugs/user_tracking_plug_test.exs b/test/pleroma/web/plugs/user_tracking_plug_test.exs index 5c67a7735..cd9c66448 100644 --- a/test/pleroma/web/plugs/user_tracking_plug_test.exs +++ b/test/pleroma/web/plugs/user_tracking_plug_test.exs @@ -22,7 +22,11 @@ defmodule Pleroma.Web.Plugs.UserTrackingPlugTest do |> UserTrackingPlug.call(%{}) assert NaiveDateTime.compare(user.last_active_at, test_started_at) in [:gt, :eq] - assert NaiveDateTime.compare(user.last_active_at, NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second)) in [:lt, :eq] + + assert NaiveDateTime.compare( + user.last_active_at, + NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) + ) in [:lt, :eq] end test "doesn't update last_active_at if it was updated recently", %{conn: conn} do From 7ddae61414a2e0f04560d2afe46dc51c5ac32c85 Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Wed, 4 Jun 2025 12:25:06 +0300 Subject: [PATCH 16/18] Change the test that assumes that a hashtag with # will remain as-is This does not seem to be the intended behaviour, as the code that produces it did not actually ever do anything and just returned the tag as-is. See lib/pleroma/web/activity_pub/object_validators/tag_validator.ex and https://git.pleroma.social/pleroma/pleroma/-/merge_requests/4358#note_112681 At least Mastodon and Misskey output tags without the # from their API, so in reality tags with the hash should rarely happen. --- .../web/activity_pub/transmogrifier/note_handling_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs index fd7a3c772..648326929 100644 --- a/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs @@ -200,7 +200,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do assert match?( %{ "href" => "http://mastodon.example.org/tags/moo", - "name" => "#moo", + "name" => "moo", "type" => "Hashtag" }, Enum.at(object.data["tag"], 1) From dc26f749617dda6ed2b538f515056567519d9246 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Wed, 4 Jun 2025 18:32:25 +0200 Subject: [PATCH 17/18] Revert to previous tag_validator behavior This paritally reverts commit 9710063fdc92ca3df9005ef57f678fd78680a4f0 and reverts commit 7ddae61414a2e0f04560d2afe46dc51c5ac32c85 See thread: https://git.pleroma.social/pleroma/pleroma/-/merge_requests/4358#note_112761 --- .../web/activity_pub/object_validators/tag_validator.ex | 8 +------- .../activity_pub/transmogrifier/note_handling_test.exs | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex b/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex index 91aeb9dd7..dc2770189 100644 --- a/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/tag_validator.ex @@ -50,13 +50,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidator do end def changeset(struct, %{"type" => "Hashtag", "name" => name} = data) do - name = - case name do - "#" <> name -> name - name -> name - end - |> String.downcase() - + name = String.downcase(name) data = Map.put(data, "name", name) struct diff --git a/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs index 648326929..fd7a3c772 100644 --- a/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs @@ -200,7 +200,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do assert match?( %{ "href" => "http://mastodon.example.org/tags/moo", - "name" => "moo", + "name" => "#moo", "type" => "Hashtag" }, Enum.at(object.data["tag"], 1) From ff69b00eaef8354ca7224aa6af5eb158ca502125 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Wed, 4 Jun 2025 19:18:01 +0200 Subject: [PATCH 18/18] Elixir 1.18 Update credo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit warning: Credo.CLI.Command.Info.Output.Default.print_after_info/4 is undefined or private. Did you mean: * print/2 │ 4 │ use Credo.CLI.Output.FormatDelegator, │ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ │ └─ lib/credo/cli/command/info/info_output.ex:4: Credo.CLI.Command.Info.InfoOutput.print_after_info/4 --- mix.exs | 2 +- mix.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index dc6c2492f..e34ee0cbc 100644 --- a/mix.exs +++ b/mix.exs @@ -213,7 +213,7 @@ defmodule Pleroma.Mixfile do {:poison, "~> 3.0", only: :test}, {:ex_doc, "~> 0.22", only: :dev, runtime: false}, {:ex_machina, "~> 2.4", only: :test}, - {:credo, "~> 1.6", only: [:dev, :test], runtime: false}, + {:credo, "~> 1.7", only: [:dev, :test], runtime: false}, {:mock, "~> 0.3.5", only: :test}, {:covertool, "~> 2.0", only: :test}, {:hackney, "~> 1.18.0", override: true}, diff --git a/mix.lock b/mix.lock index 9b53ede62..f7f37b7e1 100644 --- a/mix.lock +++ b/mix.lock @@ -23,7 +23,7 @@ "cowboy": {:hex, :cowboy, "2.12.0", "f276d521a1ff88b2b9b4c54d0e753da6c66dd7be6c9fca3d9418b561828a3731", [:make, :rebar3], [{:cowlib, "2.13.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "8a7abe6d183372ceb21caa2709bec928ab2b72e18a3911aa1771639bef82651e"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"}, "cowlib": {:hex, :cowlib, "2.13.0", "db8f7505d8332d98ef50a3ef34b34c1afddec7506e4ee4dd4a3a266285d282ca", [:make, :rebar3], [], "hexpm", "e1e1284dc3fc030a64b1ad0d8382ae7e99da46c3246b815318a4b848873800a4"}, - "credo": {:hex, :credo, "1.7.7", "771445037228f763f9b2afd612b6aa2fd8e28432a95dbbc60d8e03ce71ba4446", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8bc87496c9aaacdc3f90f01b7b0582467b69b4bd2441fe8aae3109d843cc2f2e"}, + "credo": {:hex, :credo, "1.7.12", "9e3c20463de4b5f3f23721527fcaf16722ec815e70ff6c60b86412c695d426c1", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8493d45c656c5427d9c729235b99d498bd133421f3e0a683e5c1b561471291e5"}, "crontab": {:hex, :crontab, "1.1.8", "2ce0e74777dfcadb28a1debbea707e58b879e6aa0ffbf9c9bb540887bce43617", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "custom_base": {:hex, :custom_base, "0.2.1", "4a832a42ea0552299d81652aa0b1f775d462175293e99dfbe4d7dbaab785a706", [:mix], [], "hexpm", "8df019facc5ec9603e94f7270f1ac73ddf339f56ade76a721eaa57c1493ba463"}, "db_connection": {:hex, :db_connection, "2.7.0", "b99faa9291bb09892c7da373bb82cba59aefa9b36300f6145c5f201c7adf48ec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dcf08f31b2701f857dfc787fbad78223d61a32204f217f15e881dd93e4bdd3ff"},