Class: CapsuleCD::Engine
- Inherits:
-
Object
- Object
- CapsuleCD::Engine
- Defined in:
- lib/capsulecd/base/engine.rb
Direct Known Subclasses
Chef::ChefEngine, Javascript::JavascriptEngine, Node::NodeEngine, Python::PythonEngine, Ruby::RubyEngine
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #build_step ⇒ Object
-
#initialize(options) ⇒ Engine
constructor
A new instance of Engine.
- #package_step ⇒ Object
- #post_build_step ⇒ Object
- #post_package_step ⇒ Object
- #post_release_step ⇒ Object
- #post_runner_retrieve_payload ⇒ Object
- #post_source_configure ⇒ Object
- #post_source_process_pull_request_payload ⇒ Object
- #post_source_process_push_payload ⇒ Object
- #post_source_release ⇒ Object
- #post_test_step ⇒ Object
- #pre_build_step ⇒ Object
- #pre_package_step ⇒ Object
- #pre_release_step ⇒ Object
- #pre_runner_retrieve_payload ⇒ Object
-
#pre_source_configure ⇒ Object
base methods.
- #pre_source_process_pull_request_payload ⇒ Object
- #pre_source_process_push_payload ⇒ Object
- #pre_source_release ⇒ Object
- #pre_test_step ⇒ Object
- #release_step ⇒ Object
- #start ⇒ Object
- #test_step ⇒ Object
Constructor Details
#initialize(options) ⇒ Engine
Returns a new instance of Engine.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/capsulecd/base/engine.rb', line 8 def initialize() @config = CapsuleCD::Configuration.new() # transform the engine with system config file hooks transformer = CapsuleCD::TransformEngine.new() transformer.transform(self, [:config_file], :global) if @config.source == :github require_relative 'source/github' self.class.send(:include, CapsuleCD::Source::Github) else fail CapsuleCD::Error::SourceUnspecifiedError, 'No source defined.' end # if @config.runner == :circleci # require_relative 'runner/circleci' # self.class.send(:include, CapsuleCD::Runner::Circleci) # else self.class.send(:include, CapsuleCD::Runner::Default) # end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/capsulecd/base/engine.rb', line 6 def config @config end |
Instance Method Details
#build_step ⇒ Object
145 |
# File 'lib/capsulecd/base/engine.rb', line 145 def build_step; puts 'build_step'; end |
#package_step ⇒ Object
151 |
# File 'lib/capsulecd/base/engine.rb', line 151 def package_step; puts 'package_step'; end |
#post_build_step ⇒ Object
146 |
# File 'lib/capsulecd/base/engine.rb', line 146 def post_build_step; puts 'post_build_step'; end |
#post_package_step ⇒ Object
152 |
# File 'lib/capsulecd/base/engine.rb', line 152 def post_package_step; puts 'post_package_step'; end |
#post_release_step ⇒ Object
155 |
# File 'lib/capsulecd/base/engine.rb', line 155 def post_release_step; puts 'post_release_step'; end |
#post_runner_retrieve_payload ⇒ Object
142 |
# File 'lib/capsulecd/base/engine.rb', line 142 def post_runner_retrieve_payload; puts 'post_runner_retrieve_payload'; end |
#post_source_configure ⇒ Object
133 |
# File 'lib/capsulecd/base/engine.rb', line 133 def post_source_configure; puts 'post_source_configure'; end |
#post_source_process_pull_request_payload ⇒ Object
135 |
# File 'lib/capsulecd/base/engine.rb', line 135 def post_source_process_pull_request_payload; puts 'post_source_process_pull_request_payload'; end |
#post_source_process_push_payload ⇒ Object
137 |
# File 'lib/capsulecd/base/engine.rb', line 137 def post_source_process_push_payload; puts 'post_source_process_push_payload'; end |
#post_source_release ⇒ Object
139 |
# File 'lib/capsulecd/base/engine.rb', line 139 def post_source_release; puts 'post_source_release'; end |
#post_test_step ⇒ Object
149 |
# File 'lib/capsulecd/base/engine.rb', line 149 def post_test_step; puts 'post_test_step'; end |
#pre_build_step ⇒ Object
144 |
# File 'lib/capsulecd/base/engine.rb', line 144 def pre_build_step; puts 'pre_build_step'; end |
#pre_package_step ⇒ Object
150 |
# File 'lib/capsulecd/base/engine.rb', line 150 def pre_package_step; puts 'pre_package_step'; end |
#pre_release_step ⇒ Object
153 |
# File 'lib/capsulecd/base/engine.rb', line 153 def pre_release_step; puts 'pre_release_step'; end |
#pre_runner_retrieve_payload ⇒ Object
141 |
# File 'lib/capsulecd/base/engine.rb', line 141 def pre_runner_retrieve_payload; puts 'pre_runner_retrieve_payload'; end |
#pre_source_configure ⇒ Object
base methods
132 |
# File 'lib/capsulecd/base/engine.rb', line 132 def pre_source_configure; puts 'pre_source_configure'; end |
#pre_source_process_pull_request_payload ⇒ Object
134 |
# File 'lib/capsulecd/base/engine.rb', line 134 def pre_source_process_pull_request_payload; puts 'pre_source_process_pull_request_payload'; end |
#pre_source_process_push_payload ⇒ Object
136 |
# File 'lib/capsulecd/base/engine.rb', line 136 def pre_source_process_push_payload; puts 'pre_source_process_push_payload'; end |
#pre_source_release ⇒ Object
138 |
# File 'lib/capsulecd/base/engine.rb', line 138 def pre_source_release; puts 'pre_source_release'; end |
#pre_test_step ⇒ Object
147 |
# File 'lib/capsulecd/base/engine.rb', line 147 def pre_test_step; puts 'pre_test_step'; end |
#release_step ⇒ Object
154 |
# File 'lib/capsulecd/base/engine.rb', line 154 def release_step; puts 'release_step'; end |
#start ⇒ Object
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 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 125 126 127 128 129 |
# File 'lib/capsulecd/base/engine.rb', line 30 def start # start the source, and whatever work needs to be done there. # MUST set @source_git_parent_path # MUST set @source_client pre_source_configure source_configure post_source_configure # runner must determine if this is a pull request or a push. # if it's a pull request the runner must retrieve the pull request payload and return it # if its a push, the runner must retrieve the push payload and return it # the variable @runner_is_pullrequest will be true if a pull request was created. # MUST set runner_is_pullrequest # REQUIRES source_client pre_runner_retrieve_payload payload = runner_retrieve_payload(@options) post_runner_retrieve_payload if @runner_is_pullrequest # all capsule CD processing will be kicked off via a payload. In this case the payload is the pull request data. # should check if the pull request opener even has permissions to create a release. # all sources should process the payload by downloading a git repository that contains the master branch merged with the test branch # MUST set source_git_local_path # MUST set source_git_local_branch # MUST set source_git_base_info # MUST set source_git_head_info # REQUIRES source_client pre_source_process_pull_request_payload source_process_pull_request_payload(payload) post_source_process_pull_request_payload else # start processing the payload, which should result in a local git repository that we # can begin to test. Since this is a push, no packaging is required # MUST set source_git_local_path # MUST set source_git_local_branch # MUST set source_git_head_info # REQUIRES source_client pre_source_process_push_payload source_process_push_payload(payload) post_source_process_push_payload end # update the config with repo config file options @config.populate_repo_config_file(@source_git_local_path) # transform the engine with the repo config file hooks transformer = CapsuleCD::TransformEngine.new() transformer.transform(self, @source_git_local_path + '/capsule.yml', :repo) # now that the payload has been processed we can begin by building the code. # this may be creating missing files/default structure, compilation, version bumping, etc. source_notify('build') do pre_build_step build_step post_build_step end # this step should download dependencies, run the package test runner(s) (eg. npm test, rake test, kitchen test) # REQUIRES @config.engine_cmd_test # REQUIRES @config.engine_disable_test source_notify('test') do pre_test_step test_step post_test_step end # this step should commit any local changes and create a git tag. Nothing should be pushed to remote repository source_notify('package') do pre_package_step package_step post_package_step end if @runner_is_pullrequest # this step should push the release to the package repository (ie. npm, chef supermarket, rubygems) source_notify('release') do pre_release_step release_step post_release_step end # this step should push the merged, tested and version updated code up to the source code repository # this step should also do any source specific releases (github release, asset uploading, etc) source_notify('source release') do pre_source_release source_release post_source_release end end # rescue => ex #TODO if you enable this rescue block, hooks stop working. # TODO: it shouldnt be required anylonger because source_notify will handle rescueing the failures. # puts ex # # self.run_hook :pre_source_process_failure, ex # source_process_failure(ex) # self.run_hook :post_source_process_failure, ex end |
#test_step ⇒ Object
148 |
# File 'lib/capsulecd/base/engine.rb', line 148 def test_step; puts 'test_step'; end |