File tree Expand file tree Collapse file tree 3 files changed +54
-48
lines changed
lib/manageiq/cross_repo/runner Expand file tree Collapse file tree 3 files changed +54
-48
lines changed Original file line number Diff line number Diff line change @@ -21,31 +21,6 @@ def build_test_script
21
21
22
22
private
23
23
24
- def environment_setup_commands
25
- commands = [ ]
26
-
27
- if config [ "node_js" ]
28
- commands << "source ~/.nvm/nvm.sh"
29
- commands += Array ( config [ "node_js" ] ) . map do |node_version |
30
- "nvm install #{ node_version } "
31
- end
32
- end
33
-
34
- commands . any? ? build_section ( "environment" , *commands ) : commands
35
- end
36
-
37
- def section_commands
38
- sections = %w[ before_install install before_script script ]
39
- sections . flat_map do |section |
40
- commands = build_section_commands ( section )
41
- build_section ( section , *commands ) if commands . present?
42
- end . compact
43
- end
44
-
45
- def build_commands
46
- environment_setup_commands + section_commands
47
- end
48
-
49
24
def build_section_commands ( section )
50
25
# Travis sections can have a single command or an array of commands
51
26
Array ( config [ section ] ) . map { |cmd | "#{ cmd } || exit $?" }
@@ -60,16 +35,6 @@ def build_section(section, *commands)
60
35
end
61
36
62
37
def load_config!
63
- ci_config . tap do |config |
64
- # Set missing sections to the proper defaults
65
- config [ "install" ] ||= defaults [ config [ "language" ] ] [ "install" ]
66
-
67
- config [ "script" ] = script_cmd if script_cmd . present?
68
- config [ "script" ] ||= defaults [ config [ "language" ] ] [ "script" ]
69
- end
70
- end
71
-
72
- def ci_config
73
38
raise NotImplementedError , "must be implemented in a subclass"
74
39
end
75
40
Original file line number Diff line number Diff line change @@ -13,21 +13,27 @@ def self.available?
13
13
14
14
private
15
15
16
- def ci_config
17
- github_config = YAML . load_file ( CONFIG_FILE )
18
-
19
- steps = github_config [ "jobs" ] [ "ci" ] [ "steps" ]
20
- steps_by_name = steps . index_by { |step | step [ "name" ] }
21
-
22
- language = steps . any? { |s | s [ "uses" ] == "ruby/setup-ruby@v1" } ? "ruby" : "node_js"
23
-
24
- result = { "language" => language }
16
+ def build_commands
17
+ config . dig ( "jobs" , "ci" , "steps" ) . map do |step |
18
+ if step [ "run" ] . nil?
19
+ case step [ "uses" ]
20
+ when /ruby\/ setup-ruby/
21
+ step [ "run" ] = defaults [ "ruby" ] [ "install" ]
22
+ when /actions\/ setup-node/
23
+ step [ "run" ] = defaults [ "node_js" ] [ "install" ]
24
+ end
25
+ end
26
+
27
+ build_section ( step [ "name" ] , step [ "run" ] )
28
+ end . compact
29
+ end
25
30
26
- result [ "before_install" ] = steps_by_name [ "Set up system" ] [ "run" ] if steps_by_name [ "Set up system" ]
27
- result [ "before_script" ] = steps_by_name [ "Prepare tests" ] [ "run" ] if steps_by_name [ "Prepare tests" ]
28
- result [ "script" ] = steps_by_name [ "Run tests" ] [ "run" ] if steps_by_name [ "Run tests" ]
31
+ def load_config!
32
+ ci_config
33
+ end
29
34
30
- result
35
+ def ci_config
36
+ YAML . load_file ( CONFIG_FILE )
31
37
end
32
38
end
33
39
end
Original file line number Diff line number Diff line change @@ -12,6 +12,41 @@ def self.available?
12
12
13
13
private
14
14
15
+ def environment_setup_commands
16
+ commands = [ ]
17
+
18
+ if config [ "node_js" ]
19
+ commands << "source ~/.nvm/nvm.sh"
20
+ commands += Array ( config [ "node_js" ] ) . map do |node_version |
21
+ "nvm install #{ node_version } "
22
+ end
23
+ end
24
+
25
+ commands . any? ? build_section ( "environment" , *commands ) : commands
26
+ end
27
+
28
+ def section_commands
29
+ sections = %w[ before_install install before_script script ]
30
+ sections . flat_map do |section |
31
+ commands = build_section_commands ( section )
32
+ build_section ( section , *commands ) if commands . present?
33
+ end . compact
34
+ end
35
+
36
+ def build_commands
37
+ environment_setup_commands + section_commands
38
+ end
39
+
40
+ def load_config!
41
+ ci_config . tap do |config |
42
+ # Set missing sections to the proper defaults
43
+ config [ "install" ] ||= defaults [ config [ "language" ] ] [ "install" ]
44
+
45
+ config [ "script" ] = script_cmd if script_cmd . present?
46
+ config [ "script" ] ||= defaults [ config [ "language" ] ] [ "script" ]
47
+ end
48
+ end
49
+
15
50
def ci_config
16
51
YAML . load_file ( CONFIG_FILE )
17
52
end
You can’t perform that action at this time.
0 commit comments