-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.rb
68 lines (51 loc) · 1.86 KB
/
run.rb
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# frozen_string_literal: true
# TODO
# Separate out handling of 'failed tests' from 'encountered errors'
# Full comments - what's the proper comment structure for ruby classes & functions?
# Move more into ContainerHelper
# Decouple from running the script from a single location
# external dependencies
require 'erb'
require 'fileutils'
require 'logger'
require 'time'
require 'yaml'
# local dependencies
require File.join(File.dirname(__FILE__), "lib/argument_parser.rb")
require File.join(File.dirname(__FILE__), "lib/integration.rb")
require File.join(File.dirname(__FILE__), "lib/container_helper.rb")
require File.join(File.dirname(__FILE__), "lib/erb_helper.rb")
require File.join(File.dirname(__FILE__), "lib/file_helper.rb")
# parse command line arguments
options = ArgumentParser.parse
use_repo_image = options[:userepoimage]
image_tag = options[:imagetag]
spec_file_path = options[:specfilepath]
debug_mode = options[:debug]
# create our temp directory & set up some paths we'll need later on
FileUtils.mkdir_p('tmp')
rundir = Dir.pwd # directory we're running from
specfile = "#{rundir}/#{spec_file_path}"
base_dockerfile_path = 'base.dockerfile' # relative to location of this script
# read the config file in and parse its parts
file = YAML.load_file(specfile)
integrations = file['integrations']
# if we're not using a base image from a remote repo, build the base docker image
if !use_repo_image
ContainerHelper.build_base_image(image_tag, 'base.dockerfile')
end
# run build and test each of the integrations one by one
all_tests_passed = true
for yaml_int in integrations do
integration = Integration.new(yaml_int, image_tag, spec_file_path)
if !integration.run(debug_mode)
all_tests_passed = false
end
end
if all_tests_passed
print "All test passed for all integrations ^_^"
exit 0
else
print "There were test failures >.<"
exit 2
end