Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add `rake plugins:turbo_spec` task (#18289)

David Tayloref39193a06a4
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 03d00a0f29b..eee600f74da 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -28,7 +28,7 @@ jobs:
RAILS_ENV: test
PGUSER: discourse
PGPASSWORD: discourse
- USES_PARALLEL_DATABASES: ${{ matrix.build_type == 'backend' && matrix.target == 'core' }}
+ USES_PARALLEL_DATABASES: ${{ matrix.build_type == 'backend' }}
EMBER_CLI_PLUGIN_ASSETS: ${{ matrix.ember_cli_plugin_assets }}
strategy:
@@ -158,7 +158,7 @@ jobs:
- name: Plugin RSpec
if: matrix.build_type == 'backend' && matrix.target == 'plugins'
- run: bin/rake plugin:spec
+ run: bin/rake plugin:turbo_spec
- name: Plugin QUnit
if: matrix.build_type == 'frontend' && matrix.target == 'plugins'
diff --git a/bin/rake b/bin/rake
index 61c75ed85af..b699951a809 100755
--- a/bin/rake
+++ b/bin/rake
@@ -2,7 +2,7 @@
# frozen_string_literal: true
if ENV['RAILS_ENV'] == 'test' && ENV['LOAD_PLUGINS'].nil?
- if ARGV.include?('db:migrate')
+ if ARGV.include?('db:migrate') || ARGV.include?('parallel:migrate')
STDERR.puts "You are attempting to run migrations in your test environment and are not loading plugins, setting LOAD_PLUGINS to 1"
ENV['LOAD_PLUGINS'] = '1'
end
diff --git a/lib/tasks/plugin.rake b/lib/tasks/plugin.rake
index 7b29c264e90..e9b6218615d 100644
--- a/lib/tasks/plugin.rake
+++ b/lib/tasks/plugin.rake
@@ -167,23 +167,34 @@ task 'plugin:install_gems', :plugin do |t, args|
puts "Done"
end
-desc 'run plugin specs'
-task 'plugin:spec', :plugin do |t, args|
- args.with_defaults(plugin: "*")
-
- params = ['--profile']
+def spec(plugin, parallel: false)
+ params = []
+ params << '--profile' if !parallel
params << '--fail-fast' if ENV['RSPEC_FAILFAST']
params << "--seed #{ENV['RSPEC_SEED']}" if Integer(ENV['RSPEC_SEED'], exception: false)
ruby = `which ruby`.strip
- files = Dir.glob("./plugins/#{args[:plugin]}/spec/**/*_spec.rb").sort
+ files = Dir.glob("./plugins/#{plugin}/spec/**/*_spec.rb").sort
if files.length > 0
- sh "LOAD_PLUGINS=1 #{ruby} -S rspec #{files.join(' ')} #{params.join(' ')}"
+ cmd = parallel ? "bin/turbo_rspec" : "bin/rspec"
+ sh "LOAD_PLUGINS=1 #{cmd} #{files.join(' ')} #{params.join(' ')}"
else
abort "No specs found."
end
end
+desc 'run plugin specs'
+task 'plugin:spec', :plugin do |t, args|
+ args.with_defaults(plugin: "*")
+ spec(args[:plugin])
+end
+
+desc 'run plugin specs in parallel'
+task 'plugin:turbo_spec', :plugin do |t, args|
+ args.with_defaults(plugin: "*")
+ spec(args[:plugin], parallel: true)
+end
+
desc 'run plugin qunit tests'
task 'plugin:qunit', [:plugin, :timeout] do |t, args|
args.with_defaults(plugin: "*")