2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-19 05:10:17 -05:00
|
|
|
# This script is run in the discourse_test docker image
|
|
|
|
# Available environment variables:
|
2017-12-20 08:46:38 -06:00
|
|
|
# => NO_UPDATE disables updating the source code within the discourse_test docker image
|
|
|
|
# => 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"
|
|
|
|
# => RUN_SMOKE_TESTS executes the smoke tests instead of the regular tests from docker.rake
|
|
|
|
# See lib/tasks/docker.rake and lib/tasks/smoke_test.rake for more information
|
2017-08-19 05:10:17 -05:00
|
|
|
|
2018-09-12 10:43:21 -05:00
|
|
|
puts "travis_fold:end:starting_docker_container" if ENV["TRAVIS"]
|
|
|
|
|
2019-05-29 06:28:02 -05:00
|
|
|
def log(message)
|
2019-05-29 07:06:32 -05:00
|
|
|
puts "[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] #{message}"
|
2019-05-29 05:06:43 -05:00
|
|
|
end
|
|
|
|
|
2014-06-19 18:26:25 -05:00
|
|
|
def run_or_fail(command)
|
2019-05-29 06:28:02 -05:00
|
|
|
log(command)
|
2014-06-19 18:26:25 -05:00
|
|
|
pid = Process.spawn(command)
|
|
|
|
Process.wait(pid)
|
|
|
|
exit 1 unless $?.exitstatus == 0
|
|
|
|
end
|
|
|
|
|
|
|
|
unless ENV['NO_UPDATE']
|
2018-09-12 10:43:21 -05:00
|
|
|
puts "travis_fold:start:pulling_latest_discourse" if ENV["TRAVIS"]
|
2019-05-29 05:06:43 -05:00
|
|
|
|
2018-10-03 09:32:16 -05:00
|
|
|
run_or_fail("git reset --hard")
|
2019-05-29 05:06:43 -05:00
|
|
|
|
2018-05-15 08:09:49 -05:00
|
|
|
run_or_fail("git pull")
|
2014-06-19 18:26:25 -05:00
|
|
|
|
|
|
|
checkout = ENV['COMMIT_HASH'] || "HEAD"
|
|
|
|
run_or_fail("git checkout #{checkout}")
|
2018-09-12 10:43:21 -05:00
|
|
|
|
|
|
|
puts "travis_fold:end:pulling_latest_discourse" if ENV["TRAVIS"]
|
|
|
|
puts "travis_fold:start:bundle" if ENV["TRAVIS"]
|
|
|
|
|
2014-06-19 18:26:25 -05:00
|
|
|
run_or_fail("bundle")
|
2018-09-12 10:43:21 -05:00
|
|
|
|
|
|
|
puts "travis_fold:end:bundle" if ENV["TRAVIS"]
|
2014-06-19 18:26:25 -05:00
|
|
|
end
|
|
|
|
|
2019-05-29 05:06:43 -05:00
|
|
|
log("Running tests")
|
2017-12-20 08:46:38 -06:00
|
|
|
if ENV['RUN_SMOKE_TESTS']
|
|
|
|
run_or_fail("bundle exec rake smoke:test")
|
|
|
|
else
|
|
|
|
run_or_fail("bundle exec rake docker:test")
|
|
|
|
end
|