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.ymlindex 03d00a0f29b..eee600f74da 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -28,7 +28,7 @@ jobs:RAILS_ENV: testPGUSER: discoursePGPASSWORD: 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 RSpecif: matrix.build_type == 'backend' && matrix.target == 'plugins'- run: bin/rake plugin:spec+ run: bin/rake plugin:turbo_spec- name: Plugin QUnitif: matrix.build_type == 'frontend' && matrix.target == 'plugins'diff --git a/bin/rake b/bin/rakeindex 61c75ed85af..b699951a809 100755--- a/bin/rake+++ b/bin/rake@@ -2,7 +2,7 @@# frozen_string_literal: trueif 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'enddiff --git a/lib/tasks/plugin.rake b/lib/tasks/plugin.rakeindex 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 !parallelparams << '--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").sortif 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(' ')}"elseabort "No specs found."endend+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: "*")