forked from cloudfoundry-attic/warden-test-infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci-build
More file actions
executable file
·38 lines (34 loc) · 970 Bytes
/
ci-build
File metadata and controls
executable file
·38 lines (34 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env ruby
require 'tmpdir'
require 'timeout'
require 'fileutils'
BUILD_TIMEOUT_IN_SECONDS = 2400
TEST_INFRA_PATH = File.expand_path File.dirname(__FILE__)
BUILD_TO_RUN_PATH = Dir.pwd
def sh(cmd)
ok = system(cmd)
raise RuntimeError unless ok
ok
end
tmpdir = Dir.mktmpdir
FileUtils.copy("#{TEST_INFRA_PATH}/create_vagrant_and_run_test.sh", tmpdir)
FileUtils.copy("#{TEST_INFRA_PATH}/start_warden.sh", tmpdir)
puts "Running vagrant in a temporary folder: #{tmpdir}"
Dir.chdir(tmpdir) do
begin
Timeout.timeout(BUILD_TIMEOUT_IN_SECONDS) do
sh("bash -x ./create_vagrant_and_run_test.sh '#{BUILD_TO_RUN_PATH}' '#{TEST_INFRA_PATH}'")
end
rescue Timeout::Error => e
puts 'Build took too long, killing the VM'
raise e
ensure
if ENV["NODESTROY"]
puts "Skipping vagrant destroy"
else
sh('vagrant destroy --force')
puts 'Destroyed the vagrant box, vagrant status: '
end
sh('vagrant status')
end
end