blazing 0.2.7 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format nested
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ree
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  ## master
2
2
 
3
+ ## 0.2.9 - February 7, 2012
4
+
5
+ * Fixes concerning recipe loading in blazing core and recipe gems.
6
+
7
+ ## 0.2.8 - February 7, 2012
8
+
9
+ * no default target unless there is only one in config
10
+ * ability to run seutp and update on all targets by specifiying all as target on command line
11
+ * rewrite CLI interface, uses Thor
12
+ * basic integration specs
13
+ * update and improve readme and sample configuration
14
+ * deprecate `repository` DSL method
15
+ * allow environment variables to be defined in config when setting the
16
+ rake task (#58)
17
+ * allow the RAILS_ENV to be specified for a target (will be used when
18
+ calling rake) (#58)
19
+
3
20
  ## 0.2.7 - November 24, 2011
4
21
 
5
22
  * fix hook rake call, run it with bundle exec like the rest
data/Guardfile CHANGED
@@ -1,7 +1,5 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard 'rspec', :version => 2, :cli => "--colour --fail-fast --format nested" do
1
+ guard :rspectacle, :version => 2, :cli => "--colour --fail-fast --format nested" do
2
+ watch('spec/spec_helper.rb') { %w(spec/spec_helper spec) }
5
3
  watch(%r{^spec/.+_spec\.rb})
6
4
  watch(%r{^lib/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
7
5
  watch(%r{^lib/blazing/(.+)\.rb}) { |m| "spec/blazing/#{m[1]}_spec.rb" }
data/README.md CHANGED
@@ -1,24 +1,39 @@
1
- [![Build Status](https://secure.travis-ci.org/effkay/blazing.png)](http://travis-ci.org/effkay/blazing)
1
+ [![Build Status](https://secure.travis-ci.org/effkay/blazing.png?branch=master)](http://travis-ci.org/effkay/blazing)
2
2
 
3
- # Blazing fast and painless git push deploys
3
+ Blazing fast and painless git push deploys
4
+ ==========================================
4
5
 
5
6
  *Oh no, yet another deployer!*
6
7
 
7
- Not everyone can or wants to deploy on heroku. But now you can have the same (well, almost the same, since we're not gonna patch SSH) awesomely smooth git push deploys on whatever server you have SSH access to.
8
+ Not everyone can or wants to deploy on heroku. But now you can have the same (well, almost the same, since we're not gonna patch SSH) awesomely smooth git push deploys on whatever server you have SSH access to. In short, blazing helps you create nice git post-receive hooks and is extendable by plugins.
8
9
 
9
- ## Quickstart
10
+ Quickstart
11
+ ----------
10
12
 
11
- `blazing init`, edit the configuration, run `blazing setup [target]` and you're set. Deploy with `git push <target> <branch>` or setup git to always push your current branch.
13
+ `blazing init`, edit your blaing config, run `blazing setup [target]` to deploy your post-receive hook and you're set. Deploy with `git push <target> <branch>`.
12
14
 
13
- ## Overview & Background
15
+ Features
16
+ --------
17
+
18
+ Out of the box, blazing can do the following:
19
+
20
+ * set up a repository you can push to for deployment
21
+ * set up a git post-receive hook, configurable by a simple DSL
22
+ * works with rvm
23
+ * uses bundler for dependency management
24
+ * allows you to run custom rake tasks after deployment
25
+ * is extendable by blazing recipes
26
+
27
+ Overview & Background
28
+ ---------------------
14
29
 
15
30
  Blazing is a deployment tool written in Ruby. It provides helpers to setup your project with a git post-receive hook, which is triggered every time you push to your production repository.
16
31
 
17
32
  I initially started working on an extension to capistrano which would cover most of my needs and the nees of my team. After a short while I noticed that bolting more functionality on top of capistrano was just going to be messy (and a PTA to maintain). We were alerady using tons of own recipes and customizations, capistrano multistage, capistrano-ext, etc.
18
-
33
+
19
34
  I had a look at what others were doing and after a round of trying around and not getting what I wanted, I started this.
20
-
21
- ## Design Goals
35
+
36
+ #### Design Goals
22
37
 
23
38
  When I started working on blazing, I had some design goals in mind which I think should stay relevant for this project:
24
39
 
@@ -27,71 +42,129 @@ When I started working on blazing, I had some design goals in mind which I think
27
42
  - no messy rake scripts: Define the desired behavior trough a DSL, and extensions add to this DSL in a clean and modular way
28
43
  - Deployments should be fast
29
44
 
30
- ### Inspiration & Alternatives
31
-
45
+ #### Inspiration & Alternatives
46
+
32
47
  I looked at [Inploy](https://github.com/dcrec1/inploy) and [Vlad](https://github.com/seattlerb/vlad) after having used [Capistrano](https://github.com/capistrano/capistrano) for several
33
48
  years. Then got inspired by defunkt's
34
49
  [blog post](https://github.com/blog/470-deployment-script-spring-cleaning) about deployment script spring cleaning. Other's doing a similar thing with git push deployments are Mislav's [git-deploy](https://github.com/mislav/git-deploy) (which was a great inspiration and resource) and [pushand](https://github.com/remi/pushand.git) by remi. If you don't like blazing, you might give them a try.
35
50
 
36
- ## Installation
51
+ Usage
52
+ -----
37
53
 
38
- Your machine should be setup with ruby, rubygems, bundler and git. Install blazing by adding it to your `Gemfile` or run `gem install blazing`. The basic assumption from now on will be that you are working on a project with bundler and a Gemfile. Support for other ways to handle dependencies might be added in the future, but for now bundler is required.
54
+ #### Installation
39
55
 
40
- ## Usage
56
+ Your machine should be setup with ruby, rubygems, bundler and git. Install blazing by adding it to your `Gemfile` or run `gem install blazing`. The basic assumption from now on will be that you are working on a project with bundler and a Gemfile. Support for other ways to handle dependencies might be added in the future but **at the moment bundler is required**.
41
57
 
42
- ### Init
58
+ #### blazing Commands
43
59
 
44
- Run `blazing init` in your project root to create a sample config file.
60
+ ##### `blazing init`
45
61
 
46
- ### Configuration
62
+ Generate a blazing config file
47
63
 
48
- See the generated configuration file or [the template file](https://github.com/effkay/blazing/blob/master/lib/blazing/templates/config.erb) for available configuration options.
64
+ ##### `blazing setup <target>`
49
65
 
50
- ### Setup
66
+ Setup target repository for deployment and add git remote localy. Use 'all' as target name to update all configured targets at once.
51
67
 
52
- `blazing setup` will:
68
+ ##### `blazing update <target>`
53
69
 
54
- * setup your local repository for deployment with blazing/git push. Basically, it will add a remote for each target you defined in the configuration file.
55
- * clone the repository to the specified location
56
- * setup the repository to allow a currently checked out branch to be pushed to it
70
+ Update post-receive hook according to current config. Run it after changing the blazing config. Use 'all' as target name to update all configured targets at once.
57
71
 
58
- Whenever you change something in your blazing config file you can run the `update` command so your git post-receive hook and your git remotess get updated.
72
+ ##### `blazing list`
59
73
 
60
- ### Deploying
74
+ List available recipes
61
75
 
62
- Just push to your remote… so if you set up a target named `:production`, use `git push production master` to deploy your master branch there.
76
+ ##### `blazing recipes`
63
77
 
64
- ### Recipes
78
+ Run the configured recipes (used on deployment target, can be used to test recipes localy)
65
79
 
66
- Right now blazing does the following things out of the box:
80
+ The `setup` and `update` commands also take 'all' as an option. This .
67
81
 
68
- * use rvm if you specify it in your config (by passing an rvm string or just `:rvmrc`, which will load the rvmrc)
69
- * checkout the pushed ref… so if you do git push production master, the last commit of the master branch will be checked out. Before doing a checkout blazing will reset to HEAD so no errors happen due to changed files. **This means that you will loose any uncommited changes on the production repository. Having changes there is a bad idea anyway!**
70
- * run bundle --deployment so the dependencies are installed
71
- * run all recipes, in the order that they are defined
72
- * run the rake task if one was specified
82
+ #### Configuration (blazing DSL)
83
+
84
+ ```ruby
85
+ # Sample target definition:
86
+ #
87
+ # target <target_name>, <target_location>, [options]
88
+ #
89
+ # The options provided in the target definition will override any
90
+ # options provided in the recipe call.
91
+ #
92
+ # Options recognized by blazing core:
93
+ # rails_env: used when calling the rake task after deployment
94
+
95
+ target :staging, 'screenconcept@ruby:/var/www/vischer.ruby.screenconcept.ch',
96
+ :recipe_specific_option => 'foo', :rails_env => 'production'
97
+
98
+
99
+ # Sample rvm setup:
100
+ #
101
+ # rvm <rvm-string>
102
+ #
103
+ # Setting the rvm string will make sure that the correct rvm ruby and
104
+ # gemset is used before the post-receive hook does anything at all.
105
+ # Use :rvmrc as rvm string if you want blazing to use the rvm
106
+ # environment specified in your project's .rvmrc file.
107
+
108
+ rvm 'ruby-1.9.3@some-gemset'
109
+
110
+
111
+ # Sample config for custom rvm location:
112
+ #
113
+ # rvm_scripts <path_to_rvm_scripts>
114
+ #
115
+ # If you have installed rvm to a custom location, use this method to
116
+ # specify where the rvm scripts are located.
117
+
118
+ rvm_scripts '/opt/rvm/scripts/rvm'
119
+
120
+
121
+ # Sample recipe setup:
122
+ #
123
+ # recipe <recipe_name>, [options]
124
+ #
125
+ # The given recipe will be called with the provided options. Refer to each
126
+ # recipe's documentation for available options. Options provided here
127
+ # may be overridden by target specific options.
128
+ # Recipes will be executed in the order they are defined!yy
129
+
130
+ recipe :precompile_assets, :recipe_specific_option => 'bar'
131
+
132
+
133
+ # Sample rake file config:
134
+ #
135
+ # rake <task>, [environment variables]
136
+ #
137
+ # The provided rake task will be run after all recipes have run.
138
+ # Note: you can only call a single rake task. If you need to run several
139
+ # tasks just create one task that wrapps all the others.
140
+
141
+ rake :post_deploy, 'RAILS_ENV=production'
142
+ ```
73
143
 
74
- Run all recipes? Well yes, blazing can be extended by recipes. So far, these are available:
144
+ #### Deploying
75
145
 
76
- * [blazing-passenger](https://github.com/effkay/blazing-passenger)
77
- * [blazing-rails](https://github.com/effkay/blazing-rails)
146
+ Just push to your remote… so if you set up a target named `production`, use `git push production master` to deploy your master branch there.
78
147
 
79
- Feel free to roll your own recipes!
148
+ Recipes
149
+ -------
80
150
 
81
- ## Development & Contribution
151
+ Blazing only offers a small set of core features. However, it is extendable by recipes.
82
152
 
83
- ### Improving Blazing itself
153
+ #### Available Recipes
84
154
 
85
- If you like blazing and want to improve/fix something, feel free, I'm glad for every pull request. Maybe contact me beforehand so we don't fix the same bugs twice and make sure you stick with a similar code style and have tests in your pull request.
155
+ * [blazing-passenger](https://github.com/effkay/blazing-passenger)
156
+ * [blazing-rails](https://github.com/effkay/blazing-rails)
86
157
 
87
- ### Creating custom Blazing Recipes
158
+ #### Creating a blazing Recipe
88
159
 
89
- I would like to add recipes that encapuslate common deployment strategies to blazing. If you have an idea for that, you are welcome to contribute. Right now I am still working on a clever API for this. At the moment the recipe API works as follows:
160
+ Creating a blazing recipe is very easy. There are some ground rules:
90
161
 
91
162
  * recipes should live in gems called `blazing-<somename>`
92
163
  * blazing converts the symbol given in the config to the class name and calls run on it. So if you have `recipe :passenger_restart` blazing will try to run `Blazing::Recipe::PassengerRestart.run` with the options provided.
93
164
  * Recipes should live in the `Blazing::Recipe` namespace and inherit from `Blazing::Recipe` as well
94
165
  * Recipes are run in the order they are specified in the config, so there is no way to handle inter-recipe dependencies yet.
166
+ * Make sure your recipe classes are loaded when the recipe gem itself is
167
+ loaded
95
168
  * A minimal recipe implementation might look like this:
96
169
 
97
170
  ```ruby
@@ -103,12 +176,26 @@ class Blazing::Recipe::Example < Blazing::Recipe
103
176
  end
104
177
  end
105
178
  ```
179
+ Please have a look at [blazing-passenger](https://github.com/effkay/blazing-passenger) to get an idea of how to implement your recipe.
180
+
181
+ Development
182
+ -----------
183
+
184
+ Pull requests are very welcome! Please try to follow these simple rules if applicable:
185
+
186
+ * Please create a topic branch for every separate change you make.
187
+ * Make sure your patches are well tested.
188
+ * Update the README.
189
+ * Update the CHANGELOG for noteworthy changes.
190
+ * Please **do not change** the version number.
106
191
 
107
- ## Authors
192
+ Authors
193
+ -------
108
194
 
109
195
  Felipe Kaufmann ([@effkay][])
110
196
 
111
- ## License
197
+ License
198
+ -------
112
199
 
113
200
  See the [MIT-LICENSE file](https://github.com/effkay/blazing/blob/master/MIT-LICENCE)
114
201
 
data/bin/blazing CHANGED
@@ -1,38 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'bundler'
4
- Bundler.setup
5
-
6
3
  require 'blazing'
7
- require 'blazing/config'
8
- require 'blazing/runner'
9
- require 'optparse'
10
-
11
- options = {}
12
-
13
- optparse = OptionParser.new do|opts|
14
- opts.banner = "Usage: blazing <command> [options]"
15
-
16
- opts.on( '-h', '--help', 'Display this screen' ) do
17
- puts opts
18
- exit
19
- end
20
-
21
- opts.on( '-f config', '--file config', 'specify config file location (defaults to config/blazing.rb)' ) do |file|
22
- options[:file] = file
23
- end
24
- end
25
-
26
- optparse.parse!(ARGV)
27
-
28
- command = ARGV[0]
29
- target = ARGV[1]
30
-
31
- if command == 'init'
32
- config = nil
33
- else
34
- config = Blazing::Config.parse(options[:file])
35
- end
4
+ require 'blazing/cli'
36
5
 
37
- runner = Blazing::Runner.new(config, target)
38
- runner.exec(command)
6
+ Blazing::CLI.start
data/blazing.gemspec CHANGED
@@ -25,12 +25,14 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency('rake','~> 0.9.2')
26
26
  s.add_development_dependency('rspec')
27
27
  s.add_development_dependency('guard')
28
- s.add_development_dependency('guard-rspec')
29
- s.add_development_dependency('growl')
28
+ s.add_development_dependency('guard-rspectacle')
29
+ s.add_development_dependency('ruby_gntp')
30
30
  s.add_development_dependency('rb-fsevent')
31
+ s.add_development_dependency('pry')
31
32
 
32
33
  s.add_dependency('grit')
33
34
  s.add_dependency('logging')
35
+ s.add_dependency('thor')
34
36
 
35
37
  # TODO: Get rid of those, just used for guessing recipe names etc in lib/recipes.rb
36
38
  s.add_dependency "activesupport"
data/lib/blazing.rb CHANGED
@@ -1,8 +1,16 @@
1
- require "blazing/version"
2
1
  require "blazing/logger"
3
2
 
4
3
  module Blazing
5
4
 
5
+ autoload :CLI, 'blazing/cli'
6
+ autoload :Config, 'blazing/config'
7
+ autoload :Version, 'blazing/version'
8
+ autoload :DSLSetter, 'blazing/dsl_setter'
9
+ autoload :Recipe, 'blazing/recipe'
10
+ autoload :Runner, 'blazing/runner'
11
+ autoload :Shell, 'blazing/shell'
12
+ autoload :Target, 'blazing/target'
13
+
6
14
  TEMPLATE_ROOT = File.expand_path(File.dirname(__FILE__) + File.join('/', 'blazing', 'templates'))
7
15
  DEFAULT_CONFIG_LOCATION = 'config/blazing.rb'
8
16
  TMP_HOOK = '/tmp/post-receive'
@@ -0,0 +1,65 @@
1
+ require 'thor'
2
+ require 'blazing/runner'
3
+
4
+ module Blazing
5
+ class CLI < Thor
6
+
7
+ default_task :help
8
+
9
+ desc 'init', 'Generate a blazing config file'
10
+
11
+ #
12
+ # Bootstrap blazing by creating a sample config file
13
+ #
14
+ def init
15
+ Blazing::Runner.init
16
+ end
17
+
18
+ desc 'setup [TARGET]', 'Setup local and remote repository/repositories for deployment'
19
+
20
+ method_option :file,
21
+ :type => :string,
22
+ :aliases => '-f',
23
+ :banner => 'Specify a configuration file'
24
+
25
+ #
26
+ # Setup a target to be deployed with blazing
27
+ #
28
+ def setup(target_name = nil)
29
+ Blazing::Runner.new(target_name, options).setup
30
+ end
31
+
32
+ desc 'update [TARGET]', 'Re-Generate and uplaod hook based on current configuration'
33
+
34
+ method_option :file,
35
+ :type => :string,
36
+ :aliases => '-f',
37
+ :banner => 'Specify a configuration file'
38
+
39
+ #
40
+ # Update the target hook so it matches the settings in the config
41
+ #
42
+ def update(target_name = nil)
43
+ Blazing::Runner.new(target_name, options).update
44
+ end
45
+
46
+ desc 'recipes', 'Run the recipes'
47
+
48
+ #
49
+ # Run the configured blazing recipes (used on remote machien)
50
+ #
51
+ def recipes(target_name)
52
+ Blazing::Runner.new(target_name, options).recipes
53
+ end
54
+
55
+ desc 'list', 'List available recipes'
56
+
57
+ #
58
+ # List the available blazing recipes
59
+ #
60
+ def list
61
+ Blazing::Runner.list
62
+ end
63
+
64
+ end
65
+ end
@@ -5,21 +5,20 @@ require 'blazing/dsl_setter'
5
5
  class Blazing::Config
6
6
 
7
7
  extend Blazing::DSLSetter
8
+ include Blazing::Logger
8
9
 
9
10
  attr_reader :file
10
11
  attr_accessor :targets, :recipes
11
- dsl_setter :repository, :rvm, :rvm_scripts, :rake
12
+ dsl_setter :rvm, :rvm_scripts
12
13
 
13
14
  class << self
14
-
15
15
  def parse(configuration_file = nil)
16
- Blazing::Recipe.load_recipes
16
+ Blazing::Recipe.load_recipes!
17
17
  config = self.new(configuration_file)
18
18
  config.instance_eval(File.read(config.file))
19
19
 
20
20
  config
21
21
  end
22
-
23
22
  end
24
23
 
25
24
  def initialize(configuration_file = nil)
@@ -37,12 +36,17 @@ class Blazing::Config
37
36
  @recipes << Blazing::Recipe.init_by_name(name, options)
38
37
  end
39
38
 
39
+ def rake(task_name, env = nil)
40
+ @rake = { :task => task_name }
41
+ @rake[:env] = env if env
42
+ end
43
+
44
+ def repository(*args)
45
+ warn 'Ther repository DSL method has been deprecated and is no longer used. This method will be removed in Version 0.3'
46
+ end
47
+
40
48
  def default_target
41
- if @targets.size > 1
42
- default = @targets.find { |t| t.options[:default] == true }
43
- raise 'could not find default target' unless default
44
- default
45
- else
49
+ if @targets.size == 1
46
50
  @targets.first
47
51
  end
48
52
  end