mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 03:19:10 +00:00
DEV: Skip prettier in single plugin test if patterns aren't found
This reverts d06ca90c94ed5efaf35c50e826e8372906860b82 It didn't work because yarn doesn't return the original exit code of the failed command.
This commit is contained in:
parent
2fc7d2c56d
commit
a474bf966c
@ -28,10 +28,20 @@
|
||||
# Run tests for a specific plugin (with a plugin mounted from host filesystem):
|
||||
# docker run -e SKIP_CORE=1 SINGLE_PLUGIN='my-awesome-plugin' -v $(pwd)/my-awesome-plugin:/var/www/discourse/plugins/my-awesome-plugin discourse/discourse_test:release
|
||||
|
||||
def run_or_fail(command, allowed_exit_codes: [0])
|
||||
def run_or_fail(command)
|
||||
pid = Process.spawn(command)
|
||||
Process.wait(pid)
|
||||
allowed_exit_codes.include?($?.exitstatus)
|
||||
$?.exitstatus == 0
|
||||
end
|
||||
|
||||
def run_or_fail_prettier(*patterns)
|
||||
if patterns.any? { |p| Dir[p].any? }
|
||||
patterns = patterns.map { |p| "'#{p}'" }.join(' ')
|
||||
run_or_fail("yarn prettier --list-different #{patterns}")
|
||||
else
|
||||
puts "Skipping prettier. Pattern not found."
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Run all tests (JS and code in a standalone environment)'
|
||||
@ -49,7 +59,7 @@ task 'docker:test' do
|
||||
@good &&= run_or_fail("yarn eslint --ext .es6 plugins/#{ENV['SINGLE_PLUGIN']}")
|
||||
|
||||
puts "Listing prettier offenses in #{ENV['SINGLE_PLUGIN']}:"
|
||||
@good &&= run_or_fail("yarn prettier --list-different 'plugins/#{ENV['SINGLE_PLUGIN']}/**/*.scss' 'plugins/#{ENV['SINGLE_PLUGIN']}/**/*.es6'", allowed_exit_codes: [0, 2])
|
||||
@good &&= run_or_fail_prettier("plugins/#{ENV['SINGLE_PLUGIN']}/**/*.scss", "plugins/#{ENV['SINGLE_PLUGIN']}/**/*.es6")
|
||||
else
|
||||
@good &&= run_or_fail("bundle exec rubocop --parallel") unless ENV["SKIP_CORE"]
|
||||
@good &&= run_or_fail("yarn eslint app/assets/javascripts test/javascripts") unless ENV["SKIP_CORE"]
|
||||
@ -62,7 +72,7 @@ task 'docker:test' do
|
||||
|
||||
unless ENV["SKIP_PLUGINS"]
|
||||
puts "Listing prettier offenses in plugins:"
|
||||
@good &&= run_or_fail('yarn prettier --list-different "plugins/**/*.scss" "plugins/**/*.es6"', allowed_exit_codes: [0, 2])
|
||||
@good &&= run_or_fail('yarn prettier --list-different "plugins/**/*.scss" "plugins/**/*.es6"')
|
||||
end
|
||||
end
|
||||
puts "travis_fold:end:lint" if ENV["TRAVIS"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user