Skip to content

Commit

Permalink
Merge pull request #125 from FundingCircle/ruby-and-rails-upgrades
Browse files Browse the repository at this point in the history
Add rails 7 support
  • Loading branch information
bliof-fc authored Dec 29, 2021
2 parents bac2ddb + 057f210 commit 3406fb3
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 66 deletions.
68 changes: 8 additions & 60 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
basic_build: &basic_build
working_directory: ~/loga
docker:
- image: circleci/ruby:2.5.1
- image: cimg/ruby:2.7.5

test_build: &test_build
working_directory: ~/loga
Expand All @@ -25,43 +25,11 @@ test_build: &test_build
at: ./tmp
- run: RACK_ENV=development bundle exec appraisal rspec
- run: RACK_ENV=production bundle exec appraisal rspec
- run: ./tmp/cc-test-reporter format-coverage -t simplecov -o $(ruby -e 'puts "tmp/codeclimate.#{RUBY_VERSION}.json"') coverage/.resultset.json
- persist_to_workspace:
root: tmp
paths:
- codeclimate.*.json
- store_artifacts:
path: coverage

version: 2
jobs:
build:
<<: *basic_build
steps:
- run:
name: Download cc-test-reporter
command: |
mkdir -p tmp/
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
chmod +x ./tmp/cc-test-reporter
- persist_to_workspace:
root: ./tmp
paths:
- cc-test-reporter
upload-coverage:
<<: *basic_build
steps:
- attach_workspace:
at: ./tmp
- run:
name: Upload coverage results to Code Climate
command: |
./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json -o tmp/codeclimate.total.json
./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.total.json -r $CODECLIMATE_REPO_TOKEN
ruby-2.3:
docker:
- image: circleci/ruby:2.3
<<: *test_build
ruby-2.4:
docker:
- image: circleci/ruby:2.4
Expand All @@ -76,7 +44,11 @@ jobs:
<<: *test_build
ruby-2.7:
docker:
- image: circleci/ruby:2.7
- image: cimg/ruby:2.7
<<: *test_build
ruby-3.0:
docker:
- image: cimg/ruby:3.0
<<: *test_build
rubocop:
<<: *basic_build
Expand Down Expand Up @@ -107,54 +79,30 @@ workflows:
version: 2
test-then-push-gem:
jobs:
- build:
filters:
tags:
only: /.*/
- rubocop:
filters:
tags:
only: /.*/
- ruby-2.3:
filters:
tags:
only: /.*/
requires:
- build
- ruby-2.4:
filters:
tags:
only: /.*/
requires:
- build
- ruby-2.5:
filters:
tags:
only: /.*/
requires:
- build
- ruby-2.6:
filters:
tags:
only: /.*/
requires:
- build
- ruby-2.7:
filters:
tags:
only: /.*/
requires:
- build
- upload-coverage:
- ruby-3.0:
filters:
tags:
only: /.*/
requires:
- ruby-2.3
- ruby-2.4
- ruby-2.5
- ruby-2.6
- ruby-2.7
- push-to-rubygems:
filters:
tags:
Expand All @@ -163,8 +111,8 @@ workflows:
ignore: /.*/
requires:
- rubocop
- ruby-2.3
- ruby-2.4
- ruby-2.5
- ruby-2.6
- ruby-2.7
- ruby-3.0
10 changes: 10 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.5.0')
end
end

if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.7.0')
appraise 'rails61' do
gem 'rails', '~> 6.1.4.4'
end

appraise 'rails70' do
gem 'rails', '~> 7.0.0'
end
end

appraise 'sidekiq51' do
gem 'sidekiq', '~> 5.1.0'
end
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.6.0] - 2021-12-22
### Added
- Allow using the gem with rails 7
- Add a build for ruby 3.0

### Removed
- Remove build for ruby 2.3

## [2.5.4] - 2021-03-24
### Fixed
- Remove state from Rack middleware, to prevent race conditions where one request would overwrite the state of another
Expand Down
2 changes: 1 addition & 1 deletion Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end

group :rails do
%w[production development].each do |env|
%w[rails32 rails40 rails50 rails52].each do |appraisal|
%w[rails52 rails61 rails70].each do |appraisal|
cmd = "RACK_ENV=#{env} bundle exec appraisal #{appraisal} rspec"

guard :rspec, all_on_start: true, cmd: cmd do
Expand Down
11 changes: 11 additions & 0 deletions gemfiles/rails61.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 6.1.4.4"

group :test do
gem "simplecov", "~> 0.17.0"
end

gemspec path: "../"
11 changes: 11 additions & 0 deletions gemfiles/rails70.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 7.0.0"

group :test do
gem "simplecov", "~> 0.17.0"
end

gemspec path: "../"
2 changes: 1 addition & 1 deletion lib/loga/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def insert_exceptions_catcher
def silence_rails_rack_logger
case Rails::VERSION::MAJOR
when 3 then require 'loga/ext/rails/rack/logger3.rb'
when 4..6 then require 'loga/ext/rails/rack/logger.rb'
when 4..7 then require 'loga/ext/rails/rack/logger.rb'
else
raise Loga::ConfigurationError,
"Rails #{Rails::VERSION::MAJOR} is unsupported"
Expand Down
2 changes: 1 addition & 1 deletion lib/loga/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Loga
VERSION = '2.5.4'.freeze
VERSION = '2.6.0'.freeze
end
6 changes: 3 additions & 3 deletions loga.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ Gem::Specification.new do |spec|
spec.add_dependency 'activesupport', '>= 2.3.8'
spec.add_dependency 'rack'

spec.add_development_dependency 'appraisal', '~> 2.2.0'
spec.add_development_dependency 'appraisal', '~> 2.4'
spec.add_development_dependency 'bundler', '>= 1.6'
spec.add_development_dependency 'byebug'
spec.add_development_dependency 'guard', '~> 2.13'
spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
spec.add_development_dependency 'guard-rspec', '~> 4.7'
spec.add_development_dependency 'guard-rubocop', '~> 1.2'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'rack-test'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'fakeredis'
spec.add_development_dependency 'rspec', '~> 3.7.0'
spec.add_development_dependency 'rspec', '~> 3.7'
spec.add_development_dependency 'rubocop', '~> 0.57.0'
spec.add_development_dependency 'rubocop-rspec'
spec.add_development_dependency 'timecop'
Expand Down
80 changes: 80 additions & 0 deletions spec/fixtures/rails61.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
require 'action_controller/railtie'
require 'action_mailer/railtie'

Bundler.require(*Rails.groups)

STREAM = StringIO.new unless defined?(STREAM)

class Dummy < Rails::Application
config.eager_load = true
config.filter_parameters += [:password]
config.secret_key_base = '2624599ca9ab3cf3823626240138a128118a87683bf03ab8f155844c33b3cd8cbbfa3ef5e29db6f5bd182f8bd4776209d9577cfb46ac51bfd232b00ab0136b24'
config.session_store :cookie_store, key: '_rails61_session'

config.log_tags = [:uuid, 'TEST_TAG']
config.loga = {
device: STREAM,
host: 'bird.example.com',
service_name: 'hello_world_app',
service_version: '1.0',
}
config.action_mailer.delivery_method = :test
end

class ApplicationController < ActionController::Base
include Rails.application.routes.url_helpers
protect_from_forgery with: :null_session

def ok
render plain: 'Hello Rails'
end

def error
nil.name
end

def show
render json: params
end

def create
render json: params
end

def new
redirect_to :ok
end

def update
@id = params[:id]
render '/user'
end
end

class FakeMailer < ActionMailer::Base
default from: 'notifications@example.com'

def self.send_email
basic_mail.deliver_now
end

def basic_mail
mail(
to: 'user@example.com',
subject: 'Welcome to My Awesome Site',
body: 'Banana muffin',
content_type: 'text/html',
)
end
end

Dummy.routes.append do
get 'ok' => 'application#ok'
get 'error' => 'application#error'
get 'show' => 'application#show'
post 'users' => 'application#create'
get 'new' => 'application#new'
put 'users/:id' => 'application#update'
end

Dummy.initialize!
80 changes: 80 additions & 0 deletions spec/fixtures/rails70.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
require 'action_controller/railtie'
require 'action_mailer/railtie'

Bundler.require(*Rails.groups)

STREAM = StringIO.new unless defined?(STREAM)

class Dummy < Rails::Application
config.eager_load = true
config.filter_parameters += [:password]
config.secret_key_base = '2624599ca9ab3cf3823626240138a128118a87683bf03ab8f155844c33b3cd8cbbfa3ef5e29db6f5bd182f8bd4776209d9577cfb46ac51bfd232b00ab0136b24'
config.session_store :cookie_store, key: '_rails70_session'

config.log_tags = [:uuid, 'TEST_TAG']
config.loga = {
device: STREAM,
host: 'bird.example.com',
service_name: 'hello_world_app',
service_version: '1.0',
}
config.action_mailer.delivery_method = :test
end

class ApplicationController < ActionController::Base
include Rails.application.routes.url_helpers
protect_from_forgery with: :null_session

def ok
render plain: 'Hello Rails'
end

def error
nil.name
end

def show
render json: params
end

def create
render json: params
end

def new
redirect_to :ok
end

def update
@id = params[:id]
render '/user'
end
end

class FakeMailer < ActionMailer::Base
default from: 'notifications@example.com'

def self.send_email
basic_mail.deliver_now
end

def basic_mail
mail(
to: 'user@example.com',
subject: 'Welcome to My Awesome Site',
body: 'Banana muffin',
content_type: 'text/html',
)
end
end

Dummy.routes.append do
get 'ok' => 'application#ok'
get 'error' => 'application#error'
get 'show' => 'application#show'
post 'users' => 'application#create'
get 'new' => 'application#new'
put 'users/:id' => 'application#update'
end

Dummy.initialize!

0 comments on commit 3406fb3

Please sign in to comment.