Skip to content

Commit 1df04c1

Browse files
committed
Debug CI issues.
1 parent 1968a2a commit 1df04c1

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

.github/workflows/rails_application.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,28 @@ jobs:
193193
done
194194
echo "PostgreSQL is ready."
195195
196-
RAILS_ENV=test bundle exec rails db:prepare
196+
echo "Testing simple app loading first..."
197+
RAILS_ENV=test bundle exec rails runner "puts 'App loads OK'" 2>&1 || {
198+
echo "App loading fails"
199+
exit 1
200+
}
201+
202+
echo "Running db:create..."
203+
RAILS_ENV=test bundle exec rails db:create 2>&1 || echo "db:create failed or DB already exists"
204+
205+
echo "Running db:schema:load..."
206+
RAILS_ENV=test bundle exec rails db:schema:load 2>&1 || {
207+
echo "db:schema:load failed"
208+
exit 1
209+
}
210+
211+
echo "Running db:seed..."
212+
RAILS_ENV=test bundle exec rails db:seed 2>&1 || {
213+
echo "db:seed failed"
214+
exit 1
215+
}
216+
217+
echo "All db operations completed successfully"
197218
198219
SUBJECT_LIST_OUTPUT=$(RAILS_ENV=test DEBUG_TRANSFORMATIONS=true bundle exec mutant environment subject list)
199220
mapfile -t subjects_array < <( \

infra/lib/infra/event_store.rb

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ module Infra
22
class EventStore < SimpleDelegator
33
def self.main
44
if ENV['DISABLE_EVENT_TRANSFORMATIONS'] == 'true'
5-
mapper = default_mapper
5+
puts "[DEBUG] Event transformations DISABLED"
6+
mapper = debug_mapper
67
else
8+
puts "[DEBUG] Event transformations ENABLED"
79
require_relative "../../../rails_application/lib/transformations/refund_to_return_event_mapper" rescue nil
810

911
if defined?(Transformations::RefundToReturnEventMapper)
@@ -24,7 +26,21 @@ def self.main
2426
end
2527
end
2628

27-
new(RailsEventStore::JSONClient.new(mapper: mapper))
29+
client = RailsEventStore::JSONClient.new(mapper: mapper)
30+
31+
def client.publish(*events, **kwargs)
32+
events.each do |event|
33+
if event.respond_to?(:timestamp) && event.timestamp.nil?
34+
puts "[ERROR] Event #{event.class.name} has nil timestamp!"
35+
puts "[ERROR] Event ID: #{event.event_id}"
36+
puts "[ERROR] Stack trace:"
37+
puts caller[0..10].join("\n")
38+
end
39+
end
40+
super(*events, **kwargs)
41+
end
42+
43+
new(client)
2844
end
2945

3046
def self.in_memory
@@ -57,6 +73,29 @@ def link_event_to_stream(event, stream, expected_version: :any)
5773

5874
private
5975

76+
def self.debug_mapper
77+
default_mapper_instance = default_mapper
78+
79+
class << default_mapper_instance
80+
alias_method :original_event_to_record, :event_to_record
81+
82+
def event_to_record(domain_event)
83+
record = original_event_to_record(domain_event)
84+
if record.timestamp.nil?
85+
puts "[ERROR] Record created with nil timestamp!"
86+
puts "[ERROR] Event class: #{domain_event.class.name}"
87+
puts "[ERROR] Event ID: #{domain_event.event_id}"
88+
puts "[ERROR] Domain event timestamp: #{domain_event.respond_to?(:timestamp) ? domain_event.timestamp : 'N/A'}"
89+
puts "[ERROR] Stack trace:"
90+
puts caller[0..15].join("\n")
91+
end
92+
record
93+
end
94+
end
95+
96+
default_mapper_instance
97+
end
98+
6099
def self.default_mapper
61100
RubyEventStore::Mappers::PipelineMapper.new(
62101
RubyEventStore::Mappers::Pipeline.new(

0 commit comments

Comments
 (0)