From ac566629e7998145432e9f35b3a59aafdaa6d075 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Doyle Date: Fri, 28 May 2021 16:18:03 -0400 Subject: [PATCH] Move tests to Github actions & update tests matrix --- .github/workflows/verify.yml | 52 +++++++++++++++++++ .travis.yml | 16 ------ test/gemfiles/Gemfile.rails-3.1.x | 6 --- test/gemfiles/Gemfile.rails-3.2.x | 6 --- ...emfile.rails-4.1.x => rails-6.0.x.gemfile} | 2 +- ...emfile.rails-4.0.x => rails-6.1.x.gemfile} | 2 +- test/gemfiles/rails-edge.gemfile | 9 ++++ test/test_helper.rb | 13 ++++- 8 files changed, 74 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/verify.yml delete mode 100644 .travis.yml delete mode 100644 test/gemfiles/Gemfile.rails-3.1.x delete mode 100644 test/gemfiles/Gemfile.rails-3.2.x rename test/gemfiles/{Gemfile.rails-4.1.x => rails-6.0.x.gemfile} (82%) rename test/gemfiles/{Gemfile.rails-4.0.x => rails-6.1.x.gemfile} (82%) create mode 100644 test/gemfiles/rails-edge.gemfile diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..ffba2a3 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,52 @@ +name: Verify +on: [push] + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + strategy: + matrix: + gemfile: + - rails-6.0.x + - rails-6.1.x + - rails-edge + ruby-version: + - 2.6 + - 2.7 + - head + exclude: + # activesupport-7.0.0.alpha requires ruby version >= 2.7.0, which is incompatible + - gemfile: rails-edge + ruby-version: 2.7 + + continue-on-error: ${{ endsWith(matrix.gemfile, 'edge') || matrix.ruby-version == 'head' }} + + env: + RAILS_ENV: test + DATABASE_URL: postgresql://test:test@localhost/hstore_translate_test + BUNDLE_GEMFILE: test/gemfiles/${{ matrix.gemfile }}.gemfile + + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: test + POSTGRES_USER: test + POSTGRES_DB: hstore_translate_test + ports: + - 5432:5432 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Ruby ${{ matrix.ruby-version }} and install ${{ matrix.gemfile }} gems + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: ${{ matrix.ruby-version }} + + - name: Run tests + run: bundle exec rake diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6a8b2b4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -rvm: - - 1.9.3 - - 2.0.0 - - rbx - - jruby-19mode -gemfile: - - test/gemfiles/Gemfile.rails-3.1.x - - test/gemfiles/Gemfile.rails-3.2.x - - test/gemfiles/Gemfile.rails-4.0.x - - test/gemfiles/Gemfile.rails-4.1.x -matrix: - exclude: - - rvm: jruby-19mode - gemfile: test/gemfiles/Gemfile.rails-3.1.x - - rvm: jruby-19mode - gemfile: test/gemfiles/Gemfile.rails-3.2.x diff --git a/test/gemfiles/Gemfile.rails-3.1.x b/test/gemfiles/Gemfile.rails-3.1.x deleted file mode 100644 index f616278..0000000 --- a/test/gemfiles/Gemfile.rails-3.1.x +++ /dev/null @@ -1,6 +0,0 @@ -source 'https://rubygems.org' -gemspec :path => './../..' - -gem 'pg' -gem 'activerecord', '~> 3.1.0' -gem 'activerecord-postgres-hstore', '~> 0.7.0' diff --git a/test/gemfiles/Gemfile.rails-3.2.x b/test/gemfiles/Gemfile.rails-3.2.x deleted file mode 100644 index 4511c37..0000000 --- a/test/gemfiles/Gemfile.rails-3.2.x +++ /dev/null @@ -1,6 +0,0 @@ -source 'https://rubygems.org' -gemspec :path => './../..' - -gem 'pg' -gem 'activerecord', '~> 3.2.0' -gem 'activerecord-postgres-hstore', '~> 0.7.0' diff --git a/test/gemfiles/Gemfile.rails-4.1.x b/test/gemfiles/rails-6.0.x.gemfile similarity index 82% rename from test/gemfiles/Gemfile.rails-4.1.x rename to test/gemfiles/rails-6.0.x.gemfile index f3d678a..1ca380f 100644 --- a/test/gemfiles/Gemfile.rails-4.1.x +++ b/test/gemfiles/rails-6.0.x.gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' gemspec :path => './../..' -gem 'activerecord', '~> 4.1.0' +gem 'activerecord', '~> 6.0.0' gem 'pg', :platform => :ruby gem 'activerecord-jdbcpostgresql-adapter', :platform => :jruby diff --git a/test/gemfiles/Gemfile.rails-4.0.x b/test/gemfiles/rails-6.1.x.gemfile similarity index 82% rename from test/gemfiles/Gemfile.rails-4.0.x rename to test/gemfiles/rails-6.1.x.gemfile index 669726f..41a5be0 100644 --- a/test/gemfiles/Gemfile.rails-4.0.x +++ b/test/gemfiles/rails-6.1.x.gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' gemspec :path => './../..' -gem 'activerecord', '~> 4.0.0' +gem 'activerecord', '~> 6.1.0' gem 'pg', :platform => :ruby gem 'activerecord-jdbcpostgresql-adapter', :platform => :jruby diff --git a/test/gemfiles/rails-edge.gemfile b/test/gemfiles/rails-edge.gemfile new file mode 100644 index 0000000..4d6ef52 --- /dev/null +++ b/test/gemfiles/rails-edge.gemfile @@ -0,0 +1,9 @@ +source 'https://rubygems.org' +gemspec :path => './../..' + +git 'https://github.com/rails/rails.git' do + gem 'activerecord' +end + +gem 'pg', :platform => :ruby +gem 'activerecord-jdbcpostgresql-adapter', :platform => :jruby diff --git a/test/test_helper.rb b/test/test_helper.rb index c6d2c50..76d9c5c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -21,6 +21,8 @@ def prepare_database def db_config @db_config ||= begin + return ENV['DATABASE_URL'] if ENV['DATABASE_URL'] + filepath = File.join('test', 'database.yml') YAML.load_file(filepath)['test'] end @@ -32,9 +34,16 @@ def establish_connection(config) end def create_database - system_config = db_config.merge('database' => 'postgres', 'schema_search_path' => 'public') + # Using default postgres database to connect to create test database + system_config = + if db_config.is_a?(String) + db_config.gsub("/hstore_translate_test", "/postgres") + else + db_config.merge('database' => 'postgres', 'schema_search_path' => 'public') + end + connection = establish_connection(system_config) - connection.create_database(db_config['database']) rescue nil + connection.create_database("hstore_translate_test") rescue nil enable_extension end