Merge pull request #5066 from davidtaylorhq/docker-lint-changes

Docker lint SINGLE_PLUGIN
This commit is contained in:
Guo Xiang Tan 2017-08-23 09:56:15 +09:00 committed by GitHub
commit 49ddc98b38
2 changed files with 80 additions and 68 deletions

View File

@ -2,6 +2,8 @@
# running it anywhere else will likely fail
#
# Environment Variables (specific to this rake task)
# => SKIP_LINT set to 1 to skip linting (eslint and rubocop)
# => SKIP_TESTS set to 1 to skip all tests
# => SKIP_CORE set to 1 to skip core tests (rspec and qunit)
# => SKIP_PLUGINS set to 1 to skip plugin tests (rspec and qunit)
# => INSTALL_OFFICIAL_PLUGINS set to 1 to install all core plugins before running tests
@ -31,19 +33,23 @@ def run_or_fail(command)
$?.exitstatus == 0
end
desc 'Run JS and Ruby linters'
task 'docker:lint' do
success = run_or_fail("bundle exec rubocop --parallel")
success = run_or_fail("eslint app/assets/javascripts test/javascripts")
success = run_or_fail("eslint --ext .es6 app/assets/javascripts test/javascripts plugins")
exit 1 if !success
end
desc 'Run all tests (JS and code in a standalone environment)'
task 'docker:test' do
begin
@good = true
unless ENV['SKIP_LINT']
puts "Running linters"
if ENV["SINGLE_PLUGIN"]
@good &&= run_or_fail("bundle exec rubocop --parallel plugins/#{ENV["SINGLE_PLUGIN"]}")
@good &&= run_or_fail("eslint --ext .es6 plugins/#{ENV['SINGLE_PLUGIN']}")
else
@good &&= run_or_fail("bundle exec rubocop --parallel") unless ENV["SKIP_CORE"]
@good &&= run_or_fail("eslint app/assets/javascripts test/javascripts") unless ENV["SKIP_CORE"]
@good &&= run_or_fail("eslint --ext .es6 app/assets/javascripts test/javascripts plugins") unless ENV["SKIP_PLUGINS"]
end
end
unless ENV['SKIP_TESTS']
puts "Cleaning up old test tmp data in tmp/test_data"
`rm -fr tmp/test_data && mkdir -p tmp/test_data/redis && mkdir tmp/test_data/pg`
@ -63,7 +69,7 @@ task 'docker:test' do
ENV["RAILS_ENV"] = "test"
@good = run_or_fail("bundle exec rake db:create db:migrate")
@good &&= run_or_fail("bundle exec rake db:create db:migrate")
if ENV["INSTALL_OFFICIAL_PLUGINS"]
@good &&= run_or_fail("bundle exec rake plugin:install_all_official")
@ -107,14 +113,15 @@ task 'docker:test' do
end
end
end
ensure
puts "Terminating"
Process.kill("TERM", @redis_pid)
Process.kill("TERM", @pg_pid)
Process.wait @redis_pid
Process.wait @pg_pid
Process.kill("TERM", @redis_pid) if @redis_pid
Process.kill("TERM", @pg_pid) if @pg_pid
Process.wait @redis_pid if @redis_pid
Process.wait @pg_pid if @pg_pid
end
if !@good

View File

@ -1,3 +1,9 @@
# This script is run in the discourse_test docker image
# Available environment variables:
# => COMMIT_HASH used by the discourse_test docker image to load a specific commit of discourse
# this can also be set to a branch, e.g. "origin/tests-passed"
# See lib/tasks/docker.rake for more information
def run_or_fail(command)
pid = Process.spawn(command)
Process.wait(pid)
@ -12,5 +18,4 @@ unless ENV['NO_UPDATE']
run_or_fail("bundle")
end
run_or_fail("bundle exec rake docker:lint") if !ENV["SKIP_LINT"]
run_or_fail("bundle exec rake docker:test") if !ENV["LINT_ONLY"]
run_or_fail("bundle exec rake docker:test")