Class: TinyCI::Runner
- Inherits:
-
Object
- Object
- TinyCI::Runner
- Includes:
- GitUtils, Logging, Subprocesses
- Defined in:
- lib/tinyci/runner.rb
Overview
Responsible for managing the running of TinyCI against a single git object.
Instance Attribute Summary collapse
-
#builder ⇒ TinyCI::Executor
Returns the Builder object.
-
#hooker ⇒ Object
Returns the value of attribute hooker.
-
#tester ⇒ TinyCI::Executor
Returns the Tester object.
Instance Method Summary collapse
-
#export_path ⇒ Object
Build the export path.
-
#initialize(working_dir: '.', commit:, time: nil, logger: nil, config: nil) ⇒ Runner
constructor
Constructor, allows injection of generic configuration params.
-
#run! ⇒ Boolean
Runs the TinyCI system against the single git object referenced in
@commit. -
#target_path ⇒ Object
Build the absolute target path.
Methods included from GitUtils
#git_cmd, #git_directory_path, #inside_bare_repo?, #inside_git_directory?, #inside_repository?, #inside_work_tree?, #repo_root
Methods included from Subprocesses
#execute, #execute_pipe, #execute_stream
Constructor Details
#initialize(working_dir: '.', commit:, time: nil, logger: nil, config: nil) ⇒ Runner
Constructor, allows injection of generic configuration params.
37 38 39 40 41 42 43 |
# File 'lib/tinyci/runner.rb', line 37 def initialize(working_dir: '.', commit:, time: nil, logger: nil, config: nil) @working_dir = working_dir @logger = logger @config = config @commit = commit @time = time || commit_time end |
Instance Attribute Details
#builder ⇒ TinyCI::Executor
Returns the Builder object. Used solely for testing at this time.
23 24 25 |
# File 'lib/tinyci/runner.rb', line 23 def builder @builder end |
#hooker ⇒ Object
Returns the value of attribute hooker.
28 29 30 |
# File 'lib/tinyci/runner.rb', line 28 def hooker @hooker end |
#tester ⇒ TinyCI::Executor
Returns the Tester object. Used solely for testing at this time.
23 24 25 |
# File 'lib/tinyci/runner.rb', line 23 def tester @tester end |
Instance Method Details
#export_path ⇒ Object
Build the export path
132 133 134 |
# File 'lib/tinyci/runner.rb', line 132 def export_path File.join(target_path, 'export') end |
#run! ⇒ Boolean
Runs the TinyCI system against the single git object referenced in @commit.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/tinyci/runner.rb', line 48 def run! begin ensure_path target_path setup_log log_info "Commit: #{@commit}" log_info "Cleaning..." clean log_info "Exporting..." ensure_path export_path export begin load_config rescue ConfigMissingError => e log_error e. log_error 'Removing export...' clean return false end @builder ||= instantiate_builder @tester ||= instantiate_tester @hooker ||= instantiate_hooker log_info "Building..." run_hook! :before_build begin @builder.build run_hook! :after_build_success rescue => e run_hook! :after_build_failure raise e if ENV['TINYCI_ENV'] == 'test' log_error e log_debug e.backtrace return false ensure run_hook! :after_build end log_info "Testing..." run_hook! :before_test begin @tester.test rescue => e run_hook! :after_test_failure raise e if ENV['TINYCI_ENV'] == 'test' log_error e log_debug e.backtrace return false ensure run_hook! :after_test end run_hook! :after_test_success log_info "Finished #{@commit}" rescue => e raise e if ENV['TINYCI_ENV'] == 'test' log_error e log_debug e.backtrace return false end true end |
#target_path ⇒ Object
Build the absolute target path
127 128 129 |
# File 'lib/tinyci/runner.rb', line 127 def target_path File.absolute_path("#{@working_dir}/builds/#{@time.to_i}_#{@commit}/") end |