Skip to content

Commit

Permalink
Merge pull request #7 from customink/coding-bunny/fix_loading
Browse files Browse the repository at this point in the history
[Inkovate] Add Support for Rails versions
  • Loading branch information
Arne De Herdt authored Apr 27, 2021
2 parents 4d206cd + 6582c04 commit 2b66085
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 35 deletions.
96 changes: 65 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
---
# ---------------------------------------------------------------------------------------------------------------------
# CircleCI Snippets
#
# Reusable snippets are defined below this section. These are yaml fragments that can injected into the standard
# CircleCI configuration, reducing the complexity of the entire block.
# ---------------------------------------------------------------------------------------------------------------------
docker_image: &docker_image
image: ${CUSTOMINK_ECR_URL}/customink/base-ruby:2.7-v4.0
aws_auth:
aws_access_key_id: ${PRODUCTION_AWS_ACCESS_KEY_ID}
aws_secret_access_key: ${PRODUCTION_AWS_SECRET_ACCESS_KEY}

# ---------------------------------------------------------------------------------------------------------------------
# CircleCI Commands Configuration
#
Expand All @@ -20,25 +8,26 @@ docker_image: &docker_image
# ---------------------------------------------------------------------------------------------------------------------
version: 2.1
commands:
bundle_install:
description: "Performs the bundler installation, relying on the CircleCI cache for performance"
appraisal_install:
description: "Performs the installation with Appraisal"
parameters:
ruby-version:
type: string
steps:
- restore_cache:
keys:
- bundler-cache-{{ checksum "is_it_up.gemspec" }}
- appraisal-cache-<< parameters.ruby-version >>-1.0-{{ checksum "is_it_up.gemspec" }}
- run:
name: "Bundle Install"
command: bundle install --path=.bundle
name: "Appraisal Install"
command: |
bundle config --local path vendor/bundle
bundle install --jobs 4 --retry 3
bundle exec appraisal install
- save_cache:
key: bundler-cache-{{ checksum "is_it_up.gemspec" }}
key: appraisal-cache-<< parameters.ruby-version >>-1.0-{{ checksum "is_it_up.gemspec" }}
paths:
- .bundle
minitest:
description: "Runs Minitest with the correct configuration so it runs in parallel and is configured for CircleCI"
steps:
- run:
name: "Minitest Test Suite"
command: bundle exec rake
- vendor/bundle

# ---------------------------------------------------------------------------------------------------------------------
# CircleCI Job Configuration
#
Expand All @@ -48,22 +37,67 @@ commands:
# ---------------------------------------------------------------------------------------------------------------------
jobs:
tests:
working_directory: ~/is_it_up
parameters:
ruby-version:
type: string
gemfile:
type: string
docker:
- <<: *docker_image
- image: 916869144969.dkr.ecr.us-east-1.amazonaws.com/customink/base-ruby:<< parameters.ruby-version >>-v5.5
user: root
aws_auth:
aws_access_key_id: ${PRODUCTION_AWS_ACCESS_KEY_ID}
aws_secret_access_key: ${PRODUCTION_AWS_SECRET_ACCESS_KEY}
environment:
RAILS_ENV: test
RACK_ENV: test
working_directory: "/app"
steps:
- checkout
- bundle_install
- minitest
- appraisal_install:
ruby-version: << parameters.ruby-version >>
- run:
name: "Tests"
command: bundle exec appraisal << parameters.gemfile >> rake test
- store_artifacts:
path: ./coverage
- store_test_results:
path: test/reports
path: ./test/reports
- store_artifacts:
path: coverage
path: ./test/reports

# ---------------------------------------------------------------------------------------------------------------------
# CircleCI Workflow Execution Order
#
# Here we define the Workflow, the order of the various jobs and their dependencies.
# This allows us to decide whether to run certain tasks sequentially or run several of them in parallel.
# ---------------------------------------------------------------------------------------------------------------------
workflows:
version: 2.1
build-and-test:
jobs:
- tests:
name: "Ruby 2.6 Tests with Rails 5.0"
context: customink
gemfile: "rails5.0"
ruby-version: "2.6"
- tests:
name: "Ruby 2.6 Tests with Rails 5.1"
context: customink
gemfile: "rails5.1"
ruby-version: "2.6"
- tests:
name: "Ruby 2.6 Tests with Rails 5.2"
context: customink
gemfile: "rails5.2"
ruby-version: "2.6"
- tests:
name: "Ruby 2.6 Tests with Rails 6.0"
context: customink
gemfile: "rails6.0"
ruby-version: "2.6"
- tests:
name: "Ruby 2.6 Tests with Rails 6.1"
context: customink
gemfile: "rails6.1"
ruby-version: "2.6"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Gemfile.lock
InstalledFiles
_yardoc
gemfiles/*.gemfile.lock
coverage
doc/
lib/bundler/man
Expand Down
30 changes: 30 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This is the appraisal file that determines which specific gems should be
# tested in various situations. Because Appraisal was originally developed
# for the Travis CI system, a few minor tweaks are added to this file,
# to ensure we can actually run this properly on CircleCI.
#
# The core change is that we perform a Ruby version check in this file to
# exclude certain configurations from specific Ruby machines to simulate
# the configuration we had in Travis CI where we excluded a specific Gemfile from
# a build. That feature does not exist in CircleCI, so to ensure that the
# "bundle exec appraisal install" command works,
# we exclude certain appraisals when the Ruby version doesn't match.
appraise 'rails5.0' do
gem 'rails', '~> 5.0.0'
end

appraise 'rails5.1' do
gem 'rails', '~> 5.1.0'
end

appraise 'rails5.2' do
gem 'rails', '~> 5.2.0'
end

appraise 'rails6.0' do
gem 'rails', '~> 6.0.0'
end

appraise 'rails6.1' do
gem 'rails', '~> 6.1.0'
end
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# IsItUp Changelog

## 1.0.0
- Added Appraisal for proper testing against various Rails versions
- Updated documentation
- Enforced direct loading of `::Railtie`

## 0.0.5
- Fix the autoloading for `Railtie`

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source 'https://rubygems.org'
gemspec

group :test do
gem 'appraisal'
gem 'minitest-ci', require: false
gem 'simplecov', require: false
end
13 changes: 13 additions & 0 deletions gemfiles/rails5.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 5.0.0"

group :test do
gem "appraisal"
gem "minitest-ci", require: false
gem "simplecov", require: false
end

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

source "https://rubygems.org"

gem "rails", "~> 5.1.0"

group :test do
gem "appraisal"
gem "minitest-ci", require: false
gem "simplecov", require: false
end

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

source "https://rubygems.org"

gem "rails", "~> 5.2.0"

group :test do
gem "appraisal"
gem "minitest-ci", require: false
gem "simplecov", require: false
end

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

source "https://rubygems.org"

gem "rails", "~> 6.0.0"

group :test do
gem "appraisal"
gem "minitest-ci", require: false
gem "simplecov", require: false
end

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

source "https://rubygems.org"

gem "rails", "~> 6.1.0"

group :test do
gem "appraisal"
gem "minitest-ci", require: false
gem "simplecov", require: false
end

gemspec path: "../"
11 changes: 8 additions & 3 deletions lib/is_it_up.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
require "rack"

# This module defines our Gem, and automatically requires the needed files to ensure that the gem can hook into
# the application's middleware stack when needed, or triggers the Rails boot process properly using the Railtie
# framework.
# Do not swap this code to rely on autoload, since this behavior is not compatible with higher Ruby releases.
# We need to code to be loaded immediately, and not on-demand as this will be too late for the Rails boot process.
module IsItUp
autoload :VERSION, "is_it_up/version"
autoload :Middleware, "is_it_up/middleware"
autoload :Railtie, "is_it_up/railtie" if defined?(Rails::Railtie)
require_relative 'is_it_up/version'
require_relative 'is_it_up/middleware'
require_relative 'is_it_up/railtie' if defined?(::Rails::Railtie)
end
4 changes: 3 additions & 1 deletion lib/is_it_up/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module IsItUp
VERSION = "0.0.5"
VERSION = '1.0.0'.freeze

public_constant :VERSION
end

0 comments on commit 2b66085

Please sign in to comment.