mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 05:59:39 +08:00
DEV: Add rake plugins:turbo_spec
task (#18289)
This leans on our existing `turbo_rspec` implementation to run plugin specs in parallel on all available cores
This commit is contained in:
parent
59071a13f4
commit
ef39193a06
4
.github/workflows/tests.yml
vendored
4
.github/workflows/tests.yml
vendored
|
@ -28,7 +28,7 @@ jobs:
|
||||||
RAILS_ENV: test
|
RAILS_ENV: test
|
||||||
PGUSER: discourse
|
PGUSER: discourse
|
||||||
PGPASSWORD: 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 }}
|
EMBER_CLI_PLUGIN_ASSETS: ${{ matrix.ember_cli_plugin_assets }}
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
|
@ -158,7 +158,7 @@ jobs:
|
||||||
|
|
||||||
- name: Plugin RSpec
|
- name: Plugin RSpec
|
||||||
if: matrix.build_type == 'backend' && matrix.target == 'plugins'
|
if: matrix.build_type == 'backend' && matrix.target == 'plugins'
|
||||||
run: bin/rake plugin:spec
|
run: bin/rake plugin:turbo_spec
|
||||||
|
|
||||||
- name: Plugin QUnit
|
- name: Plugin QUnit
|
||||||
if: matrix.build_type == 'frontend' && matrix.target == 'plugins'
|
if: matrix.build_type == 'frontend' && matrix.target == 'plugins'
|
||||||
|
|
2
bin/rake
2
bin/rake
|
@ -2,7 +2,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
if ENV['RAILS_ENV'] == 'test' && ENV['LOAD_PLUGINS'].nil?
|
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"
|
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'
|
ENV['LOAD_PLUGINS'] = '1'
|
||||||
end
|
end
|
||||||
|
|
|
@ -167,23 +167,34 @@ task 'plugin:install_gems', :plugin do |t, args|
|
||||||
puts "Done"
|
puts "Done"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'run plugin specs'
|
def spec(plugin, parallel: false)
|
||||||
task 'plugin:spec', :plugin do |t, args|
|
params = []
|
||||||
args.with_defaults(plugin: "*")
|
params << '--profile' if !parallel
|
||||||
|
|
||||||
params = ['--profile']
|
|
||||||
params << '--fail-fast' if ENV['RSPEC_FAILFAST']
|
params << '--fail-fast' if ENV['RSPEC_FAILFAST']
|
||||||
params << "--seed #{ENV['RSPEC_SEED']}" if Integer(ENV['RSPEC_SEED'], exception: false)
|
params << "--seed #{ENV['RSPEC_SEED']}" if Integer(ENV['RSPEC_SEED'], exception: false)
|
||||||
|
|
||||||
ruby = `which ruby`.strip
|
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
|
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
|
else
|
||||||
abort "No specs found."
|
abort "No specs found."
|
||||||
end
|
end
|
||||||
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'
|
desc 'run plugin qunit tests'
|
||||||
task 'plugin:qunit', [:plugin, :timeout] do |t, args|
|
task 'plugin:qunit', [:plugin, :timeout] do |t, args|
|
||||||
args.with_defaults(plugin: "*")
|
args.with_defaults(plugin: "*")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user