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 rails 8 support #2167

Merged
merged 23 commits into from
Nov 21, 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
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
jobs:
benchmark:
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: gemfiles/rails_8.0.gemfile
steps:
- uses: actions/[email protected]
- name: Setup Ruby
Expand All @@ -18,8 +20,8 @@ jobs:
bundler-cache: true
- name: Run benchmarks
run: |
bundle exec rake partial_benchmark
bundle exec rake translatable_benchmark
bundle exec appraisal rails-8.0 rake partial_benchmark
bundle exec appraisal rails-8.0 rake translatable_benchmark
test:
name: test (${{ matrix.rails_version }}, ${{ matrix.ruby_version }}, ${{ matrix.mode }})
runs-on: ubuntu-latest
Expand Down Expand Up @@ -51,6 +53,12 @@ jobs:
- ruby_version: "3.3"
rails_version: "7.2"
mode: "capture_patch_enabled"
- ruby_version: "3.3"
rails_version: "8.0"
mode: "capture_patch_disabled"
- ruby_version: "3.3"
rails_version: "8.0"
mode: "capture_patch_enabled"
- ruby_version: "head"
rails_version: "main"
mode: "capture_patch_disabled"
Expand Down
10 changes: 10 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
appraise "rails-6.1" do
gem "rails", "~> 6.1"
gem "tailwindcss-rails", "~> 2.0"
gem "sprockets-rails", "~> 3.4.2"

# Required for Ruby 3.1.0
gem "net-smtp", require: false
Expand All @@ -15,17 +16,26 @@ appraise "rails-7.0" do
gem "rails", "~> 7.0"
gem "tailwindcss-rails", "~> 2.0"
gem "turbo-rails", "~> 1"
gem "sprockets-rails", "~> 3.4.2"
end

appraise "rails-7.1" do
gem "rails", "~> 7.1"
gem "tailwindcss-rails", "~> 2.0"
gem "turbo-rails", "~> 1"
gem "sprockets-rails", "~> 3.4.2"
end

appraise "rails-7.2" do
gem "rails", "~> 7.2"
gem "tailwindcss-rails", "~> 2.0"
gem "sprockets-rails", "~> 3.4.2"
end

appraise "rails-8.0" do
gem "rails", "~> 8.0"
gem "tailwindcss-rails", "~> 2.0"
gem "propshaft", "~> 1.1.0"
end

appraise "rails-main" do
Expand Down
8 changes: 0 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,6 @@ GEM
temple (~> 0.10.0)
tilt (>= 2.1.0)
smart_properties (1.17.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
standard (1.41.1)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
Expand Down Expand Up @@ -364,7 +357,6 @@ DEPENDENCIES
simplecov (~> 0.22.0)
simplecov-console (~> 0.9.1)
slim (~> 5.1)
sprockets-rails (~> 3.4.2)
standard (~> 1)
turbo-rails (~> 1)
view_component!
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ nav_order: 5

*Joel Hawksley*

* Add rails 8 support to CI.

*Reegan Viljoen*

## 3.20.0

* Allow rendering `with_collection` to accept an optional `spacer_component` to be rendered between each item.
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_6.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ gem "net-smtp", require: false
gem "net-imap", require: false
gem "net-pop", require: false
gem "turbo-rails", "~> 1"
gem "sprockets-rails", "~> 3.4.2"

gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ source "https://rubygems.org"
gem "rails", "~> 7.0"
gem "tailwindcss-rails", "~> 2.0"
gem "turbo-rails", "~> 1"
gem "sprockets-rails", "~> 3.4.2"

gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ source "https://rubygems.org"
gem "rails", "~> 7.1"
gem "tailwindcss-rails", "~> 2.0"
gem "turbo-rails", "~> 1"
gem "sprockets-rails", "~> 3.4.2"

gemspec path: "../"
2 changes: 2 additions & 0 deletions gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ gem "debug"

gem "tailwindcss-rails", "~> 2.0"

gem "sprockets-rails", "~> 3.4.2"

group :test do
gem "cuprite", "~> 0.15"
gem "puma", "~> 6"
Expand Down
10 changes: 10 additions & 0 deletions gemfiles/rails_8.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 8.0"
gem "tailwindcss-rails", "~> 2.0"
gem "turbo-rails", "~> 1"
gem "propshaft", "~> 1.1.0"

gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/rails_main.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ source "https://rubygems.org"
gem "rails", github: "rails/rails", branch: "main"
gem "tailwindcss-rails", "~> 2.0"
gem "turbo-rails", "~> 1"
gem "propshaft", "~> 1.1.0"

gemspec path: "../"
3 changes: 2 additions & 1 deletion test/sandbox/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
require "sprockets/railtie" if Rails.version.to_f < 8.0
require "propshaft" if Rails.version.to_f >= 8.0

require "turbo-rails"

Expand Down
2 changes: 1 addition & 1 deletion test/sandbox/config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

Rails.application.config.assets.precompile += %w[admin.css]
Rails.application.config.assets.precompile += %w[admin.css] if Rails.version.to_f <= 7.2
23 changes: 16 additions & 7 deletions test/sandbox/test/rendering_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ def test_render_inline_allocations
ViewComponent::CompileCache.cache.delete(MyComponent)
MyComponent.ensure_compiled

assert_allocations("3.4.0" => 109, "3.3.6" => 115, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123) do
allocations = (Rails.version.to_f >= 8.0) ?
{"3.4.0" => 109, "3.3.6" => 124, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123} :
{"3.4.0" => 109, "3.3.6" => 115, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123}

assert_allocations(**allocations) do
render_inline(MyComponent.new)
end

Expand Down Expand Up @@ -332,14 +336,19 @@ def test_renders_component_with_asset_url
component = AssetComponent.new
assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text)

component.config.asset_host = nil
assert_match(%r{/assets/application-\w+.css}, render_inline(component).text)
if Rails.version.to_f < 8.0

component.config.asset_host = "http://assets.example.com"
assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text)
# Propshaft doesn't allow setting custom hosts so this only works in Rails < 8
# TODO: Revisit this comment for v4 to see if we need to make any deprecations
component.config.asset_host = nil
assert_match(%r{/assets/application-\w+.css}, render_inline(component).text)

component.config.asset_host = "assets.example.com"
assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text)
component.config.asset_host = "http://assets.example.com"
assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text)

component.config.asset_host = "assets.example.com"
assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text)
end
end

def test_template_changes_are_not_reflected_if_cache_is_not_cleared
Expand Down
1 change: 0 additions & 1 deletion view_component.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "simplecov", "~> 0.22.0"
spec.add_development_dependency "simplecov-console", "~> 0.9.1"
spec.add_development_dependency "slim", "~> 5.1"
spec.add_development_dependency "sprockets-rails", "~> 3.4.2"
spec.add_development_dependency "turbo-rails", "~> 1"
spec.add_development_dependency "warning"
spec.add_development_dependency "yard", "~> 0.9.34"
Expand Down
Loading