From 261bea6966c2941632532febd626986d06975a64 Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Thu, 13 Jun 2024 20:03:56 -0700 Subject: [PATCH] Run tests locally (#736) * WIP * Rebase on another branch * Changed in CI Please review the changes in the files in this commit carefully, as they were automatically generated during CI. Run `git pull` to bring the changes into your local branch. Then, if you do not want the changes, run `git revert HEAD`. * Update gemfiles for gems not in Ruby 3.4 --------- Co-authored-by: github-actions --- .yarnrc | 2 +- Rakefile | 23 +++++++++++++++++++++++ gemfiles/6.1.gemfile | 2 ++ gemfiles/7.0.gemfile | 2 ++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.yarnrc b/.yarnrc index f2935e18d..0ad68e3dc 100644 --- a/.yarnrc +++ b/.yarnrc @@ -2,4 +2,4 @@ # yarn lockfile v1 -lastUpdateCheck 1709415989700 +lastUpdateCheck 1718162593302 diff --git a/Rakefile b/Rakefile index 49e7366cc..456e90064 100644 --- a/Rakefile +++ b/Rakefile @@ -28,3 +28,26 @@ desc 'Run RuboCop checks' RuboCop::RakeTask.new(:rubocop) task default: %i[test rubocop:autocorrect] + +namespace :test do + desc "Run tests for all supported Rails versions, with current Ruby version" + task :all do + original_directory = Dir.pwd + original_gemfile = ENV["BUNDLE_GEMFILE"] + gemfiles = Dir.glob("gemfiles/*.gemfile").reject { |f| File.basename(f) == "common.gemfile" } + gemfiles.each do |f| + ENV["BUNDLE_GEMFILE"] = f + system("bundle check") || system("bundle install") + system("bundle exec rake test") + end + + Dir.chdir("demo") + ENV.delete("BUNDLE_GEMFILE") + system("bundle check") || system("bundle install") + system("bundle exec rake test:all") + + ensure + original_gemfile.nil? ? ENV.delete("BUNDLE_GEMFILE") : ENV["BUNDLE_GEMFILE"] = original_gemfile + Dir.chdir(original_directory) + end +end diff --git a/gemfiles/6.1.gemfile b/gemfiles/6.1.gemfile index fd6a3abc6..19b306284 100644 --- a/gemfiles/6.1.gemfile +++ b/gemfiles/6.1.gemfile @@ -4,5 +4,7 @@ eval File.read(gems), binding, gems # rubocop: disable Security/Eval gem "bigdecimal" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") gem "drb" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") +gem "base64" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") +gem "logger" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") gem "rails", "~> 6.1.0" gem "sqlite3", "~> 1.4" diff --git a/gemfiles/7.0.gemfile b/gemfiles/7.0.gemfile index 15accfc2a..b4518ab65 100644 --- a/gemfiles/7.0.gemfile +++ b/gemfiles/7.0.gemfile @@ -4,6 +4,8 @@ eval File.read(gems), binding, gems # rubocop: disable Security/Eval gem "bigdecimal" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") gem "drb" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") +gem "base64" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") +gem "logger" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") gem "rails", "~> 7.0.2" gem "sqlite3", "~> 1.4" gem "sprockets-rails", require: "sprockets/railtie"