Class: TinyCI::Scheduler
- Inherits:
-
Object
- Object
- TinyCI::Scheduler
- Includes:
- GitUtils, Logging, Subprocesses
- Defined in:
- lib/tinyci/scheduler.rb
Overview
Manages the execution of test jobs. Responsible for deciding which commits need to be built and tested. Also manages the pidfile. This is the main entrypoint for TinyCI.
Instance Attribute Summary collapse
-
#working_dir ⇒ String
readonly
The working directory to execute against.
Instance Method Summary collapse
-
#initialize(working_dir: nil, logger: nil, commit: nil, runner_class: Runner) ⇒ Scheduler
constructor
Constructor, allows injection of configuration and custom Runner class.
-
#run! ⇒ Boolean
Runs the TinyCI system against the relevant commits.
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: nil, logger: nil, commit: nil, runner_class: Runner) ⇒ Scheduler
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tinyci/scheduler.rb', line 26 def initialize( working_dir: nil, logger: nil, commit: nil, runner_class: Runner ) @working_dir = working_dir || repo_root @logger = logger @runner_class = runner_class @commit = commit end |
Instance Attribute Details
#working_dir ⇒ String (readonly)
The working directory to execute against
12 13 14 |
# File 'lib/tinyci/scheduler.rb', line 12 def working_dir @working_dir end |
Instance Method Details
#run! ⇒ Boolean
Runs the TinyCI system against the relevant commits. Also sets up the pidfile.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tinyci/scheduler.rb', line 42 def run! pid = PidFile.new(pidfile: 'tinyci.pid', piddir: @working_dir) result = if @commit run_commit get_commit @commit else run_all_commits end pid.release result end |