Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Action to replace Travis #1397

Merged
merged 1 commit into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Test

on:
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
types:
- opened
- synchronize
paths-ignore:
- '**.md'

jobs:
build:
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
ports: [ '5432:5432' ]
options: --health-cmd pg_isready --health-interval 2s --health-timeout 1s --health-retries 10
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby:
- 2.7.2
- 2.6.6
- 2.5.8
- 2.4.10
appraisal:
- rails_6_0
- rails_5_2
- rails_5_1
- rails_5_0
- rails_4_2
adapter:
- sqlite3
- postgresql
exclude:
- { ruby: 2.7.2, appraisal: rails_4_2 }
- { ruby: 2.6.6, appraisal: rails_4_2 }
- { ruby: 2.4.10, appraisal: rails_6_0 }
env:
DATABASE_ADAPTER: ${{ matrix.adapter }}
BUNDLE_GEMFILE: gemfiles/${{ matrix.appraisal }}.gemfile
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
id: set-up-ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- uses: actions/cache@v2
with:
path: vendor/bundle
key: v1-rubygems-local-${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles(format('gemfiles/{0}.gemfile.lock', matrix.rails_appraisal)) }}
- name: Install dependencies
run: bundle install --jobs=3 --retry=3
- name: Run Unit Tests
run: bundle exec rake spec:unit --trace
- name: Run Acceptance Tests
run: bundle exec rake spec:acceptance --trace
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

19 changes: 10 additions & 9 deletions spec/support/acceptance/helpers/step_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,8 @@ def run_n_unit_test_suite

def create_rails_application
fs.clean
command =
if rails_version =~ '~> 6.0'
"bundle exec rails new #{fs.project_directory} --skip-bundle --skip-javascript --no-rc"
else
"bundle exec rails new #{fs.project_directory} --skip-bundle --no-rc"
end

run_command!(command) do |runner|
run_command!(rails_new_command) do |runner|
runner.directory = nil
end

Expand All @@ -76,11 +70,18 @@ def create_rails_application
bundle.remove_gem 'debugger'
bundle.remove_gem 'byebug'
bundle.remove_gem 'web-console'
bundle.add_gem 'pg'
end

fs.open('config/database.yml', 'w') do |file|
YAML.dump(database.config.to_hash, file)
YAML.dump(database.config.load_file, file)
end
end

def rails_new_command
if rails_version =~ '~> 6.0'
"bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --skip-javascript --no-rc"
else
"bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --no-rc"
end
end

Expand Down
19 changes: 19 additions & 0 deletions spec/support/tests/database_adapters/config/postgresql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
host: <%= ENV.fetch("DB_HOST", "localhost") %>
username: <%= ENV.fetch("DB_USER", "postgres") %>
password: <%= ENV.fetch("DB_USER_PASSWORD", "postgres") %>

development:
<<: *default
database: shoulda-matchers-test_development

test:
<<: *default
database: shoulda-matchers-test_test

production:
<<: *default
database: shoulda-matchers-test_production
16 changes: 16 additions & 0 deletions spec/support/tests/database_adapters/config/sqlite3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000

development:
<<: *default
database: db/development.sqlite3

test:
<<: *default
database: db/test.sqlite3

production:
<<: *default
database: db/production.sqlite3
11 changes: 2 additions & 9 deletions spec/support/tests/database_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

module Tests
class DatabaseConfiguration < SimpleDelegator
ENVIRONMENTS = %w(development test production).freeze

attr_reader :adapter_class

def self.for(database_name, adapter_name)
Expand All @@ -18,13 +16,8 @@ def initialize(config)
super(config)
end

def to_hash
ENVIRONMENTS.each_with_object({}) do |env, config_as_hash|
config_as_hash[env] = {
'adapter' => adapter.to_s,
'database' => "#{database}_#{env}",
}
end
def load_file
YAML::load_file(File.join(__dir__, "database_adapters/config/#{adapter}.yml"))
end
end
end
6 changes: 3 additions & 3 deletions spec/support/unit/rails_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def rails_new_command
'rails',
'new',
fs.project_directory.to_s,
"--database=#{database.adapter_name}",
'--skip-bundle',
'--no-rc',
'--skip-webpack-install',
Expand All @@ -106,6 +107,7 @@ def rails_new_command
'rails',
'new',
fs.project_directory.to_s,
"--database=#{database.adapter_name}",
'--skip-bundle',
'--no-rc',
]
Expand Down Expand Up @@ -135,7 +137,7 @@ def remove_bootsnap
end

def write_database_configuration
YAML.dump(database.config.to_hash, fs.open('config/database.yml', 'w'))
YAML.dump(database.config.load_file, fs.open('config/database.yml', 'w'))
end

def write_activerecord_model_with_different_connection
Expand Down Expand Up @@ -201,8 +203,6 @@ def update_gems
bundle.remove_gem 'debugger'
bundle.remove_gem 'byebug'
bundle.remove_gem 'web-console'
bundle.add_gem 'pg'
bundle.add_gem 'sqlite', '~> 1.3.6'
end
end

Expand Down