From b9bcf0739434f1bf3dfb644253a9e8d29358f901 Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Fri, 30 Aug 2024 17:55:38 +0900 Subject: [PATCH 01/17] Add integration_test --- integration_test.dockerfile | 14 ++++++++ integration_test/Gemfile | 7 ++++ integration_test/arproxy | 1 + integration_test/docker-compose.yml | 51 ++++++++++++++++++++++++++++ integration_test/spec/mysql_spec.rb | 46 +++++++++++++++++++++++++ integration_test/spec/spec_helper.rb | 28 +++++++++++++++ 6 files changed, 147 insertions(+) create mode 100644 integration_test.dockerfile create mode 100644 integration_test/Gemfile create mode 120000 integration_test/arproxy create mode 100644 integration_test/docker-compose.yml create mode 100644 integration_test/spec/mysql_spec.rb create mode 100644 integration_test/spec/spec_helper.rb diff --git a/integration_test.dockerfile b/integration_test.dockerfile new file mode 100644 index 0000000..e108212 --- /dev/null +++ b/integration_test.dockerfile @@ -0,0 +1,14 @@ +FROM ruby:3.3 + +RUN apt-get update && apt-get install -y \ + libmariadb-dev \ + libpq-dev + +COPY integration_test/Gemfile integration_test/Gemfile.lock /app/ +COPY integration_test/spec /app/spec/ + +COPY lib /app/arproxy/lib/ +COPY arproxy.gemspec /app/arproxy/arproxy.gemspec + +WORKDIR /app +RUN bundle install diff --git a/integration_test/Gemfile b/integration_test/Gemfile new file mode 100644 index 0000000..e909cc7 --- /dev/null +++ b/integration_test/Gemfile @@ -0,0 +1,7 @@ +source 'https://rubygems.org' + +gem 'arproxy', path: './arproxy' +gem 'activerecord', '~> 6.0' +gem 'rspec' +gem 'mysql2' +gem 'pg' diff --git a/integration_test/arproxy b/integration_test/arproxy new file mode 120000 index 0000000..b870225 --- /dev/null +++ b/integration_test/arproxy @@ -0,0 +1 @@ +../ \ No newline at end of file diff --git a/integration_test/docker-compose.yml b/integration_test/docker-compose.yml new file mode 100644 index 0000000..52d5e2e --- /dev/null +++ b/integration_test/docker-compose.yml @@ -0,0 +1,51 @@ +version: '3' + +services: + app: + build: + context: .. + dockerfile: integration_test.dockerfile + no_cache: true + depends_on: + mysql: + condition: service_healthy + postgres: + condition: service_healthy + environment: + - MYSQL_HOST=mysql + - MYSQL_PORT=3306 + - POSTGRES_HOST=postgres + - POSTGRES_PORT=25432 + working_dir: /app + command: ["bundle", "exec", "rspec"] + + mysql: + image: mysql:9.0 + restart: always + environment: + MYSQL_ROOT_PASSWORD: rootpassword + MYSQL_DATABASE: arproxy_test + MYSQL_USER: arproxy + MYSQL_PASSWORD: password + ports: + - "23306:3306" + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + interval: 2s + timeout: 2s + retries: 5 + + postgres: + image: postgres:16 + restart: always + environment: + POSTGRES_DB: arproxy_test + POSTGRES_USER: arproxy + POSTGRES_PASSWORD: password + ports: + - "25432:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready -h localhost -U arproxy -d arproxy_test"] + interval: 2s + timeout: 2s + retries: 5 diff --git a/integration_test/spec/mysql_spec.rb b/integration_test/spec/mysql_spec.rb new file mode 100644 index 0000000..db691ff --- /dev/null +++ b/integration_test/spec/mysql_spec.rb @@ -0,0 +1,46 @@ +require_relative 'spec_helper' +require 'mysql2' + +context 'MySQL' do + before(:all) do + ActiveRecord::Base.establish_connection( + adapter: 'mysql2', + host: ENV.fetch('MYSQL_HOST', '127.0.0.1'), + port: ENV.fetch('MYSQL_PORT', '23306').to_i, + database: 'arproxy_test', + username: 'arproxy', + password: 'password' + ) + + Arproxy.configure do |config| + config.adapter = 'mysql2' + config.use HelloProxy + config.use QueryLogger + end + Arproxy.enable! + + ActiveRecord::Base.connection.create_table :products, force: true do |t| + t.string :name + t.integer :price + end + + Product.create(name: 'apple', price: 100) + Product.create(name: 'banana', price: 200) + Product.create(name: 'orange', price: 300) + end + + before(:each) do + QueryLogger.reset! + end + + it do + expect(QueryLogger.log.size).to eq(0) + + expect(Product.count).to eq(3) + expect(Product.first.name).to eq('apple') + + expect(QueryLogger.log.size).to eq(2) + expect(QueryLogger.log[0]).to eq('SELECT COUNT(*) FROM `products` -- Hello Arproxy!') + expect(QueryLogger.log[1]).to eq('SELECT `products`.* FROM `products` ORDER BY `products`.`id` ASC LIMIT 1 -- Hello Arproxy!') + end +end diff --git a/integration_test/spec/spec_helper.rb b/integration_test/spec/spec_helper.rb new file mode 100644 index 0000000..869dec6 --- /dev/null +++ b/integration_test/spec/spec_helper.rb @@ -0,0 +1,28 @@ +require 'arproxy' +require 'active_record' + +class Product < ActiveRecord::Base +end + +class QueryLogger < Arproxy::Base + def execute(sql, name = nil) + @@log ||= [] + @@log << sql + puts "QueryLogger: #{sql}" + super + end + + def self.log + @@log + end + + def self.reset! + @@log = [] + end +end + +class HelloProxy < Arproxy::Base + def execute(sql, name = nil) + super("#{sql} -- Hello Arproxy!", name) + end +end From 0f5c7dca6b9fc6473fa662a473888fd0253ffb53 Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 13:32:38 +0900 Subject: [PATCH 02/17] Add Appraisals for integration_test --- .gitignore | 2 +- integration_test.dockerfile | 8 +++++++- integration_test/Appraisals | 1 + integration_test/Gemfile | 2 +- integration_test/docker-compose.yml | 2 +- integration_test/gemfiles/ar_6.1.gemfile | 10 ++++++++++ integration_test/gemfiles/ar_7.0.gemfile | 10 ++++++++++ integration_test/gemfiles/ar_7.1.gemfile | 10 ++++++++++ 8 files changed, 41 insertions(+), 4 deletions(-) create mode 120000 integration_test/Appraisals create mode 100644 integration_test/gemfiles/ar_6.1.gemfile create mode 100644 integration_test/gemfiles/ar_7.0.gemfile create mode 100644 integration_test/gemfiles/ar_7.1.gemfile diff --git a/.gitignore b/.gitignore index e786654..df4805e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *.swp *.gem Gemfile.lock -gemfiles/*.lock +*.gemfile.lock .bundle/ diff --git a/integration_test.dockerfile b/integration_test.dockerfile index e108212..bb587c9 100644 --- a/integration_test.dockerfile +++ b/integration_test.dockerfile @@ -4,11 +4,17 @@ RUN apt-get update && apt-get install -y \ libmariadb-dev \ libpq-dev -COPY integration_test/Gemfile integration_test/Gemfile.lock /app/ +COPY integration_test/Gemfile \ + integration_test/Appraisals \ + /app/ + COPY integration_test/spec /app/spec/ +COPY integration_test/gemfiles /app/gemfiles/ COPY lib /app/arproxy/lib/ COPY arproxy.gemspec /app/arproxy/arproxy.gemspec WORKDIR /app + RUN bundle install +RUN bundle exec appraisal install diff --git a/integration_test/Appraisals b/integration_test/Appraisals new file mode 120000 index 0000000..526794e --- /dev/null +++ b/integration_test/Appraisals @@ -0,0 +1 @@ +../Appraisals \ No newline at end of file diff --git a/integration_test/Gemfile b/integration_test/Gemfile index e909cc7..e93279b 100644 --- a/integration_test/Gemfile +++ b/integration_test/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' gem 'arproxy', path: './arproxy' -gem 'activerecord', '~> 6.0' gem 'rspec' +gem 'appraisal' gem 'mysql2' gem 'pg' diff --git a/integration_test/docker-compose.yml b/integration_test/docker-compose.yml index 52d5e2e..b4749d1 100644 --- a/integration_test/docker-compose.yml +++ b/integration_test/docker-compose.yml @@ -17,7 +17,7 @@ services: - POSTGRES_HOST=postgres - POSTGRES_PORT=25432 working_dir: /app - command: ["bundle", "exec", "rspec"] + command: ["bundle", "exec", "appraisal", "rspec"] mysql: image: mysql:9.0 diff --git a/integration_test/gemfiles/ar_6.1.gemfile b/integration_test/gemfiles/ar_6.1.gemfile new file mode 100644 index 0000000..6daa42d --- /dev/null +++ b/integration_test/gemfiles/ar_6.1.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "arproxy", path: "../arproxy" +gem "rspec" +gem "appraisal" +gem "mysql2" +gem "pg" +gem "activerecord", "~> 6.1.0" diff --git a/integration_test/gemfiles/ar_7.0.gemfile b/integration_test/gemfiles/ar_7.0.gemfile new file mode 100644 index 0000000..74a6281 --- /dev/null +++ b/integration_test/gemfiles/ar_7.0.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "arproxy", path: "../arproxy" +gem "rspec" +gem "appraisal" +gem "mysql2" +gem "pg" +gem "activerecord", "~> 7.0.0" diff --git a/integration_test/gemfiles/ar_7.1.gemfile b/integration_test/gemfiles/ar_7.1.gemfile new file mode 100644 index 0000000..1d33a46 --- /dev/null +++ b/integration_test/gemfiles/ar_7.1.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "arproxy", path: "../arproxy" +gem "rspec" +gem "appraisal" +gem "mysql2" +gem "pg" +gem "activerecord", "~> 7.1.0" From 982d15c5c0d75f94482600b87b2dc2e2e3b423ef Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 14:45:47 +0900 Subject: [PATCH 03/17] Add postgresql_spec --- integration_test/spec/postgresql_spec.rb | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 integration_test/spec/postgresql_spec.rb diff --git a/integration_test/spec/postgresql_spec.rb b/integration_test/spec/postgresql_spec.rb new file mode 100644 index 0000000..737fe39 --- /dev/null +++ b/integration_test/spec/postgresql_spec.rb @@ -0,0 +1,52 @@ +require_relative 'spec_helper' +require 'pg' + +context 'PostgreSQL' do + before(:all) do + ActiveRecord::Base.establish_connection( + adapter: 'postgresql', + host: ENV.fetch('POSTGRES_HOST', '127.0.0.1'), + port: ENV.fetch('POSTGRES_PORT', '25432').to_i, + database: 'arproxy_test', + username: 'arproxy', + password: 'password' + ) + + Arproxy.configure do |config| + config.adapter = 'postgresql' + config.use HelloProxy + config.use QueryLogger + end + Arproxy.enable! + + ActiveRecord::Base.connection.create_table :products, force: true do |t| + t.string :name + t.integer :price + end + + Product.create(name: 'apple', price: 100) + Product.create(name: 'banana', price: 200) + Product.create(name: 'orange', price: 300) + end + + after(:all) do + ActiveRecord::Base.connection.drop_table :products + ActiveRecord::Base.connection.close + Arproxy.disable! + end + + before(:each) do + QueryLogger.reset! + end + + it do + expect(QueryLogger.log.size).to eq(0) + + expect(Product.count).to eq(3) + expect(Product.first.name).to eq('apple') + + expect(QueryLogger.log.size).to eq(2) + expect(QueryLogger.log[0]).to eq('SELECT COUNT(*) FROM `products` -- Hello Arproxy!') + expect(QueryLogger.log[1]).to eq('SELECT `products`.* FROM `products` ORDER BY `products`.`id` ASC LIMIT 1 -- Hello Arproxy!') + end +end From 257adee869a7ca014aed89cf97278c41433e9f54 Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 14:45:59 +0900 Subject: [PATCH 04/17] close AR connection after(:all) --- integration_test/spec/mysql_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/integration_test/spec/mysql_spec.rb b/integration_test/spec/mysql_spec.rb index db691ff..d5dca8a 100644 --- a/integration_test/spec/mysql_spec.rb +++ b/integration_test/spec/mysql_spec.rb @@ -29,6 +29,12 @@ Product.create(name: 'orange', price: 300) end + after(:all) do + ActiveRecord::Base.connection.drop_table :products + ActiveRecord::Base.connection.close + Arproxy.disable! + end + before(:each) do QueryLogger.reset! end From 7684765eeff8a6bd69ef7a0a9f362f6ba9ab7f37 Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 15:08:40 +0900 Subject: [PATCH 05/17] Rename mysql2_spec --- integration_test/spec/{mysql_spec.rb => mysql2_spec.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename integration_test/spec/{mysql_spec.rb => mysql2_spec.rb} (100%) diff --git a/integration_test/spec/mysql_spec.rb b/integration_test/spec/mysql2_spec.rb similarity index 100% rename from integration_test/spec/mysql_spec.rb rename to integration_test/spec/mysql2_spec.rb From 9a0e9029e9423c3434709c2162d3aa3688aaf2c1 Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 15:08:56 +0900 Subject: [PATCH 06/17] Remove app --- integration_test.dockerfile | 20 -------------------- integration_test/Gemfile | 2 +- integration_test/arproxy | 1 - integration_test/docker-compose.yml | 28 ---------------------------- 4 files changed, 1 insertion(+), 50 deletions(-) delete mode 100644 integration_test.dockerfile delete mode 120000 integration_test/arproxy diff --git a/integration_test.dockerfile b/integration_test.dockerfile deleted file mode 100644 index bb587c9..0000000 --- a/integration_test.dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM ruby:3.3 - -RUN apt-get update && apt-get install -y \ - libmariadb-dev \ - libpq-dev - -COPY integration_test/Gemfile \ - integration_test/Appraisals \ - /app/ - -COPY integration_test/spec /app/spec/ -COPY integration_test/gemfiles /app/gemfiles/ - -COPY lib /app/arproxy/lib/ -COPY arproxy.gemspec /app/arproxy/arproxy.gemspec - -WORKDIR /app - -RUN bundle install -RUN bundle exec appraisal install diff --git a/integration_test/Gemfile b/integration_test/Gemfile index e93279b..7577434 100644 --- a/integration_test/Gemfile +++ b/integration_test/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'arproxy', path: './arproxy' +gem 'arproxy', path: '..' gem 'rspec' gem 'appraisal' gem 'mysql2' diff --git a/integration_test/arproxy b/integration_test/arproxy deleted file mode 120000 index b870225..0000000 --- a/integration_test/arproxy +++ /dev/null @@ -1 +0,0 @@ -../ \ No newline at end of file diff --git a/integration_test/docker-compose.yml b/integration_test/docker-compose.yml index b4749d1..18ccaeb 100644 --- a/integration_test/docker-compose.yml +++ b/integration_test/docker-compose.yml @@ -1,24 +1,6 @@ version: '3' services: - app: - build: - context: .. - dockerfile: integration_test.dockerfile - no_cache: true - depends_on: - mysql: - condition: service_healthy - postgres: - condition: service_healthy - environment: - - MYSQL_HOST=mysql - - MYSQL_PORT=3306 - - POSTGRES_HOST=postgres - - POSTGRES_PORT=25432 - working_dir: /app - command: ["bundle", "exec", "appraisal", "rspec"] - mysql: image: mysql:9.0 restart: always @@ -29,11 +11,6 @@ services: MYSQL_PASSWORD: password ports: - "23306:3306" - healthcheck: - test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] - interval: 2s - timeout: 2s - retries: 5 postgres: image: postgres:16 @@ -44,8 +21,3 @@ services: POSTGRES_PASSWORD: password ports: - "25432:5432" - healthcheck: - test: ["CMD-SHELL", "pg_isready -h localhost -U arproxy -d arproxy_test"] - interval: 2s - timeout: 2s - retries: 5 From 5f69a1980c947289def09916d6891dfd24ac6958 Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 15:09:13 +0900 Subject: [PATCH 07/17] Add integration test workflows --- .github/workflows/integration_test.yml | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/integration_test.yml diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml new file mode 100644 index 0000000..f134396 --- /dev/null +++ b/.github/workflows/integration_test.yml @@ -0,0 +1,36 @@ +name: Integration Test + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + start_dbs: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./integration_test + steps: + - name: Start DBs + run: docker compose up -d + + integration_test: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./integration_test + env: + MYSQL_HOST: 127.0.0.1 + POSTGRES_HOST: 127.0.0.1 + strategy: + matrix: + adapter: ['mysql2', 'postgresql'] + gemfile: ['ar_6.1', 'ar_7.0', 'ar_7.1'] + steps: + - uses: actions/checkout@v2 + - name: Run integration test + run: BUNDLE_GEMFILE=gemfiles/${{ matrix.gemfile }}.gemfile bundle exec rspec spec/${{ matrix.adapter }}_spec.rb From 4072abdcd190f8815aedc388f9106855ce8ececa Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 15:35:23 +0900 Subject: [PATCH 08/17] Appraisal install --- integration_test/gemfiles/ar_6.1.gemfile | 2 +- integration_test/gemfiles/ar_7.0.gemfile | 2 +- integration_test/gemfiles/ar_7.1.gemfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/integration_test/gemfiles/ar_6.1.gemfile b/integration_test/gemfiles/ar_6.1.gemfile index 6daa42d..24d1563 100644 --- a/integration_test/gemfiles/ar_6.1.gemfile +++ b/integration_test/gemfiles/ar_6.1.gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" -gem "arproxy", path: "../arproxy" +gem "arproxy", path: "../.." gem "rspec" gem "appraisal" gem "mysql2" diff --git a/integration_test/gemfiles/ar_7.0.gemfile b/integration_test/gemfiles/ar_7.0.gemfile index 74a6281..72e4b83 100644 --- a/integration_test/gemfiles/ar_7.0.gemfile +++ b/integration_test/gemfiles/ar_7.0.gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" -gem "arproxy", path: "../arproxy" +gem "arproxy", path: "../.." gem "rspec" gem "appraisal" gem "mysql2" diff --git a/integration_test/gemfiles/ar_7.1.gemfile b/integration_test/gemfiles/ar_7.1.gemfile index 1d33a46..5273122 100644 --- a/integration_test/gemfiles/ar_7.1.gemfile +++ b/integration_test/gemfiles/ar_7.1.gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" -gem "arproxy", path: "../arproxy" +gem "arproxy", path: "../.." gem "rspec" gem "appraisal" gem "mysql2" From e632ffeaf101ba1bcd1394c7455e93a594b446ff Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 15:38:40 +0900 Subject: [PATCH 09/17] Update integration_test.yml --- .github/workflows/integration_test.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index f134396..9461a8c 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -32,5 +32,15 @@ jobs: gemfile: ['ar_6.1', 'ar_7.0', 'ar_7.1'] steps: - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + - name: Run bundle install + env: + BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile + run: bundle install - name: Run integration test - run: BUNDLE_GEMFILE=gemfiles/${{ matrix.gemfile }}.gemfile bundle exec rspec spec/${{ matrix.adapter }}_spec.rb + env: + BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile + run: bundle exec rspec spec/${{ matrix.adapter }}_spec.rb From c90ddfbfe84e399ff5369a2765c1493badd50510 Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 15:41:23 +0900 Subject: [PATCH 10/17] Add actions/checkout before docker compose up --- .github/workflows/integration_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 9461a8c..5ce4704 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -15,6 +15,7 @@ jobs: run: working-directory: ./integration_test steps: + - uses: actions/checkout@v2 - name: Start DBs run: docker compose up -d From ed5e038f2d859dcf4bd776ec3e4a9590f5d2c9ee Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 15:47:19 +0900 Subject: [PATCH 11/17] Update integration_test.yml --- .github/workflows/integration_test.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 5ce4704..44d940d 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -9,16 +9,6 @@ on: - master jobs: - start_dbs: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./integration_test - steps: - - uses: actions/checkout@v2 - - name: Start DBs - run: docker compose up -d - integration_test: runs-on: ubuntu-latest defaults: @@ -29,10 +19,18 @@ jobs: POSTGRES_HOST: 127.0.0.1 strategy: matrix: - adapter: ['mysql2', 'postgresql'] - gemfile: ['ar_6.1', 'ar_7.0', 'ar_7.1'] + adapter: + - mysql2 + - postgresql + gemfile: + - ar_6.1 + - ar_7.0 + - ar_7.1 + steps: - uses: actions/checkout@v2 + - name: Start DBs + run: docker compose up -d - name: Set up Ruby uses: ruby/setup-ruby@v1 with: From c3c601148e9ae4ba1acb9222ad6bafc41a78cc4b Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 15:59:47 +0900 Subject: [PATCH 12/17] Separate mysql and postgresql --- .github/workflows/integration_test.yml | 41 +++++++++++++++++++++----- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 44d940d..02e6ba3 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -9,28 +9,53 @@ on: - master jobs: - integration_test: + mysql: runs-on: ubuntu-latest defaults: run: working-directory: ./integration_test env: MYSQL_HOST: 127.0.0.1 - POSTGRES_HOST: 127.0.0.1 strategy: matrix: - adapter: - - mysql2 - - postgresql gemfile: - ar_6.1 - ar_7.0 - ar_7.1 + steps: + - uses: actions/checkout@v2 + - name: Start DB + run: docker compose up -d mysql + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + - name: Run bundle install + env: + BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile + run: bundle install + - name: Run integration test + env: + BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile + run: bundle exec rspec spec/mysql2_spec.rb + postgresql: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./integration_test + env: + POSTGRES_HOST: 127.0.0.1 + strategy: + matrix: + gemfile: + - ar_6.1 + - ar_7.0 + - ar_7.1 steps: - uses: actions/checkout@v2 - - name: Start DBs - run: docker compose up -d + - name: Start DB + run: docker compose up -d postgres - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -42,4 +67,4 @@ jobs: - name: Run integration test env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile - run: bundle exec rspec spec/${{ matrix.adapter }}_spec.rb + run: bundle exec rspec spec/postgresql_spec.rb From 9be48faa2e043a8657845425375d25ff558858c0 Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 16:02:03 +0900 Subject: [PATCH 13/17] Set RUBY_VERSION --- .github/workflows/integration_test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 02e6ba3..91f7455 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -8,6 +8,9 @@ on: branches: - master +env: + RUBY_VERSION: 3.3 + jobs: mysql: runs-on: ubuntu-latest @@ -29,7 +32,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.3 + ruby-version: ${{ env.RUBY_VERSION }} - name: Run bundle install env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile @@ -59,7 +62,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.3 + ruby-version: ${{ env.RUBY_VERSION }} - name: Run bundle install env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile From 395da46fd379ccbf47b9556c1d06629fd1722c4e Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 16:04:33 +0900 Subject: [PATCH 14/17] Set continue-on-error --- .github/workflows/integration_test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 91f7455..fbd31fa 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -13,6 +13,7 @@ env: jobs: mysql: + continue-on-error: true runs-on: ubuntu-latest defaults: run: @@ -43,6 +44,7 @@ jobs: run: bundle exec rspec spec/mysql2_spec.rb postgresql: + continue-on-error: true runs-on: ubuntu-latest defaults: run: From cf05ea90540d43d65dfa3cd05b12b638f67e2c97 Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 16:11:35 +0900 Subject: [PATCH 15/17] refactor integration_test.yml --- .github/workflows/integration_test.yml | 51 +++++--------------------- 1 file changed, 10 insertions(+), 41 deletions(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index fbd31fa..050d273 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -8,11 +8,9 @@ on: branches: - master -env: - RUBY_VERSION: 3.3 - jobs: - mysql: + integration_test: + name: Test with ${{ matrix.gemfile }} continue-on-error: true runs-on: ubuntu-latest defaults: @@ -20,37 +18,8 @@ jobs: working-directory: ./integration_test env: MYSQL_HOST: 127.0.0.1 - strategy: - matrix: - gemfile: - - ar_6.1 - - ar_7.0 - - ar_7.1 - steps: - - uses: actions/checkout@v2 - - name: Start DB - run: docker compose up -d mysql - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ env.RUBY_VERSION }} - - name: Run bundle install - env: - BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile - run: bundle install - - name: Run integration test - env: - BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile - run: bundle exec rspec spec/mysql2_spec.rb - - postgresql: - continue-on-error: true - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./integration_test - env: POSTGRES_HOST: 127.0.0.1 + BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile strategy: matrix: gemfile: @@ -60,16 +29,16 @@ jobs: steps: - uses: actions/checkout@v2 - name: Start DB - run: docker compose up -d postgres + run: docker compose up -d - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ env.RUBY_VERSION }} + ruby-version: 3.3 - name: Run bundle install - env: - BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile run: bundle install - - name: Run integration test - env: - BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile + - name: Run mysql2 test + continue-on-error: true + run: bundle exec rspec spec/mysql2_spec.rb + - name: Run postgresql test + continue-on-error: true run: bundle exec rspec spec/postgresql_spec.rb From 29405aae4fbe4ffde6f04f7b3e85b6f83a1a4ced Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 16:14:41 +0900 Subject: [PATCH 16/17] refactor integration_test.yml --- .github/workflows/integration_test.yml | 45 ++++++++++++++++++++------ 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 050d273..a307945 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -8,18 +8,19 @@ on: branches: - master +env: + RUBY_VERSION: 3.3 + jobs: - integration_test: - name: Test with ${{ matrix.gemfile }} + mysql: continue-on-error: true runs-on: ubuntu-latest defaults: run: working-directory: ./integration_test env: - MYSQL_HOST: 127.0.0.1 - POSTGRES_HOST: 127.0.0.1 BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile + MYSQL_HOST: 127.0.0.1 strategy: matrix: gemfile: @@ -29,16 +30,40 @@ jobs: steps: - uses: actions/checkout@v2 - name: Start DB - run: docker compose up -d + run: docker compose up -d mysql - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.3 + ruby-version: ${{ env.RUBY_VERSION }} - name: Run bundle install run: bundle install - - name: Run mysql2 test - continue-on-error: true + - name: Run integration test run: bundle exec rspec spec/mysql2_spec.rb - - name: Run postgresql test - continue-on-error: true + + postgresql: + continue-on-error: true + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./integration_test + env: + BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile + POSTGRES_HOST: 127.0.0.1 + strategy: + matrix: + gemfile: + - ar_6.1 + - ar_7.0 + - ar_7.1 + steps: + - uses: actions/checkout@v2 + - name: Start DB + run: docker compose up -d postgres + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ env.RUBY_VERSION }} + - name: Run bundle install + run: bundle install + - name: Run integration test run: bundle exec rspec spec/postgresql_spec.rb From 36caa3c95dc000aed3e38fdffc797ebfc5ad2792 Mon Sep 17 00:00:00 2001 From: Issei Naruta Date: Sat, 31 Aug 2024 16:17:09 +0900 Subject: [PATCH 17/17] Update actions/checkout --- .github/workflows/integration_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index a307945..f44c877 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -28,7 +28,7 @@ jobs: - ar_7.0 - ar_7.1 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Start DB run: docker compose up -d mysql - name: Set up Ruby @@ -56,7 +56,7 @@ jobs: - ar_7.0 - ar_7.1 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Start DB run: docker compose up -d postgres - name: Set up Ruby