Skip to content

Commit

Permalink
Merge pull request #825 from zmariscal/feature--add-trilogy-adapter-g…
Browse files Browse the repository at this point in the history
…ithub-workflow

[Feature]  Add trilogy adapter support
  • Loading branch information
jkowens authored Feb 5, 2024
2 parents 22e077b + d0611bf commit cfab0ae
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:5.7
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: github
MYSQL_PASSWORD: github
MYSQL_DATABASE: activerecord_import_test
options: >-
--health-cmd "mysqladmin ping -h localhost"
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -81,6 +95,7 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
rubygems: latest
- name: Set up databases
run: |
sudo /etc/init.d/mysql start
Expand Down Expand Up @@ -110,6 +125,9 @@ jobs:
run: |
bundle exec rake test:spatialite
bundle exec rake test:sqlite3
- name: Run trilogy tests
if: ${{ matrix.env.AR_VERSION >= '7.0' && matrix.ruby != 'jruby' }}
run: bundle exec rake test:trilogy
lint:
runs-on: ubuntu-latest
env:
Expand Down
10 changes: 9 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ platforms :ruby do
gem "sqlite3", "~> #{sqlite3_version}"
# seamless_database_pool requires Ruby ~> 2.0
gem "seamless_database_pool", "~> 1.0.20" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0')
gem "trilogy" if version >= 6.0
if version >= 6.0 && version <= 7.0
gem "activerecord-trilogy-adapter"
end
end

platforms :jruby do
Expand All @@ -37,7 +41,11 @@ platforms :jruby do
end

# Support libs
gem "factory_bot"
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0")
gem "factory_bot"
else
gem "factory_bot", "~> 5", "< 6.4.5"
end
gem "timecop"
gem "chronic"
gem "mocha", "~> 2.1.0"
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ADAPTERS = %w(
sqlite3
spatialite
seamless_database_pool
trilogy
).freeze
ADAPTERS.each do |adapter|
namespace :test do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

require "active_record/connection_adapters/trilogy_adapter"
require "activerecord-import/adapters/trilogy_adapter"

class ActiveRecord::ConnectionAdapters::TrilogyAdapter
include ActiveRecord::Import::TrilogyAdapter
end
7 changes: 7 additions & 0 deletions lib/activerecord-import/adapters/trilogy_adapter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

require "activerecord-import/adapters/mysql_adapter"

module ActiveRecord::Import::TrilogyAdapter
include ActiveRecord::Import::MysqlAdapter
end
9 changes: 9 additions & 0 deletions test/adapters/trilogy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

ENV["ARE_DB"] = "trilogy"

if ENV['AR_VERSION'].to_f <= 7.0
require "activerecord-trilogy-adapter"
require "trilogy_adapter/connection"
ActiveRecord::Base.extend TrilogyAdapter::Connection
end
5 changes: 5 additions & 0 deletions test/database.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ sqlite3: &sqlite3

spatialite:
<<: *sqlite3

trilogy:
<<: *common
adapter: trilogy
host: mysql
4 changes: 4 additions & 0 deletions test/github/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ sqlite3: &sqlite3

spatialite:
<<: *sqlite3

trilogy:
<<: *common
adapter: trilogy
7 changes: 7 additions & 0 deletions test/trilogy/import_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")

should_support_mysql_import_functionality

0 comments on commit cfab0ae

Please sign in to comment.