Skip to content

Commit

Permalink
Switch to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiculescu committed Dec 10, 2020
1 parent 155dd5b commit 8a1e071
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 2 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Test & lint
on: [push]

env:
RAILS_ENV: test
PGHOST: localhost
PGUSER: postgres

jobs:
tests:
name: Test & lint
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
ruby: ['2.3.5', '2.4.2', '2.5.1', '2.6.3', '2.7.0']
gemfile: ['gemfiles/activerecord_4.2.0.gemfile', 'gemfiles/activerecord_5.0.2.gemfile', 'gemfiles/activerecord_5.1.0.gemfile', 'gemfiles/activerecord_5.2.2.gemfile', 'gemfiles/activerecord_6.0.0.gemfile']
exclude:
- gemfile: 'gemfiles/activerecord_4.2.0.gemfile'
ruby: '2.7.0'
- gemfile: 'gemfiles/activerecord_6.0.0.gemfile'
ruby: '2.4.2'
- gemfile: 'gemfiles/activerecord_6.0.0.gemfile'
ruby: '2.3.5'

services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_DB: cancan_postgresql_spec
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports: ["5432:5432"]

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: '20'

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: Install bundler
run: gem install bundler

- name: Install gems
run: BUNDLE_GEMFILE=${{ matrix.gemfile }} bundle install

- name: Run linter
run: BUNDLE_GEMFILE=${{ matrix.gemfile }} bundle exec rubocop

- name: Run tests on sqlite
run: DB=sqlite BUNDLE_GEMFILE=${{ matrix.gemfile }} bundle exec rake

- name: Run tests on postgres
run: DB=postgres BUNDLE_GEMFILE=${{ matrix.gemfile }} bundle exec rake
6 changes: 4 additions & 2 deletions spec/support/sql_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ def connect_db

def connect_postgres
ActiveRecord::Base.establish_connection(adapter: 'postgresql', host: 'localhost',
database: 'postgres', schema_search_path: 'public')
database: 'postgres', schema_search_path: 'public',
user: 'postgres', password: 'postgres')
ActiveRecord::Base.connection.drop_database('cancan_postgresql_spec')
ActiveRecord::Base.connection.create_database('cancan_postgresql_spec', 'encoding' => 'utf-8',
'adapter' => 'postgresql')
ActiveRecord::Base.establish_connection(adapter: 'postgresql', host: 'localhost',
database: 'cancan_postgresql_spec')
database: 'cancan_postgresql_spec',
user: 'postgres', password: 'postgres')
end
end

0 comments on commit 8a1e071

Please sign in to comment.