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

Introducing Appraisals for multi-Rails testing #251

Merged
merged 8 commits into from
Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
229 changes: 145 additions & 84 deletions .circleci/config.yml

Large diffs are not rendered by default.

71 changes: 36 additions & 35 deletions .circleci/config.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,32 @@
# rake circleci
#
<%
rails51 = '5.1.7'
rails52 = '5.2.8'
rails60 = '6.0.5'
rails61 = '6.1.6'
rails70 = '7.0.3'

builds = [
# 2.6
['2.6', rails51],
['2.6', rails52],
['2.6', rails60],
['2.6', rails61],
%w[2.6 5.1],
%w[2.6 5.2],
%w[2.6 6.0],
%w[2.6 6.1],

# 2.7
['2.7', rails51],
['2.7', rails52],
['2.7', rails60],
['2.7', rails61],
['2.7', rails70],
%w[2.7 5.1],
%w[2.7 5.2],
%w[2.7 6.0],
%w[2.7 6.1],
%w[2.7 7.0],
%w[2.7 7.1],

# 3.0
['3.0', rails60],
['3.0', rails61],
['3.0', rails70],
%w[3.0 6.0],
%w[3.0 6.1],
%w[3.0 7.0],
%w[3.0 7.1],

# 3.1
['3.1', rails60],
['3.1', rails61],
['3.1', rails70, true],
%w[3.1 6.0],
%w[3.1 6.1],
["3.1", "7.0", true],
%w[3.1 7.1],
]

main_build = builds.find { |_, _, is_main_build| is_main_build }
Expand All @@ -54,26 +51,30 @@ shared_build_steps: &shared_build_steps
- run:
name: Storing Rails Version
command: |
echo "$RUBY_VERSION/$RAILS_VERSION" > RAILS_VERSION
cat RAILS_VERSION
echo "$RUBY_VERSION/$BUNDLE_GEMFILE" > CACHE_ENV_VERSION
cat CACHE_ENV_VERSION
# To generate cache checksum, we need a static file, but Gemfile is
# based on the Rails version we are testing against. This step just puts
# a dynamically identified file into a known path.
cat "$BUNDLE_GEMFILE" > CACHE_GEMFILE

# Download and cache dependencies
- restore_cache:
keys:
- dependencies-{{ .Environment.CACHE_VERSION }}-{{ checksum "RAILS_VERSION" }}-{{ checksum "Gemfile" }}-{{ checksum "meta-tags.gemspec" }}
- dependencies-{{ .Environment.CACHE_VERSION }}-{{ checksum "CACHE_ENV_VERSION" }}-{{ checksum "CACHE_GEMFILE" }}-{{ checksum "meta-tags.gemspec" }}
# fallback to using the latest cache if no exact match is found
- dependencies-{{ .Environment.CACHE_VERSION }}-{{ checksum "RAILS_VERSION" }}
- dependencies-{{ .Environment.CACHE_VERSION }}-{{ checksum "CACHE_ENV_VERSION" }}

- run:
name: Installing Dependencies
command: |
bundle config set --local path vendor/bundle
bundle config set --local path "${PWD}/vendor/bundle"
bundle check || (bundle install --jobs=4 --retry=3 && bundle clean)

- save_cache:
paths:
- ./vendor/bundle
key: dependencies-{{ .Environment.CACHE_VERSION }}-{{ checksum "RAILS_VERSION" }}-{{ checksum "Gemfile" }}-{{ checksum "meta-tags.gemspec" }}
key: dependencies-{{ .Environment.CACHE_VERSION }}-{{ checksum "CACHE_ENV_VERSION" }}-{{ checksum "CACHE_GEMFILE" }}-{{ checksum "meta-tags.gemspec" }}

# run tests!
- run:
Expand Down Expand Up @@ -122,18 +123,18 @@ shared_build_steps: &shared_build_steps

jobs:
<% builds.each do |ruby_version, rails_version, is_main_build| %>
build-ruby<%= ruby_version.tr('.', '') %>-rails-<%= rails_version.tr('.', '_') %>:
build-ruby<%= ruby_version.delete(".") %>-rails-<%= rails_version.delete(".") %>:
parameters:
is_main_build:
type: boolean
default: false
docker:
- image: cimg/ruby:<%= ruby_version %>
environment:
RAILS_VERSION: <%= rails_version %>
BUNDLE_GEMFILE: gemfiles/rails_<%= rails_version %>.gemfile
ENABLE_CODE_COVERAGE: 1
NO_STEEP: <%= is_main_build ? 0 : 1 %>
working_directory: ~/meta-tags/ruby<%= ruby_version.tr('.', '') %>-rails-<%= rails_version %>
working_directory: ~/meta-tags/ruby<%= ruby_version.delete(".") %>-rails-<%= rails_version.delete(".") %>
steps: *shared_build_steps
<% end %>

Expand All @@ -147,31 +148,31 @@ jobs:
- run:
name: Uploading Code Coverage
command: |
cd /tmp/workspace/ruby<%= main_build[0].tr('.', '') %>-rails-<%= main_build[1] %>
cd /tmp/workspace/ruby<%= main_build[0].delete(".") %>-rails-<%= main_build[1].delete(".") %>
./cc-test-reporter upload-coverage --input coverage/codeclimate.coverage.json || true
tests:
docker:
- image: alpine
steps:
- run:
name: All tests succeeded
command: ':'
command: ":"

workflows:
version: 2
test:
jobs:
<% builds.each do |ruby_version, rails_version, is_main_build| %>
- build-ruby<%= ruby_version.tr('.', '') %>-rails-<%= rails_version.tr('.', '_') %>:
- build-ruby<%= ruby_version.delete(".") %>-rails-<%= rails_version.delete(".") %>:
is_main_build: <%= !!is_main_build %>
<% end %>

- upload-coverage:
requires:
- build-ruby<%= main_build[0].tr('.', '') %>-rails-<%= main_build[1].tr('.', '_') %>
- build-ruby<%= main_build[0].delete(".") %>-rails-<%= main_build[1].delete(".") %>

- tests:
requires:
<% builds.each do |ruby_version, rails_version| %>
- build-ruby<%= ruby_version.tr('.', '') %>-rails-<%= rails_version.tr('.', '_') %>
- build-ruby<%= ruby_version.delete(".") %>-rails-<%= rails_version.delete(".") %>
<% end %>
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
.DS_Store
.bundle
Gemfile.lock
gemfiles/*.gemfile.lock
.ruby-gemset
coverage
doc
pkg
*.gem
.idea
log/
tmp/
tmp/
25 changes: 25 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

appraise "rails-5.1" do
gem "railties", "5.1.7"
end

appraise "rails-5.2" do
gem "railties", "5.2.8.1"
end

appraise "rails-6.0" do
gem "railties", "6.0.6"
end

appraise "rails-6.1" do
gem "railties", "6.1.7"
end

appraise "rails-7.0" do
gem "railties", "7.0.4"
end

appraise "rails-7.1" do
gem "railties", github: "rails"
end
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

Changes:

- Switched code style from custom rules to Standard ([246](https://github.com/kpumuk/meta-tags/pull/246)).
- Switched code style from custom rules to Standard ([246](https://github.com/kpumuk/meta-tags/pull/251)).
- Switched from testing Rails using environment variables to Appraisal gem ([251](https://github.com/kpumuk/meta-tags/pull/247)).

## 2.18.0 (September 15, 2022) [☰](https://github.com/kpumuk/meta-tags/compare/v2.17.0...v2.18.0)

Expand Down
9 changes: 3 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

source "https://rubygems.org"

# Specify your gem's dependencies in meta-tags.gemspec
# Specify gem's dependencies in meta-tags.gemspec
gemspec

if ENV["RAILS_VERSION"]
# Install specified version of actionpack if requested
gem "railties", "~> #{ENV["RAILS_VERSION"]}"
end
gem "railties", "~> 7.0.4"

unless ENV["NO_STEEP"] == "1"
# Ruby typings
gem "steep", "~> 1.1.1", platform: :mri
gem "steep", "~> 1.3.0", platform: :mri
end

group :test do
Expand Down
17 changes: 17 additions & 0 deletions gemfiles/rails_5.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "railties", "5.1.7"
gem "steep", "~> 1.3.0", platform: :mri

group :test do
gem "standard"
gem "rubocop-rails"
gem "rubocop-rake"
gem "rubocop-rspec", require: false
gem "simplecov", "~> 0.21.2"
gem "rspec_junit_formatter"
end

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

source "https://rubygems.org"

gem "railties", "5.2.8.1"
gem "steep", "~> 1.3.0", platform: :mri

group :test do
gem "standard"
gem "rubocop-rails"
gem "rubocop-rake"
gem "rubocop-rspec", require: false
gem "simplecov", "~> 0.21.2"
gem "rspec_junit_formatter"
end

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

source "https://rubygems.org"

gem "railties", "6.0.6"
gem "steep", "~> 1.3.0", platform: :mri

group :test do
gem "standard"
gem "rubocop-rails"
gem "rubocop-rake"
gem "rubocop-rspec", require: false
gem "simplecov", "~> 0.21.2"
gem "rspec_junit_formatter"
end

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

source "https://rubygems.org"

gem "railties", "6.1.7"
gem "steep", "~> 1.3.0", platform: :mri

group :test do
gem "standard"
gem "rubocop-rails"
gem "rubocop-rake"
gem "rubocop-rspec", require: false
gem "simplecov", "~> 0.21.2"
gem "rspec_junit_formatter"
end

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

source "https://rubygems.org"

gem "railties", "7.0.4"
gem "steep", "~> 1.3.0", platform: :mri

group :test do
gem "standard"
gem "rubocop-rails"
gem "rubocop-rake"
gem "rubocop-rspec", require: false
gem "simplecov", "~> 0.21.2"
gem "rspec_junit_formatter"
end

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

source "https://rubygems.org"

gem "railties", github: "rails"
gem "steep", "~> 1.3.0", platform: :mri

group :test do
gem "standard"
gem "rubocop-rails"
gem "rubocop-rake"
gem "rubocop-rspec", require: false
gem "simplecov", "~> 0.21.2"
gem "rspec_junit_formatter"
end

gemspec path: "../"
4 changes: 2 additions & 2 deletions lib/meta_tags/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ module MetaTags
class Railtie < Rails::Railtie
initializer "meta_tags.setup_action_controller" do
ActiveSupport.on_load :action_controller do
ActionController::Base.include MetaTags::ControllerHelper
include MetaTags::ControllerHelper
end
end

initializer "meta_tags.setup_action_view" do
ActiveSupport.on_load :action_view do
ActionView::Base.include MetaTags::ViewHelper
include MetaTags::ViewHelper
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion meta-tags.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "railties", ">= 3.2.0", "< 7.1"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.11.0"
spec.add_development_dependency "rspec", "~> 3.12.0"
spec.add_development_dependency "rspec-html-matchers", "~> 0.10.0"
spec.add_development_dependency "standard", "~> 1.18.1"
spec.add_development_dependency "appraisal", "~> 2.4.1"

spec.cert_chain = ["certs/kpumuk.pem"]
spec.signing_key = File.expand_path("~/.ssh/gem-kpumuk.pem") if $PROGRAM_NAME.end_with?("gem")
Expand Down