mirror of
https://github.com/discourse/discourse.git
synced 2024-11-21 16:38:15 -06: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
|
||||
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'
|
||||
|
2
bin/rake
2
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
|
||||
|
@ -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: "*")
|
||||
|
Loading…
Reference in New Issue
Block a user