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

Switch to github actions #669

Merged
merged 9 commits into from
Dec 30, 2020
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
81 changes: 81 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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.4', '2.5', '2.6', '2.7', 'jruby', 'truffleruby']
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', 'gemfiles/activerecord_6.1.0.gemfile', 'gemfiles/activerecord_master.gemfile']
exclude:
- gemfile: 'gemfiles/activerecord_4.2.0.gemfile'
ruby: '2.7' # rails 4.2 can't run on ruby 2.7 due to BigDecimal API change
- gemfile: 'gemfiles/activerecord_6.0.0.gemfile'
ruby: '2.4' # rails 6+ requires ruby 2.5+
- gemfile: 'gemfiles/activerecord_6.1.0.gemfile'
ruby: '2.4' # rails 6+ requires ruby 2.5+
- gemfile: 'gemfiles/activerecord_master.gemfile'
ruby: '2.4' # rails 6+ requires ruby 2.5+
- gemfile: 'gemfiles/activerecord_5.0.2.gemfile'
ruby: 'jruby' # this *should* work - there's a test failure; it's not incompatible like the other excludes. could be an issue in Rails 5.0.2?
- gemfile: 'gemfiles/activerecord_6.1.0.gemfile'
ruby: 'jruby' # this *should* work. it seems like there's an issue with rails 6 on jruby.
- gemfile: 'gemfiles/activerecord_master.gemfile'
ruby: 'jruby' # this *should* work. it seems like there's an issue with rails 6 on jruby.

env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}

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

# https://github.com/CanCanCommunity/cancancan/pull/669#issuecomment-748019539
- name: Nokogiri support for Truffleruby
run: sudo apt-get -yqq install libxml2-dev libxslt-dev
if: ${{ matrix.ruby == 'truffleruby' }}
ghiculescu marked this conversation as resolved.
Show resolved Hide resolved

- name: Install gems
run: bundle install --jobs 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using bundler-cache: true would be much faster, I'll make a PR for that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


- name: Run linter
run: bundle exec rubocop

- name: Run tests on sqlite
run: DB=sqlite bundle exec rake

- name: Run tests on postgres
run: DB=postgres bundle exec rake
8 changes: 4 additions & 4 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ appraise 'activerecord_6.1.0' do
end

platforms :ruby, :mswin, :mingw do
gem 'pg', '~> 1.1.4'
gem 'sqlite3', '~> 1.4.0'
gem 'pg', '~> 1.2.3'
gem 'sqlite3', '~> 1.4.2'
end
end

Expand All @@ -113,7 +113,7 @@ appraise 'activerecord_master' do
end

platforms :ruby, :mswin, :mingw do
gem 'pg', '~> 1.1.4'
gem 'sqlite3', '~> 1.4.0'
gem 'pg', '~> 1.2.3'
gem 'sqlite3', '~> 1.4.2'
end
end
4 changes: 2 additions & 2 deletions gemfiles/activerecord_6.1.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ platforms :jruby do
end

platforms :ruby, :mswin, :mingw do
gem "pg", "~> 1.1.4"
gem "sqlite3", "~> 1.4.0"
gem "pg", "~> 1.2.3"
gem "sqlite3", "~> 1.4.2"
end

gemspec path: "../"
4 changes: 2 additions & 2 deletions gemfiles/activerecord_master.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ platforms :jruby do
end

platforms :ruby, :mswin, :mingw do
gem "pg", "~> 1.1.4"
gem "sqlite3", "~> 1.4.0"
gem "pg", "~> 1.2.3"
gem "sqlite3", "~> 1.4.2"
end

gemspec path: "../"
6 changes: 4 additions & 2 deletions spec/support/sql_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,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