Skip to content

Commit 688ae92

Browse files
fix CI dependency issues and Phoenix.PubSub configuration
1 parent 0416ae5 commit 688ae92

6 files changed

Lines changed: 35 additions & 81 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,22 @@ jobs:
3838
elixir-version: ${{ env.ELIXIR_VERSION }}
3939
otp-version: ${{ env.OTP_VERSION }}
4040

41-
- name: Restore dependencies cache
42-
uses: actions/cache@v4
43-
with:
44-
path: |
45-
deps
46-
_build
47-
key: ${{ runner.os }}-mix-otp28-${{ hashFiles('**/mix.lock') }}
48-
restore-keys: ${{ runner.os }}-mix-otp28-
49-
41+
# Temporarily disabled cache to ensure clean builds
42+
# - name: Restore dependencies cache
43+
# uses: actions/cache@v4
44+
# with:
45+
# path: |
46+
# deps
47+
# _build
48+
# key: ${{ runner.os }}-mix-otp28-${{ hashFiles('**/mix.lock') }}
49+
# restore-keys: ${{ runner.os }}-mix-otp28-
50+
5051
- name: Install dependencies
5152
run: |
5253
mix local.hex --force
5354
mix local.rebar --force
5455
mix deps.get
56+
mix deps.compile
5557
5658
- name: Check formatting
5759
run: mix format --check-formatted

apps/kafkaesque_core/lib/kafkaesque/core/application.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ defmodule Kafkaesque.Core.Application do
77
def start(_type, _args) do
88
children = [
99
{Registry, keys: :unique, name: Kafkaesque.TopicRegistry},
10-
{DynamicSupervisor, name: Kafkaesque.TopicSupervisor, strategy: :one_for_one},
11-
{Phoenix.PubSub, name: Kafkaesque.PubSub},
10+
Kafkaesque.Topic.Supervisor,
11+
{Phoenix.PubSub, name: Kafkaesque.PubSub, adapter: Phoenix.PubSub.PG2},
1212
Kafkaesque.Telemetry.Supervisor
1313
]
1414

apps/kafkaesque_core/test/pipeline/produce_broadway_test.exs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,21 @@ defmodule Kafkaesque.Pipeline.ProduceBroadwayTest do
4545
max_queue_size: 100
4646
)
4747

48-
assert {:ok, pid} =
49-
ProduceBroadway.start_link(
50-
topic: @test_topic,
51-
partition: @test_partition,
52-
batch_size: 10,
53-
batch_timeout: 1
54-
)
48+
result =
49+
ProduceBroadway.start_link(
50+
topic: @test_topic,
51+
partition: @test_partition,
52+
batch_size: 10,
53+
batch_timeout: 1
54+
)
5555

56-
assert Process.alive?(pid)
56+
case result do
57+
{:ok, pid} ->
58+
assert Process.alive?(pid)
59+
60+
{:error, {:already_started, pid}} ->
61+
assert Process.alive?(pid)
62+
end
5763
end
5864
end
5965

apps/kafkaesque_core/test/support/test_case.ex

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,61 +18,11 @@ defmodule Kafkaesque.TestCase do
1818
end
1919

2020
setup do
21-
# Start required registries and services
22-
ensure_registry_started()
23-
# Only start PubSub if the application isn't already managing it
24-
unless Application.started_applications() |> Enum.any?(fn {app, _, _} -> app == :kafkaesque_core end) do
25-
ensure_pubsub_started()
26-
end
27-
ensure_telemetry_started()
28-
21+
# The application is started in test_helper.exs, so we don't need to start services here
22+
# They should already be running
2923
:ok
3024
end
3125

32-
@doc """
33-
Ensures the Registry is started.
34-
"""
35-
def ensure_registry_started do
36-
case Registry.start_link(keys: :unique, name: Kafkaesque.TopicRegistry) do
37-
{:ok, _} -> :ok
38-
{:error, {:already_started, _}} -> :ok
39-
end
40-
end
41-
42-
@doc """
43-
Ensures PubSub is started.
44-
"""
45-
def ensure_pubsub_started do
46-
# Check if PubSub is already running
47-
case Process.whereis(Kafkaesque.PubSub) do
48-
nil ->
49-
# Not running, start it
50-
children = [
51-
{Phoenix.PubSub, name: Kafkaesque.PubSub}
52-
]
53-
54-
case Supervisor.start_link(children, strategy: :one_for_one, name: KafkaesqueTestPubSub) do
55-
{:ok, _} -> :ok
56-
{:error, {:already_started, _}} -> :ok
57-
{:error, {:shutdown, {:failed_to_start_child, Phoenix.PubSub, {:already_started, _}}}} -> :ok
58-
end
59-
60-
_pid ->
61-
# Already running
62-
:ok
63-
end
64-
end
65-
66-
@doc """
67-
Ensures Telemetry is started.
68-
"""
69-
def ensure_telemetry_started do
70-
case Kafkaesque.Telemetry.start_link([]) do
71-
{:ok, _} -> :ok
72-
{:error, {:already_started, _}} -> :ok
73-
end
74-
end
75-
7626
@doc """
7727
Sets up a test directory and ensures cleanup on exit.
7828
"""

apps/kafkaesque_core/test/test_helper.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Start the application to ensure all services are available
2+
Application.ensure_all_started(:kafkaesque_core)
3+
14
# Compile test support files
25
Code.require_file("support/test_case.ex", __DIR__)
36

apps/kafkaesque_core/test/topic/supervisor_test.exs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,9 @@ defmodule Kafkaesque.Topic.SupervisorTest do
1313
Application.put_env(:kafkaesque_core, :data_dir, test_dir)
1414
Application.put_env(:kafkaesque_core, :offsets_dir, Path.join(test_dir, "offsets"))
1515

16-
# Start the topic supervisor if not already started
17-
case Process.whereis(TopicSupervisor) do
18-
nil ->
19-
case TopicSupervisor.start_link([]) do
20-
{:ok, pid} -> {:ok, pid}
21-
{:error, {:already_started, pid}} -> {:ok, pid}
22-
end
23-
pid ->
24-
{:ok, pid}
25-
end
16+
# The supervisor should already be started by the application
17+
# Just verify it's running (registered as the module name)
18+
assert Process.whereis(Kafkaesque.Topic.Supervisor) != nil
2619

2720
on_exit(fn ->
2821
# Clean up any created topics

0 commit comments

Comments
 (0)