From c5edd759d2acd010823710620007d86dca78ac17 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Tue, 12 Sep 2023 06:35:42 -0700 Subject: [PATCH 01/20] add trilogy to Gemfile --- Gemfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index ac1ab013..327980df 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,11 @@ group :sqlserver do gem 'activerecord-sqlserver-adapter' end +group :trilogy do + gem 'trilogy' + gem 'activerecord-trilogy-adapter' +end + group :test do gem 'minitest' end From 802587bf8118b9b53592de4ad8e4a586e836a420 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Tue, 12 Sep 2023 06:37:00 -0700 Subject: [PATCH 02/20] create trilogy rake task and add it to Rakefile and console script --- Rakefile | 2 +- scripts/console.rb | 4 ++-- tasks/databases/trilogy.rake | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 tasks/databases/trilogy.rake diff --git a/Rakefile b/Rakefile index 93fdb0b4..177a314f 100644 --- a/Rakefile +++ b/Rakefile @@ -23,7 +23,7 @@ Dir.glob('tasks/**/*.rake').each do |rake_file| end # Set up test tasks for each supported connection adapter -%w(mysql sqlite oracle oracle_enhanced postgresql ibm_db sqlserver).each do |adapter| +%w(mysql sqlite oracle oracle_enhanced postgresql ibm_db sqlserver trilogy).each do |adapter| namespace adapter do desc "Run tests using the #{adapter} adapter" task "test" do diff --git a/scripts/console.rb b/scripts/console.rb index 27c69cfc..851c8e5e 100755 --- a/scripts/console.rb +++ b/scripts/console.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -# if run as script, load the file as library while starting irb +# if run as script, load the file as library while starting irb # if __FILE__ == $0 irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' @@ -12,7 +12,7 @@ # # check if the given adapter is supported (default: mysql) # -adapters = %w[mysql sqlite oracle oracle_enhanced postgresql ibm_db] +adapters = %w[mysql sqlite oracle oracle_enhanced postgresql ibm_db trilogy] adapter = ENV['ADAPTER'] || 'mysql' unless adapters.include? adapter puts "Usage: #{__FILE__} " diff --git a/tasks/databases/trilogy.rake b/tasks/databases/trilogy.rake new file mode 100644 index 00000000..d3e922da --- /dev/null +++ b/tasks/databases/trilogy.rake @@ -0,0 +1,23 @@ +namespace :trilogy do + task :setup do + require 'bundler' + Bundler.require(:default, :trilogy) + end + + task :create_database => :setup do + Rake::Task["mysql:create_database"].invoke + end + + desc 'Build the MySQL test database' + task :build_database => [:create_database] do + Rake::Task["mysql:build_database"].invoke + end + + desc 'Drop the MySQL test database' + task :drop_database => :setup do + Rake::Task["mysql:drop_database"].invoke + end + + desc 'Rebuild the MySQL test database' + task :rebuild_database => [:drop_database, :build_database] +end From 8c55d8132cdb003514ce0ddc94e48e857da03a7b Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Tue, 12 Sep 2023 06:37:40 -0700 Subject: [PATCH 03/20] bundle current github workflows without trilogy --- .github/workflows/mariadb.yml | 2 +- .github/workflows/mysql.yml | 2 +- .github/workflows/postgresql.yml | 2 +- .github/workflows/sqlite.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mariadb.yml b/.github/workflows/mariadb.yml index 565bda7e..d0cd2fa6 100644 --- a/.github/workflows/mariadb.yml +++ b/.github/workflows/mariadb.yml @@ -26,7 +26,7 @@ jobs: --health-timeout 5s --health-retries 5 env: - BUNDLE_WITHOUT: "db2 oracle sqlserver sqlite postgresql" + BUNDLE_WITHOUT: "db2 oracle sqlserver sqlite postgresql trilogy" BUNDLE_JOBS: 4 BUNDLE_PATH: vendor/bundle steps: diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml index ccc58418..9e701f42 100644 --- a/.github/workflows/mysql.yml +++ b/.github/workflows/mysql.yml @@ -26,7 +26,7 @@ jobs: --health-timeout 5s --health-retries 5 env: - BUNDLE_WITHOUT: "db2 oracle sqlserver sqlite postgresql" + BUNDLE_WITHOUT: "db2 oracle sqlserver sqlite postgresql trilogy" BUNDLE_JOBS: 4 BUNDLE_PATH: vendor/bundle steps: diff --git a/.github/workflows/postgresql.yml b/.github/workflows/postgresql.yml index a1261dd8..90b963ff 100644 --- a/.github/workflows/postgresql.yml +++ b/.github/workflows/postgresql.yml @@ -24,7 +24,7 @@ jobs: --health-timeout 5s --health-retries 5 env: - BUNDLE_WITHOUT: "db2 oracle sqlserver mysql splite" + BUNDLE_WITHOUT: "db2 oracle sqlserver mysql sqlite trilogy" BUNDLE_JOBS: 4 BUNDLE_PATH: vendor/bundle steps: diff --git a/.github/workflows/sqlite.yml b/.github/workflows/sqlite.yml index bc02ad3e..24a39e8c 100644 --- a/.github/workflows/sqlite.yml +++ b/.github/workflows/sqlite.yml @@ -11,7 +11,7 @@ jobs: ruby: [2.7, "3.0", 3.1, 3.2] runs-on: ${{matrix.os}} env: - BUNDLE_WITHOUT: "db2 oracle sqlserver postgresql mysql" + BUNDLE_WITHOUT: "db2 oracle sqlserver postgresql mysql trilogy" BUNDLE_JOBS: 4 BUNDLE_PATH: vendor/bundle steps: From a331a2a7ae4de098214cf4823d3d52258f3ddb91 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Tue, 12 Sep 2023 06:38:24 -0700 Subject: [PATCH 04/20] add trilogy to databases.ci.yml --- test/connections/databases.ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/connections/databases.ci.yml b/test/connections/databases.ci.yml index d7ba6c2a..3c97967e 100644 --- a/test/connections/databases.ci.yml +++ b/test/connections/databases.ci.yml @@ -20,3 +20,13 @@ sqlite: adapter: sqlite3 database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %> +trilogy: + adapter: mysql2 + username: github + password: github + host: 127.0.0.1 + port: 3306 + encoding: utf8mb4 + charset: utf8mb4 + collation: utf8mb4_bin + database: composite_primary_keys_unittest From 2109996346f0ee38f6b08b1c5a8c0a8bb0786881 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Tue, 12 Sep 2023 06:42:05 -0700 Subject: [PATCH 05/20] ensure trilogy AR connection files are added and specify #cpk_mysql_subquery if TrilogyAdapter is defined --- lib/composite_primary_keys.rb | 4 +++- lib/composite_primary_keys/relation.rb | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/composite_primary_keys.rb b/lib/composite_primary_keys.rb index 7fc83cae..5146cc35 100644 --- a/lib/composite_primary_keys.rb +++ b/lib/composite_primary_keys.rb @@ -61,6 +61,8 @@ require 'active_record/connection_adapters/abstract/database_statements' require 'active_record/connection_adapters/abstract_adapter' require 'active_record/connection_adapters/postgresql/database_statements' +require "active_record/connection_adapters/trilogy_adapter" +require "active_record/connection_adapters/trilogy/database_statements" require 'active_record/relation/where_clause' require 'active_record/table_metadata' @@ -114,4 +116,4 @@ require_relative 'composite_primary_keys/arel/to_sql' require_relative 'composite_primary_keys/arel/sqlserver' -require_relative 'composite_primary_keys/table_metadata' \ No newline at end of file +require_relative 'composite_primary_keys/table_metadata' diff --git a/lib/composite_primary_keys/relation.rb b/lib/composite_primary_keys/relation.rb index 8b19c548..3f08eaf4 100644 --- a/lib/composite_primary_keys/relation.rb +++ b/lib/composite_primary_keys/relation.rb @@ -1,5 +1,7 @@ module ActiveRecord class Relation + AR_CONNECTION_TRILOGY_ADAPTER = ActiveRecord::ConnectionAdapters::TrilogyAdapter + alias :initialize_without_cpk :initialize def initialize(klass, table: klass.arel_table, predicate_builder: klass.predicate_builder, values: {}) initialize_without_cpk(klass, table: table, predicate_builder: predicate_builder, values: values) @@ -102,6 +104,8 @@ def cpk_subquery(stmt) # database adapter to decide how to proceed. if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) && connection.is_a?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) cpk_mysql_subquery(stmt) + elsif defined?(AR_CONNECTION_TRILOGY_ADAPTER) && connection.is_a?(AR_CONNECTION_TRILOGY_ADAPTER) + cpk_mysql_subquery(stmt) elsif defined?(ActiveRecord::ConnectionAdapters::SQLServerAdapter) && connection.is_a?(ActiveRecord::ConnectionAdapters::SQLServerAdapter) cpk_exists_subquery(stmt) else From 2b6df2693a63f7be43caa60bd1fa5ae286562a86 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Tue, 12 Sep 2023 06:47:15 -0700 Subject: [PATCH 06/20] add private method to control #value returned One thing we need to ensure overall is that and ActiveRecord::Result is returned as the guts of the gem is looking to work with that object. A Trilogy::Result was being returned as `value`and that doesn't respond to #empty? --- .../abstract/database_statements.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb b/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb index 56795996..6adbb753 100644 --- a/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +++ b/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb @@ -6,8 +6,7 @@ def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, bind value = exec_insert(sql, name, binds, pk, sequence_name) return id_value if id_value - - if pk.is_a?(Array) && !value.empty? + if pk.is_a?(Array) && !active_record_result(value).empty? # This is a CPK model and the query result is not empty. Thus we can figure out the new ids for each # auto incremented field pk.map {|key| value.first[key]} @@ -32,6 +31,16 @@ def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, bind last_inserted_id(value) end end + + private + + def active_record_result(value) + return value if @config[:adapter] != "trilogy" + + # Create an AR Result so we can respond to #empty? + # since Trilogy:Result doesn't respond to it. + ActiveRecord::Result.new(value.fields, value.to_a) + end end end end From bcf5e484acf60dac05debf91ebbfeeec75641be2 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Tue, 12 Sep 2023 06:50:25 -0700 Subject: [PATCH 07/20] connect to the db if trilogy adapter used We need to load some more files as AR isn't aware of trilogy --- test/abstract_unit.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/abstract_unit.rb b/test/abstract_unit.rb index cbb14f46..1b29717a 100644 --- a/test/abstract_unit.rb +++ b/test/abstract_unit.rb @@ -1,6 +1,11 @@ spec_name = ENV['ADAPTER'] || 'postgresql' require 'bundler' require 'minitest/autorun' +if spec_name == "trilogy" + require "activerecord-trilogy-adapter" + require "trilogy_adapter/connection" + ActiveRecord::Base.extend TrilogyAdapter::Connection +end Bundler.setup(:default, spec_name.to_sym) Bundler.require(:default, spec_name.to_sym) From 5d8bbf55c293d892ba042174a7ade0afa52286e4 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Tue, 12 Sep 2023 06:52:54 -0700 Subject: [PATCH 08/20] create github trilogy workflow --- .github/workflows/trilogy.yml | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/trilogy.yml diff --git a/.github/workflows/trilogy.yml b/.github/workflows/trilogy.yml new file mode 100644 index 00000000..f8eae308 --- /dev/null +++ b/.github/workflows/trilogy.yml @@ -0,0 +1,45 @@ +name: trilogy + +on: [push, pull_request] + +jobs: + trilogy_test: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + ruby: [2.7, 3.0, 3.1, 3.2] + runs-on: ${{matrix.os}} + services: + mysql: + image: mysql + ports: + - 3306:3306 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_USER: github + MYSQL_PASSWORD: github + MYSQL_DATABASE: composite_primary_keys_unittest + options: >- + --health-cmd "mysqladmin ping -h localhost" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + BUNDLE_WITHOUT: "db2 oracle sqlserver sqlite postgresql trilogy" + BUNDLE_JOBS: 4 + BUNDLE_PATH: vendor/bundle + steps: + - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{matrix.ruby}} + bundler-cache: true + - name: Setup database config + run: cp test/connections/databases.ci.yml test/connections/databases.yml + - name: Prepare databases + run: bundle exec rake trilogy:rebuild_database + env: + MYSQL_ROOT_PASSWORD: root + - name: Trilogy test + run: bundle exec rake trilogy:test From dc079a21745a3db4a62a5a56383c3f6d4cc24898 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Wed, 20 Sep 2023 17:02:53 -0700 Subject: [PATCH 09/20] use the trilogy adapter in the db.ci yml file --- test/connections/databases.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/connections/databases.ci.yml b/test/connections/databases.ci.yml index 3c97967e..09b63edc 100644 --- a/test/connections/databases.ci.yml +++ b/test/connections/databases.ci.yml @@ -21,7 +21,7 @@ sqlite: database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %> trilogy: - adapter: mysql2 + adapter: trilogy username: github password: github host: 127.0.0.1 From f46d5acb143401a9443c22a6a0f57befd442761b Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Wed, 20 Sep 2023 17:03:26 -0700 Subject: [PATCH 10/20] remove require statements as they aren't needed --- lib/composite_primary_keys.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/composite_primary_keys.rb b/lib/composite_primary_keys.rb index 5146cc35..1666770d 100644 --- a/lib/composite_primary_keys.rb +++ b/lib/composite_primary_keys.rb @@ -61,8 +61,6 @@ require 'active_record/connection_adapters/abstract/database_statements' require 'active_record/connection_adapters/abstract_adapter' require 'active_record/connection_adapters/postgresql/database_statements' -require "active_record/connection_adapters/trilogy_adapter" -require "active_record/connection_adapters/trilogy/database_statements" require 'active_record/relation/where_clause' require 'active_record/table_metadata' From 3fc646631829c3256368642b881bcca8a06b3025 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Wed, 20 Sep 2023 17:04:22 -0700 Subject: [PATCH 11/20] Remove constant and follow pattern of if block there's a pattern already in place as the constant may not always be defined --- lib/composite_primary_keys/relation.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/composite_primary_keys/relation.rb b/lib/composite_primary_keys/relation.rb index 3f08eaf4..14e23914 100644 --- a/lib/composite_primary_keys/relation.rb +++ b/lib/composite_primary_keys/relation.rb @@ -1,7 +1,5 @@ module ActiveRecord class Relation - AR_CONNECTION_TRILOGY_ADAPTER = ActiveRecord::ConnectionAdapters::TrilogyAdapter - alias :initialize_without_cpk :initialize def initialize(klass, table: klass.arel_table, predicate_builder: klass.predicate_builder, values: {}) initialize_without_cpk(klass, table: table, predicate_builder: predicate_builder, values: values) @@ -104,7 +102,7 @@ def cpk_subquery(stmt) # database adapter to decide how to proceed. if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) && connection.is_a?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) cpk_mysql_subquery(stmt) - elsif defined?(AR_CONNECTION_TRILOGY_ADAPTER) && connection.is_a?(AR_CONNECTION_TRILOGY_ADAPTER) + elsif defined?(ActiveRecord::ConnectionAdapters::TrilogyAdapter) && connection.is_a?(ActiveRecord::ConnectionAdapters::TrilogyAdapter) cpk_mysql_subquery(stmt) elsif defined?(ActiveRecord::ConnectionAdapters::SQLServerAdapter) && connection.is_a?(ActiveRecord::ConnectionAdapters::SQLServerAdapter) cpk_exists_subquery(stmt) From 32ef97f720d3a057c0fbcc4311da40952c8b4134 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Wed, 20 Sep 2023 17:05:10 -0700 Subject: [PATCH 12/20] revert trilogy additions in test file --- test/abstract_unit.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/abstract_unit.rb b/test/abstract_unit.rb index 1b29717a..cbb14f46 100644 --- a/test/abstract_unit.rb +++ b/test/abstract_unit.rb @@ -1,11 +1,6 @@ spec_name = ENV['ADAPTER'] || 'postgresql' require 'bundler' require 'minitest/autorun' -if spec_name == "trilogy" - require "activerecord-trilogy-adapter" - require "trilogy_adapter/connection" - ActiveRecord::Base.extend TrilogyAdapter::Connection -end Bundler.setup(:default, spec_name.to_sym) Bundler.require(:default, spec_name.to_sym) From 69aced21e71ab1321a6bf7c0873179d0b313e869 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Mon, 25 Sep 2023 20:06:42 -0700 Subject: [PATCH 13/20] when adding trilogy to various places I accidentally added it to its own github action and we for sure need trilogy here --- .github/workflows/trilogy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trilogy.yml b/.github/workflows/trilogy.yml index f8eae308..009de44c 100644 --- a/.github/workflows/trilogy.yml +++ b/.github/workflows/trilogy.yml @@ -26,7 +26,7 @@ jobs: --health-timeout 5s --health-retries 5 env: - BUNDLE_WITHOUT: "db2 oracle sqlserver sqlite postgresql trilogy" + BUNDLE_WITHOUT: "db2 oracle sqlserver sqlite postgresql" BUNDLE_JOBS: 4 BUNDLE_PATH: vendor/bundle steps: From c95dc75c71b67b34463ed245945f303eb9121324 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Mon, 25 Sep 2023 20:18:37 -0700 Subject: [PATCH 14/20] if value doesn't respond to #empty? we don't want to continue --- .../abstract/database_statements.rb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb b/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb index 6adbb753..b01107fb 100644 --- a/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +++ b/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb @@ -6,7 +6,7 @@ def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, bind value = exec_insert(sql, name, binds, pk, sequence_name) return id_value if id_value - if pk.is_a?(Array) && !active_record_result(value).empty? + if pk.is_a?(Array) && value.respond_to?(:empty?) && !value.empty? # This is a CPK model and the query result is not empty. Thus we can figure out the new ids for each # auto incremented field pk.map {|key| value.first[key]} @@ -31,16 +31,6 @@ def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, bind last_inserted_id(value) end end - - private - - def active_record_result(value) - return value if @config[:adapter] != "trilogy" - - # Create an AR Result so we can respond to #empty? - # since Trilogy:Result doesn't respond to it. - ActiveRecord::Result.new(value.fields, value.to_a) - end end end end From e5f311e2ab61a917613055b44bd0e1a4dbd63a5b Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Mon, 25 Sep 2023 21:26:00 -0700 Subject: [PATCH 15/20] when running tests we need to ensure AR is aware of Trilogy so load it and make the DB connection --- test/abstract_unit.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/abstract_unit.rb b/test/abstract_unit.rb index cbb14f46..4645bf38 100644 --- a/test/abstract_unit.rb +++ b/test/abstract_unit.rb @@ -14,6 +14,12 @@ puts "Loaded #{spec_name}" # And now connect to the database +if spec_name == "trilogy" + require "activerecord-trilogy-adapter" + require "trilogy_adapter/connection" + ActiveRecord::Base.extend TrilogyAdapter::Connection +end + ActiveRecord::Base.establish_connection(spec) # Tell active record about the configuration From 3de57acde069ad4c25763d758868398b3dfad9c1 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Mon, 9 Oct 2023 22:12:35 -0700 Subject: [PATCH 16/20] add github action steps to resolve database.yml or DATABASE_URL https://github.com/trilogy-libraries/activerecord-trilogy-adapter/issues/64 --- .github/workflows/trilogy.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/trilogy.yml b/.github/workflows/trilogy.yml index 009de44c..e4bd2882 100644 --- a/.github/workflows/trilogy.yml +++ b/.github/workflows/trilogy.yml @@ -41,5 +41,10 @@ jobs: run: bundle exec rake trilogy:rebuild_database env: MYSQL_ROOT_PASSWORD: root + - name: Create user, grant privledges,and flush # workaround to resolve https://github.com/trilogy-libraries/activerecord-trilogy-adapter/issues/64 + run: | + mysql -e "CREATE USER 'test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';" -uMYSQL_USER -pMYSQL_ROOT_PASSWORD + mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' WITH GRANT OPTION;" -uMYSQL_USER -pMYSQL_ROOT_PASSWORD + mysql -e "FLUSH PRIVILEGES;" -uMYSQL_USER -pMYSQL_ROOT_PASSWORD - name: Trilogy test run: bundle exec rake trilogy:test From 334b5a810d29e11e6b7b7fa701433ef75ae9be83 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Mon, 9 Oct 2023 22:42:54 -0700 Subject: [PATCH 17/20] update github envs appropriately --- .github/workflows/trilogy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/trilogy.yml b/.github/workflows/trilogy.yml index e4bd2882..3e98ddc2 100644 --- a/.github/workflows/trilogy.yml +++ b/.github/workflows/trilogy.yml @@ -43,8 +43,8 @@ jobs: MYSQL_ROOT_PASSWORD: root - name: Create user, grant privledges,and flush # workaround to resolve https://github.com/trilogy-libraries/activerecord-trilogy-adapter/issues/64 run: | - mysql -e "CREATE USER 'test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';" -uMYSQL_USER -pMYSQL_ROOT_PASSWORD - mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' WITH GRANT OPTION;" -uMYSQL_USER -pMYSQL_ROOT_PASSWORD - mysql -e "FLUSH PRIVILEGES;" -uMYSQL_USER -pMYSQL_ROOT_PASSWORD + mysql -e "CREATE USER 'test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';" -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} + mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' WITH GRANT OPTION;" -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} + mysql -e "FLUSH PRIVILEGES;" -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} - name: Trilogy test run: bundle exec rake trilogy:test From 1bc20ba1273fca71fc153fb61c206339d689cff8 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Sat, 14 Oct 2023 06:39:38 -0700 Subject: [PATCH 18/20] target host when executing github action --- .github/workflows/trilogy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/trilogy.yml b/.github/workflows/trilogy.yml index 3e98ddc2..b8c2c8f0 100644 --- a/.github/workflows/trilogy.yml +++ b/.github/workflows/trilogy.yml @@ -43,8 +43,8 @@ jobs: MYSQL_ROOT_PASSWORD: root - name: Create user, grant privledges,and flush # workaround to resolve https://github.com/trilogy-libraries/activerecord-trilogy-adapter/issues/64 run: | - mysql -e "CREATE USER 'test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';" -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} - mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' WITH GRANT OPTION;" -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} - mysql -e "FLUSH PRIVILEGES;" -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} + mysql -h 127.0.0.1 -e "CREATE USER 'test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';" -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} + mysql -h 127.0.0.1 -e "GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' WITH GRANT OPTION;" -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} + mysql -h 127.0.0.1 -e "FLUSH PRIVILEGES;" -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} - name: Trilogy test run: bundle exec rake trilogy:test From 9311e0dadc9d464f52cfd128f14746992fa10631 Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Fri, 20 Oct 2023 21:06:05 -0700 Subject: [PATCH 19/20] update workflow and order the args for the mysql command differently --- .github/workflows/trilogy.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/trilogy.yml b/.github/workflows/trilogy.yml index b8c2c8f0..85047d9d 100644 --- a/.github/workflows/trilogy.yml +++ b/.github/workflows/trilogy.yml @@ -41,10 +41,12 @@ jobs: run: bundle exec rake trilogy:rebuild_database env: MYSQL_ROOT_PASSWORD: root - - name: Create user, grant privledges,and flush # workaround to resolve https://github.com/trilogy-libraries/activerecord-trilogy-adapter/issues/64 + - name: Create user, grant privileges, and flush # workaround to resolve https://github.com/trilogy-libraries/activerecord-trilogy-adapter/issues/64 run: | - mysql -h 127.0.0.1 -e "CREATE USER 'test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';" -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} - mysql -h 127.0.0.1 -e "GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' WITH GRANT OPTION;" -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} - mysql -h 127.0.0.1 -e "FLUSH PRIVILEGES;" -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} + mysql -h 127.0.0.1 -e "CREATE USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY 'test';" -uroot -p${{ env.MYSQL_ROOT_PASSWORD }} + mysql -h 127.0.0.1 -e "GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' WITH GRANT OPTION;" -uroot -p${{ env.MYSQL_ROOT_PASSWORD }} + mysql -h 127.0.0.1 -e "FLUSH PRIVILEGES;" -uroot -p${{ env.MYSQL_ROOT_PASSWORD }} + env: + MYSQL_ROOT_PASSWORD: root - name: Trilogy test run: bundle exec rake trilogy:test From f79e913b8e7beee93e19a8bdf81db19d10f2ea4c Mon Sep 17 00:00:00 2001 From: Zack Mariscal Date: Fri, 3 Nov 2023 06:37:44 -0700 Subject: [PATCH 20/20] remove trilogy github action for now --- .github/workflows/trilogy.yml | 52 ----------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 .github/workflows/trilogy.yml diff --git a/.github/workflows/trilogy.yml b/.github/workflows/trilogy.yml deleted file mode 100644 index 85047d9d..00000000 --- a/.github/workflows/trilogy.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: trilogy - -on: [push, pull_request] - -jobs: - trilogy_test: - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - ruby: [2.7, 3.0, 3.1, 3.2] - runs-on: ${{matrix.os}} - services: - mysql: - image: mysql - ports: - - 3306:3306 - env: - MYSQL_ROOT_PASSWORD: root - MYSQL_USER: github - MYSQL_PASSWORD: github - MYSQL_DATABASE: composite_primary_keys_unittest - options: >- - --health-cmd "mysqladmin ping -h localhost" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - env: - BUNDLE_WITHOUT: "db2 oracle sqlserver sqlite postgresql" - BUNDLE_JOBS: 4 - BUNDLE_PATH: vendor/bundle - steps: - - uses: actions/checkout@v3 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{matrix.ruby}} - bundler-cache: true - - name: Setup database config - run: cp test/connections/databases.ci.yml test/connections/databases.yml - - name: Prepare databases - run: bundle exec rake trilogy:rebuild_database - env: - MYSQL_ROOT_PASSWORD: root - - name: Create user, grant privileges, and flush # workaround to resolve https://github.com/trilogy-libraries/activerecord-trilogy-adapter/issues/64 - run: | - mysql -h 127.0.0.1 -e "CREATE USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY 'test';" -uroot -p${{ env.MYSQL_ROOT_PASSWORD }} - mysql -h 127.0.0.1 -e "GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' WITH GRANT OPTION;" -uroot -p${{ env.MYSQL_ROOT_PASSWORD }} - mysql -h 127.0.0.1 -e "FLUSH PRIVILEGES;" -uroot -p${{ env.MYSQL_ROOT_PASSWORD }} - env: - MYSQL_ROOT_PASSWORD: root - - name: Trilogy test - run: bundle exec rake trilogy:test