Skip to content

Commit

Permalink
Merge pull request #194 from nikz/master
Browse files Browse the repository at this point in the history
Adds GitHub Actions CI + fixes for Ruby 3.1
  • Loading branch information
jmazzi authored Mar 24, 2022
2 parents 518d82e + d3f6941 commit 1a1d7fe
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 4 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Tests

on: [push, pull_request]

jobs:
test:
name: Test on Ruby ${{ matrix.ruby-version }} / Active Record ${{ matrix.rails }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version: [ '2.7', '3.0', '3.1']
rails: ['5_0', '5_1', '5_2', '6_0', '6_1', '7_0']
exclude:
# exclude unsupported ruby versions: https://github.com/rails/rails/issues/40938
- ruby-version: '3.0'
rails: '5_0'
- ruby-version: '3.0'
rails: '5_1'
- ruby-version: '3.0'
rails: '5_2'
- ruby-version: '3.1'
rails: '5_0'
- ruby-version: '3.1'
rails: '5_1'
- ruby-version: '3.1'
rails: '5_2'

env:
TESTING_RAILS_VERSION: ${{ matrix.rails }}
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/activerecord_${{ matrix.rails }}.gemfile

services:
postgres:
image: postgres
env:
POSTGRES_USER: crypt_keeper
POSTGRES_PASSWORD: crypt_keeper
POSTGRES_DB: crypt_keeper_providers
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: crypt_keeper_providers
MYSQL_USER: crypt_keeper
MYSQL_PASSWORD: crypt_keeper
MYSQL_ROOT_PASSWORD: rootpassword
ports:
- 33306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: actions/checkout@v2

- name: Setup System
run: sudo apt-get install libsqlite3-dev

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Copy database config
run: |
cp spec/github_actions.database.yml spec/database.yml
- name: Enable pgcrypto extension
run: |
PGPASSWORD=crypt_keeper psql crypt_keeper_providers -h localhost -p 5432 -U crypt_keeper -tc "CREATE EXTENSION IF NOT EXISTS pgcrypto;"
- name: Run tests
run: bundle exec rake
2 changes: 1 addition & 1 deletion Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ appraise "activerecord_5_0" do
gem "activerecord", "~> 5.0.0"
gem "activesupport", "~> 5.0.0"

gem "sqlite3", "~> 1.3.6"
gem "sqlite3", "~> 1.3.11"
end

appraise "activerecord_5_1" do
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require "appraisal"
RSpec::Core::RakeTask.new :spec
Bundler::GemHelper.install_tasks

if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"] && !ENV["GITHUB_ACTIONS"]
task default: :appraisal
else
task default: :spec
Expand Down
2 changes: 1 addition & 1 deletion crypt_keeper.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'guard-rspec', '~> 4.2.9'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'rb-fsevent', '~> 0.9.1'
gem.add_development_dependency 'coveralls'
gem.add_development_dependency 'coveralls_reborn'
gem.add_development_dependency 'appraisal', '~> 2.1.0'

if RUBY_PLATFORM == 'java'
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/activerecord_5_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ source "https://rubygems.org"

gem "activerecord", "~> 5.0.0"
gem "activesupport", "~> 5.0.0"
gem "sqlite3", "~> 1.3.6"
gem "sqlite3", "~> 1.3.11"

gemspec :path => "../"
3 changes: 3 additions & 0 deletions lib/crypt_keeper/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ def decrypt_table!
# Private: The encryptor class
def encryptor_klass
@encryptor_klass ||= "CryptKeeper::Provider::#{crypt_keeper_encryptor.to_s.camelize}".constantize
rescue NameError
# couldn’t constantize...
nil
end

# Private: The encryptor instance.
Expand Down
25 changes: 25 additions & 0 deletions spec/github_actions.database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
postgres:
adapter: postgresql
encoding: utf8
reconnect: false
host: localhost
database: crypt_keeper_providers
pool: 5
username: crypt_keeper
password: crypt_keeper
min_messages: WARNING
mysql:
adapter: mysql2
encoding: utf8
reconnect: false
database: crypt_keeper_providers
pool: 5
host: 127.0.0.1
port: 33306
username: crypt_keeper
password: crypt_keeper
sqlite:
adapter: sqlite3
encoding: utf8
reconnect: false
database: ':memory:'

0 comments on commit 1a1d7fe

Please sign in to comment.