diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index f3cc4f66..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,83 +0,0 @@ -defaults: &defaults - parallelism: 1 - working_directory: ~/workspace - docker: - - image: ruby:2.6 - environment: - RAILS_ENV: test - DB_HOST_IP: 127.0.0.1 -version: 2.1 -jobs: - build: - <<: *defaults - steps: - - checkout - - # Restore bundle cache & npm cache - - restore_cache: - key: 'rails-{{ checksum "Gemfile.lock" }}' - - # Bundle install dependencies in /tmp/ - # so Dockerfile does not copy them since - # its base image is different than CircleCI - - run: - name: Install bundler - command: gem install bundler:2.1.4 - - run: - name: Bundle install - command: bundle install --path vendor/bundle --jobs=4 --retry=3 - - # Store bundle cache - - save_cache: - key: 'rails-{{ checksum "Gemfile.lock" }}' - paths: - - ~/workspace/vendor/bundle - - - persist_to_workspace: - root: ~/workspace - paths: - - . - - lint: - <<: *defaults - steps: - - attach_workspace: - at: ~/workspace - - run: - name: Install bundler - command: gem install bundler:2.1.4 - - run: - name: Point bundle to vendor/bundle - command: bundle --path vendor/bundle - - run: bundle exec rubocop --display-only-fail-level-offenses --fail-level C - - test-rspec: - <<: *defaults - steps: - - attach_workspace: - at: ~/workspace - - run: - name: Install bundler - command: gem install bundler:2.1.4 - - run: - name: Point bundle to vendor/bundle - command: bundle --path vendor/bundle - - run: mkdir result - - run: - name: Running rspec - command: bundle exec rspec --format progress --format RspecJunitFormatter -o result/rspec.xml - when: always - - store_test_results: - path: ~/workspace/result - -workflows: - version: 2 - build-and-test: - jobs: - - build - - test-rspec: - requires: - - build - - lint: - requires: - - build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b05e7f59..05a744e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,10 +19,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Ruby 2.7 + - name: Set up Ruby 3.3 uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.3 bundler-cache: true - name: Bundle install @@ -36,7 +36,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [ '2.6', '2.7', '3.0', '3.1' ] + ruby: [ '2.7', '3.0', '3.1', '3.2', '3.3' ] steps: - uses: actions/checkout@v3 diff --git a/.ruby-version b/.ruby-version index a7f19382..be94e6f5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1,2 +1 @@ -2.7.0 - +3.2.2 diff --git a/lib/deimos/kafka_topic_info.rb b/lib/deimos/kafka_topic_info.rb index e8fdfad7..7697742f 100644 --- a/lib/deimos/kafka_topic_info.rb +++ b/lib/deimos/kafka_topic_info.rb @@ -6,6 +6,11 @@ class KafkaTopicInfo < ActiveRecord::Base self.table_name = 'kafka_topic_info' class << self + + def quote_time(time) + time.respond_to?(:to_fs) ? time.to_fs(:db) : time.to_s(:db) + end + # Lock a topic for the given ID. Returns whether the lock was successful. # @param topic [String] # @param lock_id [String] @@ -22,9 +27,9 @@ def lock(topic, lock_id) qtopic = self.connection.quote(topic) qlock_id = self.connection.quote(lock_id) qtable = self.connection.quote_table_name('kafka_topic_info') - qnow = self.connection.quote(Time.zone.now.to_s(:db)) + qnow = self.connection.quote(quote_time(Time.zone.now)) qfalse = self.connection.quoted_false - qtime = self.connection.quote(1.minute.ago.to_s(:db)) + qtime = self.connection.quote(quote_time(1.minute.ago)) # If a record is marked as error and less than 1 minute old, # we don't want to pick it up even if not currently locked because diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8e5184ee..acf29369 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,6 +14,8 @@ require 'handlers/my_consumer' require 'rspec/rails' require 'rspec/snapshot' +require "trilogy_adapter/connection" +ActiveRecord::Base.public_send :extend, TrilogyAdapter::Connection Dir['./spec/schemas/**/*.rb'].sort.each { |f| require f } # Constants used for consumer specs