From fb9e10222ba14990a1e1fc1c87a58cf21f844326 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Sat, 15 Feb 2025 11:12:01 +0100 Subject: [PATCH 1/3] CI: Specify Bundler version Bundler `latest` has stopped working with older Rubies. We need to specify the Bundler version for the older Rubies to still build. --- .github/workflows/ci.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 325b400e..f741c256 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,35 +9,43 @@ jobs: include: - ruby: 2.5 gemfile: "gemfiles/Gemfile.rails-6.1-sprockets-3" + bundler: "2.3.0" - ruby: 2.5 gemfile: "gemfiles/Gemfile.rails-6.1-sprockets-4" - + bundler: "2.3.0" - ruby: 2.7 gemfile: "gemfiles/Gemfile.rails-7.0-sprockets-3" + bundler: "2.4.8" - ruby: 2.7 gemfile: "gemfiles/Gemfile.rails-7.0-sprockets-4" - + bundler: "2.4.8" - ruby: 2.7 gemfile: "gemfiles/Gemfile.rails-7.1-sprockets-3" + bundler: "2.4.8" - ruby: 2.7 gemfile: "gemfiles/Gemfile.rails-7.1-sprockets-4" - + bundler: "2.4.8" - ruby: 3.1 gemfile: "gemfiles/Gemfile.rails-7.2-sprockets-3" + bundler: default - ruby: 3.1 gemfile: "gemfiles/Gemfile.rails-7.2-sprockets-4" - + bundler: default - ruby: 3.2 gemfile: "gemfiles/Gemfile.rails-8.0-sprockets-3" + bundler: default - ruby: 3.2 gemfile: "gemfiles/Gemfile.rails-8.0-sprockets-4" - + bundler: default - ruby: 3.2 gemfile: Gemfile + bundler: default - ruby: 3.3 gemfile: Gemfile + bundler: default - ruby: head gemfile: Gemfile + bundler: default env: BUNDLE_GEMFILE: ${{ matrix.gemfile }} @@ -49,6 +57,8 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: true + cache-version: ${{ matrix.ruby }}-${{ matrix.ruby }}-${{ matrix.gemfile }} + bundler: ${{ matrix.bundler }} - name: Run tests run: bundle exec rake continue-on-error: ${{ matrix.gemfile == 'Gemfile' }} From 647b886fbe683689dab2eaf6e7ce8dff6bb4a925 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Sat, 15 Feb 2025 11:13:38 +0100 Subject: [PATCH 2/3] CI: Fix Rails 7.0 and 6.1 See https://github.com/rails/rails/issues/54260 for context. --- gemfiles/Gemfile.rails-6.1-sprockets-3 | 2 ++ gemfiles/Gemfile.rails-6.1-sprockets-4 | 2 ++ gemfiles/Gemfile.rails-7.0-sprockets-3 | 2 ++ gemfiles/Gemfile.rails-7.0-sprockets-4 | 2 ++ 4 files changed, 8 insertions(+) diff --git a/gemfiles/Gemfile.rails-6.1-sprockets-3 b/gemfiles/Gemfile.rails-6.1-sprockets-3 index 3e31a785..0626d619 100644 --- a/gemfiles/Gemfile.rails-6.1-sprockets-3 +++ b/gemfiles/Gemfile.rails-6.1-sprockets-3 @@ -4,3 +4,5 @@ gemspec path: '..' gem 'actionpack', '~> 6.1.0' gem 'railties', '~> 6.1.0' gem 'sprockets', '~> 3.0' + +gem 'concurrent-ruby', '< 1.3.5' diff --git a/gemfiles/Gemfile.rails-6.1-sprockets-4 b/gemfiles/Gemfile.rails-6.1-sprockets-4 index af14533e..41a6c57a 100644 --- a/gemfiles/Gemfile.rails-6.1-sprockets-4 +++ b/gemfiles/Gemfile.rails-6.1-sprockets-4 @@ -4,3 +4,5 @@ gemspec path: '..' gem 'actionpack', '~> 6.1.0' gem 'railties', '~> 6.1.0' gem 'sprockets', '~> 4.0' + +gem 'concurrent-ruby', '< 1.3.5' diff --git a/gemfiles/Gemfile.rails-7.0-sprockets-3 b/gemfiles/Gemfile.rails-7.0-sprockets-3 index dd25e0ec..c5787efb 100644 --- a/gemfiles/Gemfile.rails-7.0-sprockets-3 +++ b/gemfiles/Gemfile.rails-7.0-sprockets-3 @@ -4,3 +4,5 @@ gemspec path: '..' gem 'actionpack', '~> 7.0.0' gem 'railties', '~> 7.0.0' gem 'sprockets', '~> 3.0' + +gem 'concurrent-ruby', '< 1.3.5' diff --git a/gemfiles/Gemfile.rails-7.0-sprockets-4 b/gemfiles/Gemfile.rails-7.0-sprockets-4 index 27b9dd95..0c73b078 100644 --- a/gemfiles/Gemfile.rails-7.0-sprockets-4 +++ b/gemfiles/Gemfile.rails-7.0-sprockets-4 @@ -4,3 +4,5 @@ gemspec path: '..' gem 'actionpack', '~> 7.0.0' gem 'railties', '~> 7.0.0' gem 'sprockets', '~> 4.0' + +gem 'concurrent-ruby', '< 1.3.5' From 3b36794df7b5d2e2a31b24a3e30e43ddc755f4b7 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Fri, 14 Feb 2025 16:37:53 +0100 Subject: [PATCH 3/3] Warn instead of raising on missing manifest.js With a pristine (`rails new`) Rails 8.0 app, the `app/assets/config/manifest.js` file is no longer automatically generated. For engines still using sprockets, that is not a huge issue, because they have and add their own manifest files for their assets to the list of precompiled assets. However, scripts like the Solidus bin/sandbox script[1] first run `rails new`, then add the needed engines to the sandbox's `Gemfile`, then run `rails db:migrate` and their respective install generators. With Rails 8, these scripts now fail before anything is possible in Ruby, because the initializer of `Sprockets::Railtie` will raise an error on startup. This commit changes the behavior of the Railtie to issue a deprecation warning instead of raising an Exception. [1] https://github.com/solidusio/solidus/blob/main/bin/sandbox#L44-L99 --- lib/sprockets/railtie.rb | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/lib/sprockets/railtie.rb b/lib/sprockets/railtie.rb index 5f579e9c..1a774269 100644 --- a/lib/sprockets/railtie.rb +++ b/lib/sprockets/railtie.rb @@ -60,21 +60,6 @@ module Sprockets class Railtie < ::Rails::Railtie include Sprockets::Rails::Utils - class ManifestNeededError < StandardError - def initialize - msg = "Expected to find a manifest file in `app/assets/config/manifest.js`\n" + - "But did not, please create this file and use it to link any assets that need\n" + - "to be rendered by your app:\n\n" + - "Example:\n" + - " //= link_tree ../images\n" + - " //= link_directory ../javascripts .js\n" + - " //= link_directory ../stylesheets .css\n" + - "and restart your server\n\n" + - "For more information see: https://github.com/rails/sprockets/blob/070fc01947c111d35bb4c836e9bb71962a8e0595/UPGRADING.md#manifestjs" - super msg - end - end - LOOSE_APP_ASSETS = lambda do |logical_path, filename| filename.start_with?(::Rails.root.join("app/assets").to_s) && !['.js', '.css', ''].include?(File.extname(logical_path)) @@ -103,8 +88,20 @@ def configure(&block) initializer :set_default_precompile do |app| if using_sprockets4? - raise ManifestNeededError unless ::Rails.root.join("app/assets/config/manifest.js").exist? - app.config.assets.precompile += %w( manifest.js ) + if ::Rails.root.join("app/assets/config/manifest.js").exist? + app.config.assets.precompile += %w( manifest.js ) + else + msg = "Expected to find a manifest file in `app/assets/config/manifest.js`\n" + + "But did not, please create this file and use it to link any assets that need\n" + + "to be rendered by your app:\n\n" + + "Example:\n" + + " //= link_tree ../images\n" + + " //= link_directory ../javascripts .js\n" + + " //= link_directory ../stylesheets .css\n" + + "and restart your server\n\n" + + "For more information see: https://github.com/rails/sprockets/blob/070fc01947c111d35bb4c836e9bb71962a8e0595/UPGRADING.md#manifestjs" + Sprockets::Rails.deprecator.warn msg + end else app.config.assets.precompile += [LOOSE_APP_ASSETS, /(?:\/|\\|\A)application\.(css|js)$/] end