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 CI on GitHub for 1.x-stable branch #2640

Merged
merged 12 commits into from
Dec 28, 2022
Merged
79 changes: 79 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Test

on: [push, pull_request]

jobs:
test:
name: RSpec and Cucumber
strategy:
fail-fast: false
matrix:
ruby: [ '2.2', '2.3', '2.4', '2.5', '2.6' ]
gemfile:
- gemfiles/rails-4-0.gemfile
- gemfiles/rails-4-1.gemfile
- gemfiles/rails-4-2.gemfile
- gemfiles/rails-5-0.gemfile
- gemfiles/rails-5-1.gemfile
- gemfiles/rails-5-2.gemfile
experimental: [ false ]
include:
- ruby: '2.7'
gemfile: gemfiles/rails-6-1.gemfile
experimental: false
- ruby: '3.0'
gemfile: gemfiles/rails-6-1.gemfile
experimental: false
- ruby: '3.0'
gemfile: gemfiles/rails-7-0.gemfile
experimental: false
- ruby: '3.1'
gemfile: gemfiles/rails-main.gemfile
experimental: false
exclude:
- ruby: '2.4'
gemfile: gemfiles/rails-4-0.gemfile
- ruby: '2.4'
gemfile: gemfiles/rails-4-1.gemfile
- ruby: '2.5'
gemfile: gemfiles/rails-4-0.gemfile
- ruby: '2.5'
gemfile: gemfiles/rails-4-1.gemfile
- ruby: '2.6'
gemfile: gemfiles/rails-4-0.gemfile
- ruby: '2.6'
gemfile: gemfiles/rails-4-1.gemfile
- ruby: '2.6'
gemfile: gemfiles/rails-4-2.gemfile
runs-on: ubuntu-20.04
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
EXPERIMENTAL: ${{ matrix.experimental }}
JRUBY_OPTS: --debug
steps:
- uses: actions/checkout@v3
- name: Setup ImageMagick policy
run: sudo sh -c 'echo '\''<policymap><policy domain="coder" rights="read|write" pattern="PDF" /></policymap>'\'' > /etc/ImageMagick-6/policy.xml'
- name: Update package list
run: sudo apt update
- name: Install ghostscript to process PDF
run: sudo apt-get -y install ghostscript
- name: Install libvips-dev for Carrierwave::Vips
run: sudo apt-get install libvips-dev
- name: Set up Ruby
uses: ruby/setup-ruby@v1
if: ${{ matrix.ruby <= 2.6 }}
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
bundler: 1.17.3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
if: ${{ matrix.ruby > 2.6 }}
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run RSpec
run: bundle exec rake spec || [ "$EXPERIMENTAL" == "true" ] && true
- name: Run Cucumber
run: bundle exec rake features || [ "$EXPERIMENTAL" == "true" ] && true
5 changes: 0 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,3 @@ You should now be able to run the remote tests:
REMOTE=true bundle exec rake

Please test with the latest Ruby 2.2.x version using RVM if possible.

## Running active record tests

Make sure you have a local PostgreSQL database named `carrierwave_test` with the username
`postgres`
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source "https://rubygems.org"

gem "activemodel-serializers-xml"
gem 'pg', '~> 0.21.0', platforms: :ruby
gem 'sqlite3', platforms: :ruby
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby, :truffleruby]

gemspec
16 changes: 8 additions & 8 deletions carrierwave.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ Gem::Specification.new do |s|
s.add_dependency "activesupport", ">= 4.0.0"
s.add_dependency "activemodel", ">= 4.0.0"
s.add_dependency "mime-types", ">= 1.16"
s.add_dependency "ssrf_filter", "~> 1.0"
if RUBY_ENGINE == 'jruby'
s.add_development_dependency 'activerecord-jdbcpostgresql-adapter'
else
s.add_development_dependency "pg"
end
s.add_development_dependency "rails", ">= 4.0.0"
s.add_dependency "ssrf_filter", "< 1.1.0", "~> 1.0"
s.add_development_dependency "rails", ">= 5.0.0"
s.add_development_dependency "cucumber", "~> 2.3"
s.add_development_dependency "rspec", "~> 3.4"
s.add_development_dependency "webmock"
s.add_development_dependency "fog-core", "~> 2.1.0"
s.add_development_dependency "fog-aws"
s.add_development_dependency "fog-google", "~> 1.7.1"
if RUBY_VERSION < '2.7'
s.add_development_dependency "fog-google", "~> 1.7.0"
else
s.add_development_dependency "fog-google"
end
s.add_development_dependency "fog-local"
s.add_development_dependency "fog-rackspace"
s.add_development_dependency "mini_magick", ">= 3.6.0"
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/rails-4-0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"

gem "rails", "~> 4.0.0"
gem "railties", "~> 4.0.0"
gem 'pg', '~> 0.21.0', platforms: :ruby
gem "activerecord-jdbcpostgresql-adapter", "~> 1.3", platforms: :jruby
gem 'sqlite3', '~> 1.3.6', platforms: :ruby
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby, :truffleruby]

gemspec :path => "../"
4 changes: 2 additions & 2 deletions gemfiles/rails-4-1.gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source "https://rubygems.org"

gem "rails", "~> 4.1.0"
gem 'pg', '~> 0.21.0', platforms: :ruby
gem "activerecord-jdbcpostgresql-adapter", "~> 1.3", platforms: :jruby
gem 'sqlite3', '~> 1.3.6', platforms: :ruby
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby, :truffleruby]

gemspec :path => "../"
4 changes: 2 additions & 2 deletions gemfiles/rails-4-2.gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source "https://rubygems.org"

gem "rails", "~> 4.2.0"
gem 'pg', '~> 0.21.0', platforms: :ruby
gem "activerecord-jdbcpostgresql-adapter", "~> 1.3", platforms: :jruby
gem 'sqlite3', '~> 1.3.6', platforms: :ruby
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby, :truffleruby]

gemspec :path => "../"
7 changes: 5 additions & 2 deletions gemfiles/rails-5-0.gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
source "https://rubygems.org"

gem "rails", "~> 5.0.0"
gem 'pg', '~> 0.21.0', platforms: :ruby
gem "activemodel-serializers-xml"
gem "activerecord-jdbcpostgresql-adapter", "~> 50.0", platforms: :jruby
if RUBY_VERSION < '2.3'
gem "ruby-vips", "2.0.13"
end
gem 'sqlite3', '~> 1.3.6', platforms: :ruby
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby, :truffleruby]

gemspec :path => "../"
4 changes: 2 additions & 2 deletions gemfiles/rails-5-1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"

gem "rails", "~> 5.1.0"
gem "activemodel-serializers-xml"
gem 'pg', '~> 0.21.0', platforms: :ruby
gem "activerecord-jdbcpostgresql-adapter", '~> 51.0', platforms: :jruby
gem 'sqlite3', '~> 1.3.6', platforms: :ruby
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby, :truffleruby]

gemspec :path => "../"
3 changes: 2 additions & 1 deletion gemfiles/rails-5-2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ source "https://rubygems.org"

gem "rails", "~> 5.2.0"
gem "activemodel-serializers-xml"
gem 'pg', '~> 0.21.0', platforms: :ruby
gem 'sqlite3', '~> 1.3.6', platforms: :ruby
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby, :truffleruby]

gemspec :path => "../"
8 changes: 8 additions & 0 deletions gemfiles/rails-6-0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "https://rubygems.org"

gem "rails", "~> 6.0.0"
gem "activemodel-serializers-xml"
gem 'sqlite3', platforms: :ruby
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby, :truffleruby]

gemspec :path => "../"
8 changes: 8 additions & 0 deletions gemfiles/rails-6-1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "https://rubygems.org"

gem "rails", "~> 6.1.0"
gem "activemodel-serializers-xml"
gem 'sqlite3', platforms: :ruby
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby, :truffleruby]

gemspec :path => "../"
8 changes: 8 additions & 0 deletions gemfiles/rails-7-0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "https://rubygems.org"

gem "rails", "~> 7.0.0"
gem "activemodel-serializers-xml"
gem 'sqlite3', platforms: :ruby
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby, :truffleruby]

gemspec :path => "../"
8 changes: 8 additions & 0 deletions gemfiles/rails-main.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "https://rubygems.org"

gem "rails", github: "rails/rails", branch: "main"
gem "activemodel-serializers-xml"
gem 'sqlite3', platforms: :ruby
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby, :truffleruby]

gemspec :path => "../"
12 changes: 0 additions & 12 deletions gemfiles/rails-master.gemfile

This file was deleted.

9 changes: 8 additions & 1 deletion spec/orm/activerecord_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'spec_helper'
require 'support/activerecord'


def create_table(name)
ActiveRecord::Base.connection.create_table(name, force: true) do |t|
t.column :image, :string
Expand All @@ -17,7 +18,13 @@ def drop_table(name)

def reset_class(class_name)
Object.send(:remove_const, class_name) rescue nil
Object.const_set(class_name, Class.new(ActiveRecord::Base))
klass = Object.const_set(class_name, Class.new(ActiveRecord::Base))
# TODO Remove when Rails 5.2 is dropped
klass.class_eval do
attribute :images, :json
attribute :textfiles, :json
end
klass
end

describe CarrierWave::ActiveRecord do
Expand Down
55 changes: 34 additions & 21 deletions spec/support/activerecord.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
if RUBY_ENGINE == 'jruby'
require 'activerecord-jdbcpostgresql-adapter'
else
require 'pg'
end
require 'active_record'
require 'carrierwave/orm/activerecord'
Bundler.require

# Change this if PG is unavailable
dbconfig = {
:adapter => 'postgresql',
:database => 'carrierwave_test',
:encoding => 'utf8',
:username => 'postgres'
}
ActiveRecord::Base.establish_connection({ adapter: 'sqlite3', database: ':memory:' })

database = dbconfig.delete(:database)
ActiveRecord::Migration.verbose = false

ActiveRecord::Base.establish_connection(dbconfig.merge(database: "template1"))
begin
ActiveRecord::Base.connection.create_database database
rescue ActiveRecord::StatementInvalid => e # database already exists
end
ActiveRecord::Base.establish_connection(dbconfig.merge(:database => database))
if ActiveRecord.version < Gem::Version.new("5.2") && ActiveRecord.version >= Gem::Version.new("5.0")
module ActiveRecord
module Type
class Json < ActiveModel::Type::Value
include ActiveModel::Type::Helpers::Mutable

ActiveRecord::Migration.verbose = false
def type
:json
end

def deserialize(value)
return value unless value.is_a?(::String)
ActiveSupport::JSON.decode(value) rescue nil
end

def serialize(value)
ActiveSupport::JSON.encode(value) unless value.nil?
end

def changed_in_place?(raw_old_value, new_value)
deserialize(raw_old_value) != new_value
end

def accessor
ActiveRecord::Store::StringKeyedHashAccessor
end
end
end
end

ActiveRecord::Type.register(:json, ActiveRecord::Type::Json, override: false)
end

if ActiveRecord::VERSION::STRING >= '4.2' && ActiveRecord::VERSION::STRING < '5.0'
ActiveRecord::Base.raise_in_transactional_callbacks = true
ActiveRecord::Base.raise_in_transactional_callbacks = true
end
2 changes: 1 addition & 1 deletion spec/uploader/download_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
let(:test_file) { File.read(file_path(test_file_name)) }
let(:test_file_name) { "test.jpg" }
let(:unicode_named_file) { File.read(file_path(unicode_filename)) }
let(:unicode_URL) { URI.encode(base_url + "/#{unicode_filename}") }
let(:unicode_URL) { URI::DEFAULT_PARSER.escape(base_url + "/#{unicode_filename}") }
let(:unicode_filename) { "юникод.jpg" }
let(:authentication_headers) do
{
Expand Down