diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 0000000..a437088 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -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 diff --git a/Appraisals b/Appraisals index 27bcb12..aff8851 100644 --- a/Appraisals +++ b/Appraisals @@ -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 diff --git a/Rakefile b/Rakefile index f899090..f1cc2a1 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/crypt_keeper.gemspec b/crypt_keeper.gemspec index 6654574..c742ebd 100644 --- a/crypt_keeper.gemspec +++ b/crypt_keeper.gemspec @@ -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' diff --git a/gemfiles/activerecord_5_0.gemfile b/gemfiles/activerecord_5_0.gemfile index 993e2f3..42f1499 100644 --- a/gemfiles/activerecord_5_0.gemfile +++ b/gemfiles/activerecord_5_0.gemfile @@ -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 => "../" diff --git a/lib/crypt_keeper/model.rb b/lib/crypt_keeper/model.rb index 2a1a491..7a18ed1 100644 --- a/lib/crypt_keeper/model.rb +++ b/lib/crypt_keeper/model.rb @@ -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. diff --git a/spec/github_actions.database.yml b/spec/github_actions.database.yml new file mode 100644 index 0000000..88a26b5 --- /dev/null +++ b/spec/github_actions.database.yml @@ -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:'