DEV: support installing plugin gems in test images

DEV: support installing plugin gems in test images

  • adds plugin:install_all_gems rake task

  • adds UPDATE_ALL_PLUGINS env variable in docker:test

diff --git a/lib/tasks/docker.rake b/lib/tasks/docker.rake
index d5f0a8a..9058e22 100644
--- a/lib/tasks/docker.rake
+++ b/lib/tasks/docker.rake
@@ -117,6 +117,10 @@ task 'docker:test' do
         @good &&= run_or_fail("bundle exec rake plugin:install_all_official")
       end
 
+      if ENV["UPDATE_ALL_PLUGINS"]
+        @good &&= run_or_fail("bundle exec rake plugin:update_all")
+      end
+
       if ENV["SKIP_PLUGINS"]
         @good &&= run_or_fail("bundle exec rake db:migrate")
       else
diff --git a/lib/tasks/plugin.rake b/lib/tasks/plugin.rake
index 111b78b..77dc03d 100644
--- a/lib/tasks/plugin.rake
+++ b/lib/tasks/plugin.rake
@@ -87,6 +87,30 @@ task 'plugin:update', :plugin do |t, args|
   abort('Unable to pull latest version of plugin') unless update_status
 end
 
+desc 'install all plugin gems'
+task 'plugin:install_all_gems' do |t|
+  plugins = Dir.glob(File.expand_path('plugins/*')).select { |f| File.directory? f }
+  plugins.each do |plugin|
+    Rake::Task['plugin:install_gems'].invoke(plugin)
+    Rake::Task['plugin:install_gems'].reenable
+  end
+end
+
+desc 'install plugin gems'
+task 'plugin:install_gems', :plugin do |t, args|
+  plugin = ENV['PLUGIN'] || ENV['plugin'] || args[:plugin]
+  plugin_path = plugin + "/plugin.rb"
+
+  if File.file?(plugin_path)
+    File.open(plugin_path).each do |l|
+      next if !l.start_with? "gem"
+      next unless /gem\s['"](.*)['"],\s['"](.*)['"]/.match(l)
+      puts "gem install #{$1} -v #{$2} -i #{plugin}/gems/#{RUBY_VERSION} --no-document --ignore-dependencies --no-user-install"
+      system("gem install #{$1} -v #{$2} -i #{plugin}/gems/#{RUBY_VERSION} --no-document --ignore-dependencies --no-user-install")
+    end
+  end
+end
+
 desc 'run plugin specs'
 task 'plugin:spec', :plugin do |t, args|
   args.with_defaults(plugin: "*")

GitHub sha: 66b15b9d

1 Like