mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 21:43:38 +08:00
7288bc277b
Previously, FETCH_HEAD would always point to tests-passed because our base docker image was configured to only fetch the tests-passed branch. Since https://github.com/discourse/discourse_docker/commit/53bbacc882, we switched to a partial clone which means that `git fetch; git checkout FETCH_HEAD` will checkout whichever remote branch is the first alphabetically. This commit makes the checkout more specific to avoid this issue.
39 lines
1.1 KiB
Ruby
39 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# This script is run in the discourse_test docker image
|
|
# Available environment variables:
|
|
# => 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
|
|
|
|
def log(message)
|
|
puts "[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] #{message}"
|
|
end
|
|
|
|
def run_or_fail(command)
|
|
log(command)
|
|
pid = Process.spawn(command)
|
|
Process.wait(pid)
|
|
exit 1 unless $?.exitstatus == 0
|
|
end
|
|
|
|
unless ENV["NO_UPDATE"]
|
|
run_or_fail("git reset --hard")
|
|
run_or_fail("git fetch")
|
|
|
|
checkout = ENV["COMMIT_HASH"] || "origin/tests-passed"
|
|
run_or_fail("LEFTHOOK=0 git checkout #{checkout}")
|
|
|
|
run_or_fail("bundle")
|
|
end
|
|
|
|
log("Running tests")
|
|
|
|
if ENV["RUN_SMOKE_TESTS"]
|
|
run_or_fail("bundle exec rake smoke:test")
|
|
else
|
|
run_or_fail("bundle exec rake docker:test")
|
|
end
|