From 15a8acbd6cc6ecc89b49956acfeba49d02270c1d Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Thu, 30 Nov 2023 09:40:17 +0400 Subject: [PATCH 1/6] MRF, Docs.Generator: Ensure code is loaded before checking it --- lib/pleroma/docs/generator.ex | 2 ++ lib/pleroma/web/activity_pub/mrf.ex | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lib/pleroma/docs/generator.ex b/lib/pleroma/docs/generator.ex index 6508f1947..456a8fd54 100644 --- a/lib/pleroma/docs/generator.ex +++ b/lib/pleroma/docs/generator.ex @@ -17,6 +17,8 @@ defmodule Pleroma.Docs.Generator do # This shouldn't be needed as all modules are expected to have module_info/1, # but in test enviroments some transient modules `:elixir_compiler_XX` # are loaded for some reason (where XX is a random integer). + Code.ensure_loaded(module) + if function_exported?(module, :module_info, 1) do module.module_info(:attributes) |> Keyword.get_values(:behaviour) diff --git a/lib/pleroma/web/activity_pub/mrf.ex b/lib/pleroma/web/activity_pub/mrf.ex index ff9f84497..a0deac300 100644 --- a/lib/pleroma/web/activity_pub/mrf.ex +++ b/lib/pleroma/web/activity_pub/mrf.ex @@ -54,6 +54,8 @@ defmodule Pleroma.Web.ActivityPub.MRF do @required_description_keys [:key, :related_policy] def filter_one(policy, message) do + Code.ensure_loaded(policy) + should_plug_history? = if function_exported?(policy, :history_awareness, 0) do policy.history_awareness() @@ -188,6 +190,7 @@ defmodule Pleroma.Web.ActivityPub.MRF do def config_descriptions(policies) do Enum.reduce(policies, @mrf_config_descriptions, fn policy, acc -> + Code.ensure_loaded(policy) if function_exported?(policy, :config_description, 0) do description = @default_description From 265d8749b1683f58f902cb82529d762617adc1c6 Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Thu, 30 Nov 2023 09:40:29 +0400 Subject: [PATCH 2/6] Gitlab CI: Make it work for a local runner --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ff3308e31..10a843af2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ variables: &global_variables POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres DB_HOST: postgres - DB_PORT: 5432 + DB_PORT: "5432" MIX_ENV: test workflow: From 30084b7332e4a5985d866d94328fba1bc08475ec Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Thu, 30 Nov 2023 09:55:04 +0400 Subject: [PATCH 3/6] Add changelog. --- changelog.d/loading-order-test-fix.skip | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 changelog.d/loading-order-test-fix.skip diff --git a/changelog.d/loading-order-test-fix.skip b/changelog.d/loading-order-test-fix.skip new file mode 100644 index 000000000..e69de29bb From eb6be30602f95cf86aef465229dacbdcb92c3c58 Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Thu, 30 Nov 2023 10:05:00 +0400 Subject: [PATCH 4/6] Linting --- lib/pleroma/web/activity_pub/mrf.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pleroma/web/activity_pub/mrf.ex b/lib/pleroma/web/activity_pub/mrf.ex index a0deac300..69054e25b 100644 --- a/lib/pleroma/web/activity_pub/mrf.ex +++ b/lib/pleroma/web/activity_pub/mrf.ex @@ -191,6 +191,7 @@ defmodule Pleroma.Web.ActivityPub.MRF do def config_descriptions(policies) do Enum.reduce(policies, @mrf_config_descriptions, fn policy, acc -> Code.ensure_loaded(policy) + if function_exported?(policy, :config_description, 0) do description = @default_description From d99e139c6bec91150a10b68c032019a163eccf04 Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Thu, 30 Nov 2023 13:54:07 +0400 Subject: [PATCH 5/6] CI: Remove test coverage --- .gitlab-ci.yml | 8 +------- mix.exs | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 10a843af2..1edfc02ea 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -125,13 +125,7 @@ unit-testing: script: - mix ecto.create - mix ecto.migrate - - mix test --cover --preload-modules - coverage: '/^Line total: ([^ ]*%)$/' - artifacts: - reports: - coverage_report: - coverage_format: cobertura - path: coverage.xml + - mix test --preload-modules unit-testing-erratic: extends: diff --git a/mix.exs b/mix.exs index 99074b433..85371c645 100644 --- a/mix.exs +++ b/mix.exs @@ -190,7 +190,6 @@ defmodule Pleroma.Mixfile do {:ex_machina, "~> 2.4", only: :test}, {:credo, "~> 1.6", only: [:dev, :test], runtime: false}, {:mock, "~> 0.3.5", only: :test}, - {:covertool, "~> 2.0", only: :test}, {:hackney, "~> 1.18.0", override: true}, {:mox, "~> 1.0", only: :test}, {:websockex, "~> 0.4.3", only: :test}, From 5dce39d17f7aede05f6326fbe3514bd9431f832c Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Sun, 3 Dec 2023 10:17:24 +0400 Subject: [PATCH 6/6] Revert "CI: Remove test coverage" This reverts commit d99e139c6bec91150a10b68c032019a163eccf04. --- .gitlab-ci.yml | 8 +++++++- mix.exs | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1edfc02ea..10a843af2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -125,7 +125,13 @@ unit-testing: script: - mix ecto.create - mix ecto.migrate - - mix test --preload-modules + - mix test --cover --preload-modules + coverage: '/^Line total: ([^ ]*%)$/' + artifacts: + reports: + coverage_report: + coverage_format: cobertura + path: coverage.xml unit-testing-erratic: extends: diff --git a/mix.exs b/mix.exs index 85371c645..99074b433 100644 --- a/mix.exs +++ b/mix.exs @@ -190,6 +190,7 @@ defmodule Pleroma.Mixfile do {:ex_machina, "~> 2.4", only: :test}, {:credo, "~> 1.6", only: [:dev, :test], runtime: false}, {:mock, "~> 0.3.5", only: :test}, + {:covertool, "~> 2.0", only: :test}, {:hackney, "~> 1.18.0", override: true}, {:mox, "~> 1.0", only: :test}, {:websockex, "~> 0.4.3", only: :test},