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

Use appraisal gem in CI #1308

Merged
merged 1 commit into from
Jan 6, 2024
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
75 changes: 32 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: CI

on: [push, pull_request]
on:
pull_request:
push:
branches:
- main

jobs:
benchmark:
Expand All @@ -22,65 +26,50 @@ jobs:
bundle exec rake partial_benchmark
bundle exec rake translatable_benchmark
test:
name: test (${{ matrix.rails_version }}, ${{ matrix.ruby_version }}, ${{ matrix.mode }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rails_version: ["6.1", "7.0", "7.1", "main"]
ruby_version: ["3.1", "3.2", "3.3"]
mode: ["capture_patch_enabled", "capture_patch_disabled"]
include:
- rails_version: "6.1.4.4"
ruby_version: "3.0"
# Run against all previously supported Rails versions for Ruby 3.0
- ruby_version: "3.0"
rails_version: "6.1"
mode: "capture_patch_enabled"
- rails_version: "7.0.2.3"
ruby_version: "3.0"
mode: "capture_patch_enabled"
- rails_version: "main"
ruby_version: "3.1"
mode: "capture_patch_enabled"
- rails_version: "7.1.1"
ruby_version: "3.2"
mode: "capture_patch_enabled"
- rails_version: "main"
ruby_version: "3.2"
mode: "capture_patch_enabled"
- rails_version: "6.1.4.4"
ruby_version: "3.0"
mode: "capture_patch_disabled"
- rails_version: "7.0.2.3"
ruby_version: "3.0"
mode: "capture_patch_disabled"
- rails_version: "main"
ruby_version: "3.1"
mode: "capture_patch_disabled"
- rails_version: "7.1.1"
ruby_version: "3.2"
mode: "capture_patch_disabled"
- rails_version: "main"
ruby_version: "3.2"
- ruby_version: "3.0"
rails_version: "6.1"
mode: "capture_patch_disabled"
- rails_version: "7.1.1"
ruby_version: "3.3"
- ruby_version: "3.0"
rails_version: "7.0"
mode: "capture_patch_enabled"
- ruby_version: "3.0"
rails_version: "7.0"
mode: "capture_patch_disabled"
- rails_version: "main"
ruby_version: "3.3"
- ruby_version: "3.0"
rails_version: "7.1"
mode: "capture_patch_enabled"
- ruby_version: "3.0"
rails_version: "7.1"
mode: "capture_patch_disabled"
env:
BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails_version }}.gemfile
steps:
- uses: actions/checkout@v4.1.1
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
- uses: actions/cache@v3
with:
path: vendor/bundle
key: gems-build-rails-${{ matrix.rails_version }}-ruby-${{ matrix.ruby_version }}-${{ hashFiles('**/Gemfile.lock') }}
bundler-cache: true
Comment on lines -72 to +65
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎

- name: Build and test with Rake
# Code-reloading isn't compatible with simplecov, so we need to run once
# to collect coverage, and again to test reloads.
run: |
bundle config path vendor/bundle
bundle update
# Code-reloading isn't compatible with simplecov, so we need to run once
# to collect coverage, and again to test reloads.
boardfish marked this conversation as resolved.
Show resolved Hide resolved
MEASURE_COVERAGE=true bundle exec rake test spec
ENABLE_RELOADING=true bundle exec rake test spec
bundle exec appraisal rails-${{ matrix.rails_version }} bundle
MEASURE_COVERAGE=true bundle exec appraisal rails-${{ matrix.rails_version }} rake
ENABLE_RELOADING=true bundle exec appraisal rails-${{ matrix.rails_version }} rake
env:
RAISE_ON_WARNING: 1
RAILS_VERSION: ${{ matrix.rails_version }}
Expand Down
8 changes: 4 additions & 4 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

appraise "rails-6.1" do
gem "rails", "~> 6.1.0"
gem "rails", "~> 6.1"
gem "tailwindcss-rails", "~> 2.0"

# Required for Ruby 3.1.0
Expand All @@ -11,16 +11,16 @@ appraise "rails-6.1" do
end

appraise "rails-7.0" do
gem "rails", "~> 7.0.0"
gem "rails", "~> 7.0"
gem "tailwindcss-rails", "~> 2.0"
end

appraise "rails-7.1" do
gem "rails", "~> 7.1.0"
gem "rails", "~> 7.1"
gem "tailwindcss-rails", "~> 2.0"
end

appraise "rails-head" do
appraise "rails-main" do
gem "rails", github: "rails/rails", branch: "main"
gem "tailwindcss-rails", "~> 2.0"
end
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ group :test do
gem "selenium-webdriver", "4.9.0" # 4.9.1 requires Ruby 3+
end

group :development, :test do
gem "appraisal", "~> 2.5"
end

if RUBY_VERSION >= "3.1"
gem "net-imap", require: false
gem "net-pop", require: false
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ PLATFORMS
ruby

DEPENDENCIES
appraisal (~> 2.4)
appraisal (~> 2.5)
benchmark-ips (~> 2.13.0)
better_html
bundler (~> 2)
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ nav_order: 5

## main

* Update CI configuration to use `Appraisal`.

*Hans Lemuet, Simon Fish*

## 3.9.0

* Don’t break `rails stats` if ViewComponent path is missing.
Expand Down
19 changes: 19 additions & 0 deletions gemfiles/rails_5.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "capybara", "~> 3"
gem "rails", "~> 5.2.0"
gem "rspec-rails", "~> 5"

group :test do
gem "cuprite", "~> 0.8"
gem "puma", "~> 5"
gem "selenium-webdriver", "~> 4"
end

group :development, :test do
gem "appraisal", github: "thoughtbot/appraisal"
end

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

source "https://rubygems.org"

gem "capybara", "~> 3"
gem "rails", "~> 6.0.0"
gem "rspec-rails", "~> 5"
gem "tailwindcss-rails", "~> 2.0"

group :test do
gem "cuprite", "~> 0.8"
gem "puma", "~> 5"
gem "selenium-webdriver", "~> 4"
end

group :development, :test do
gem "appraisal", github: "thoughtbot/appraisal"
end

gemspec path: "../"
15 changes: 10 additions & 5 deletions gemfiles/rails_6.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
source "https://rubygems.org"

gem "capybara", "~> 3"
gem "rails", "~> 6.1.0"
gem "rails", "~> 6.1"
gem "rspec-rails", "~> 5"
gem "debug"
gem "tailwindcss-rails", "~> 2.0"
gem "net-smtp", require: false
gem "net-imap", require: false
gem "net-pop", require: false
gem "net-smtp", require: false
gem "debug"
gem "tailwindcss-rails", "~> 2.0"

group :test do
gem "cuprite", "~> 0.8"
gem "cuprite", "~> 0.15"
gem "puma", "~> 6"
gem "warning"
gem "selenium-webdriver", "4.9.0"
end

group :development, :test do
gem "appraisal", "~> 2.5"
end

gemspec path: "../"
12 changes: 10 additions & 2 deletions gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
source "https://rubygems.org"

gem "capybara", "~> 3"
gem "rails", "~> 7.0.0"
gem "rails", "~> 7.0"
gem "rspec-rails", "~> 5"
gem "net-imap", require: false
gem "net-pop", require: false
gem "net-smtp", require: false
gem "debug"
gem "tailwindcss-rails", "~> 2.0"

group :test do
gem "cuprite", "~> 0.8"
gem "cuprite", "~> 0.15"
gem "puma", "~> 6"
gem "warning"
gem "selenium-webdriver", "4.9.0"
end

group :development, :test do
gem "appraisal", "~> 2.5"
end

gemspec path: "../"
12 changes: 10 additions & 2 deletions gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
source "https://rubygems.org"

gem "capybara", "~> 3"
gem "rails", "~> 7.1.0"
gem "rails", "~> 7.1"
gem "rspec-rails", "~> 5"
gem "net-imap", require: false
gem "net-pop", require: false
gem "net-smtp", require: false
gem "debug"
gem "tailwindcss-rails", "~> 2.0"

group :test do
gem "cuprite", "~> 0.8"
gem "cuprite", "~> 0.15"
gem "puma", "~> 6"
gem "warning"
gem "selenium-webdriver", "4.9.0"
end

group :development, :test do
gem "appraisal", "~> 2.5"
end

gemspec path: "../"
10 changes: 9 additions & 1 deletion gemfiles/rails_head.gemfile → gemfiles/rails_main.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ source "https://rubygems.org"
gem "capybara", "~> 3"
gem "rails", github: "rails/rails", branch: "main"
gem "rspec-rails", "~> 5"
gem "net-imap", require: false
gem "net-pop", require: false
gem "net-smtp", require: false
gem "debug"
gem "tailwindcss-rails", "~> 2.0"

group :test do
gem "cuprite", "~> 0.8"
gem "cuprite", "~> 0.15"
gem "puma", "~> 6"
gem "warning"
gem "selenium-webdriver", "4.9.0"
end

group :development, :test do
gem "appraisal", "~> 2.5"
end

gemspec path: "../"
3 changes: 3 additions & 0 deletions lib/view_component/test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,18 @@ def __vc_test_helpers_build_controller(klass)

def __vc_test_helpers_preview_class
result = if respond_to?(:described_class)
# :nocov:
raise "`render_preview` expected a described_class, but it is nil." if described_class.nil?

"#{described_class}Preview"
# :nocov:
else
self.class.name.gsub("Test", "Preview")
end
result = result.constantize
rescue NameError
raise NameError, "`render_preview` expected to find #{result}, but it does not exist."
end
# :nocov:
Comment on lines +258 to +270
Copy link
Member

@joelhawksley joelhawksley Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these changes necessary? I'd really prefer to avoid adding these comments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try dropping them, but runs were failing due to coverage errors. I think this was the cause, though I'm not sure if anything in this PR in particular would've triggered it.

end
end
Loading