Skip to content

Commit

Permalink
Move tests to Github actions & update tests matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
j15e committed May 28, 2021
1 parent 2a2f555 commit 20aa7ff
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 32 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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

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
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

6 changes: 0 additions & 6 deletions test/gemfiles/Gemfile.rails-3.1.x

This file was deleted.

6 changes: 0 additions & 6 deletions test/gemfiles/Gemfile.rails-3.2.x

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions test/gemfiles/rails-edge.gemfile
Original file line number Diff line number Diff line change
@@ -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
13 changes: 11 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 20aa7ff

Please sign in to comment.