From 6fdd39dc0e1346800a34adeae098f94398d4d169 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 27 Jul 2025 13:51:43 -0500 Subject: [PATCH] Fix CI test failures and configuration issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Simplify APRS_PORT parsing to avoid syntax errors - Disable Exq properly in test environment to prevent startup issues - Disable Prometheus telemetry in test mode to avoid port conflicts - Update telemetry module to conditionally start Prometheus metrics 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- config/runtime.exs | 9 +-------- config/test.exs | 8 +++++++- lib/aprsme_web/telemetry.ex | 24 ++++++++++++++++-------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/config/runtime.exs b/config/runtime.exs index 8a1db26..39620e6 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -172,14 +172,7 @@ if config_env() == :prod do ecto_repos: [Aprsme.Repo], aprs_is_server: System.get_env("APRS_SERVER", "dallas.aprs2.net"), # config :aprsme, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY") - aprs_is_port: case System.get_env("APRS_PORT", "14580") do - port when is_binary(port) -> - case Integer.parse(port) do - {int, ""} -> int - _ -> 14580 # fallback to default port if parsing fails - end - _ -> 14580 - end, + aprs_is_port: String.to_integer(System.get_env("APRS_PORT") || "14580"), aprs_is_default_filter: System.get_env("APRS_FILTER"), aprs_is_login_id: System.get_env("APRS_CALLSIGN"), aprs_is_password: System.get_env("APRS_PASSCODE"), diff --git a/config/test.exs b/config/test.exs index bee7f95..ebea06f 100644 --- a/config/test.exs +++ b/config/test.exs @@ -52,7 +52,13 @@ config :aprsme, auto_migrate: false config :bcrypt_elixir, :log_rounds, 1 # Disable Exq during tests to prevent background job execution -config :exq, mode: :inline +config :exq, + start_on_application: false, + mode: :inline + +# Disable Prometheus telemetry in test mode to avoid port conflicts +config :aprsme, AprsmeWeb.Telemetry, + enabled: false # Configure ExVCR config :exvcr, diff --git a/lib/aprsme_web/telemetry.ex b/lib/aprsme_web/telemetry.ex index 1bb05ce..c371fde 100644 --- a/lib/aprsme_web/telemetry.ex +++ b/lib/aprsme_web/telemetry.ex @@ -10,14 +10,22 @@ defmodule AprsmeWeb.Telemetry do @impl true def init(_arg) do - children = [ - # Telemetry poller will execute the given period measurements - # every 10_000ms. Learn more here: https://hexdocs.pm/telemetry_metrics - {:telemetry_poller, measurements: periodic_measurements(), period: 10_000}, - # Add reporters as children of your supervision tree. - # {Telemetry.Metrics.ConsoleReporter, metrics: metrics()} - {TelemetryMetricsPrometheus, [metrics: metrics()]} - ] + children = + if Application.get_env(:aprsme, AprsmeWeb.Telemetry)[:enabled] != false do + [ + # Telemetry poller will execute the given period measurements + # every 10_000ms. Learn more here: https://hexdocs.pm/telemetry_metrics + {:telemetry_poller, measurements: periodic_measurements(), period: 10_000}, + # Add reporters as children of your supervision tree. + # {Telemetry.Metrics.ConsoleReporter, metrics: metrics()} + {TelemetryMetricsPrometheus, [metrics: metrics()]} + ] + else + [ + # Only telemetry poller in test mode + {:telemetry_poller, measurements: periodic_measurements(), period: 10_000} + ] + end Supervisor.init(children, strategy: :one_for_one) end