From 53cb6e38bd03fbb5b0d8c36c1c63f3c521545a96 Mon Sep 17 00:00:00 2001 From: Malaber Date: Wed, 6 May 2026 12:39:12 +0200 Subject: [PATCH] fix: align CI RuboCop and e2e helpers --- .rubocop.yml | 5 +++++ Dockerfile | 1 + e2e/lib/action_cable_client.rb | 16 +++++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0c74afb..fc13361 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -66,6 +66,11 @@ Rails/SkipsModelValidations: - "app/services/tournament_sync_pusher.rb" - "db/migrate/**/*" +Rails/Delegate: + Exclude: + - "app/controllers/tournaments_controller.rb" + - "e2e/lib/action_cable_client.rb" + Style/MultilineBlockChain: Exclude: - "e2e/lib/api_client.rb" diff --git a/Dockerfile b/Dockerfile index e7c10d1..ec73507 100644 --- a/Dockerfile +++ b/Dockerfile @@ -111,6 +111,7 @@ COPY script /app/script COPY config.ru Rakefile /app/ COPY config/environments/production.rb /app/config/environments/beta.rb COPY tasks.py /app/tasks.py +COPY .rubocop.yml /app/.rubocop.yml COPY e2e /app/e2e COPY lib /app/lib COPY spec /app/spec diff --git a/e2e/lib/action_cable_client.rb b/e2e/lib/action_cable_client.rb index f6dd428..f3d9f80 100644 --- a/e2e/lib/action_cable_client.rb +++ b/e2e/lib/action_cable_client.rb @@ -121,7 +121,9 @@ module TurniereE2E websocket_url end - delegate :write, to: :socket + def write(data) + socket.write(data) + end private @@ -182,8 +184,8 @@ module TurniereE2E end def pump_until_open!(timeout: 10) - deadline = Time.zone.now + timeout - while Time.zone.now < deadline + deadline = monotonic_deadline(timeout) + while Process.clock_gettime(Process::CLOCK_MONOTONIC) < deadline read_from_socket(timeout: 0.5) return if driver.ready_state == 1 end @@ -192,14 +194,14 @@ module TurniereE2E end def wait_for!(timeout: 20) - deadline = Time.zone.now + timeout + deadline = monotonic_deadline(timeout) loop do until @messages.empty? message = @messages.pop(true) return message if yield(message) end - raise "websocket message not received within #{timeout}s" if Time.zone.now >= deadline + raise "websocket message not received within #{timeout}s" if Process.clock_gettime(Process::CLOCK_MONOTONIC) >= deadline read_from_socket(timeout: 0.5) rescue ThreadError @@ -207,6 +209,10 @@ module TurniereE2E end end + def monotonic_deadline(timeout) + Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout + end + def read_from_socket(timeout:) readable, = IO.select([socket], nil, nil, timeout) return if readable.nil?