bard 0.23.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc1c6c9dceac8bcf010f8f0fbcbdf9b6678d21f1
4
- data.tar.gz: 2d4b58d4760e2c1c22fc4a1d74cb0c24bacbd567
3
+ metadata.gz: 07d5c93a6df172df91066f90c0bc8832aeb68b80
4
+ data.tar.gz: fceecc7432bd7e7fed5e6f43efae4a44b02662cf
5
5
  SHA512:
6
- metadata.gz: c5437ee43af1d313b7712c4e86def8311dd67bae1a90082d6170645030a62d7f6a133f55da4d321f01360c86fd04601aa61c49198b40ff5e38d64f3a40a429c0
7
- data.tar.gz: edb8cdb7ce7b8d60eff67b6f4d5fe57a0d1e80e78da93ef8f8bcaa91df4aadc5c043af243097f3ffee3009300d8204891b1a39c86fd9fc1ab4f79b36abee7bdb
6
+ metadata.gz: 716ea0db922225e502aeacefff4e53d2d45e29d455ff62c2008be67d82420f5517d299da35e293216a38990eefb94d786451cd7408e4f33d463e3815a1f5170a
7
+ data.tar.gz: 66847050ea9676a3f92f541e49a4101aa7bd36f3c50098f92f11ada2f5ca97ceb67d00c40e271920fa499628cc2f53b25fed24fd5fd7ee1024241e652c0371a8
data/.gitignore CHANGED
@@ -1,8 +1,12 @@
1
1
  *.sw?
2
+ *.gem
2
3
  .DS_Store
4
+ .bundle
3
5
  coverage
4
6
  rdoc
5
- pkg
6
7
  tmp
7
8
  .bundle
8
9
  .rvmrc
10
+ Gemfile.lock
11
+ pkg/*
12
+
@@ -0,0 +1 @@
1
+ bard
@@ -0,0 +1 @@
1
+ ruby-2.1.2
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
- source "http://gemcutter.org"
1
+ source "http://rubygems.org"
2
2
 
3
+ # Specify your gem's dependencies in bard.gemspec
3
4
  gemspec
5
+
@@ -1,68 +1,78 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bard (0.15.4)
4
+ bard (0.23.0)
5
5
  bard-rake (>= 0.1.1)
6
6
  capistrano (= 2.5.10)
7
- git_remote_branch (>= 0.3.0)
8
- grit (= 1.1.1)
9
7
  rvm-capistrano
10
8
  systemu (>= 1.2.0)
11
9
  term-ansicolor (>= 1.0.3)
12
10
  thor (= 0.11.7)
13
- versionomy (>= 0.3.0)
14
11
 
15
12
  GEM
16
- remote: http://gemcutter.org/
13
+ remote: http://rubygems.org/
17
14
  specs:
18
- bard-rake (0.4.3)
19
- blockenspiel (0.4.3)
20
- builder (2.1.2)
15
+ bard-rake (0.12.0)
16
+ rake
17
+ builder (3.2.2)
18
+ byebug (3.5.1)
19
+ columnize (~> 0.8)
20
+ debugger-linecache (~> 1.2)
21
+ slop (~> 3.6)
21
22
  capistrano (2.5.10)
22
23
  highline
23
24
  net-scp (>= 1.0.0)
24
25
  net-sftp (>= 2.0.0)
25
26
  net-ssh (>= 2.0.14)
26
27
  net-ssh-gateway (>= 1.0.0)
27
- cucumber (0.9.4)
28
- builder (~> 2.1.2)
29
- diff-lcs (~> 1.1.2)
30
- gherkin (~> 2.2.9)
31
- json (~> 1.4.6)
32
- term-ansicolor (~> 1.0.5)
33
- diff-lcs (1.1.2)
34
- gherkin (2.2.9)
35
- json (~> 1.4.6)
36
- term-ansicolor (~> 1.0.5)
37
- git_remote_branch (0.3.3)
38
- rainbow
39
- grit (1.1.1)
40
- diff-lcs (>= 1.1.2)
41
- mime-types (>= 1.15)
42
- highline (1.6.11)
43
- json (1.4.6)
44
- mime-types (1.18)
45
- net-scp (1.0.4)
46
- net-ssh (>= 1.99.1)
47
- net-sftp (2.0.5)
48
- net-ssh (>= 2.0.9)
49
- net-ssh (2.3.0)
50
- net-ssh-gateway (1.1.0)
51
- net-ssh (>= 1.99.1)
52
- rainbow (1.1.3)
53
- rspec (1.3.1)
54
- rvm-capistrano (1.0.2)
28
+ columnize (0.8.9)
29
+ cucumber (1.3.17)
30
+ builder (>= 2.1.2)
31
+ diff-lcs (>= 1.1.3)
32
+ gherkin (~> 2.12)
33
+ multi_json (>= 1.7.5, < 2.0)
34
+ multi_test (>= 0.1.1)
35
+ debugger-linecache (1.2.0)
36
+ diff-lcs (1.2.5)
37
+ gherkin (2.12.2)
38
+ multi_json (~> 1.3)
39
+ highline (1.6.21)
40
+ multi_json (1.10.1)
41
+ multi_test (0.1.1)
42
+ net-scp (1.2.1)
43
+ net-ssh (>= 2.6.5)
44
+ net-sftp (2.1.2)
45
+ net-ssh (>= 2.6.5)
46
+ net-ssh (2.9.1)
47
+ net-ssh-gateway (1.2.0)
48
+ net-ssh (>= 2.6.5)
49
+ rake (10.4.0)
50
+ rspec (3.1.0)
51
+ rspec-core (~> 3.1.0)
52
+ rspec-expectations (~> 3.1.0)
53
+ rspec-mocks (~> 3.1.0)
54
+ rspec-core (3.1.7)
55
+ rspec-support (~> 3.1.0)
56
+ rspec-expectations (3.1.2)
57
+ diff-lcs (>= 1.2.0, < 2.0)
58
+ rspec-support (~> 3.1.0)
59
+ rspec-mocks (3.1.3)
60
+ rspec-support (~> 3.1.0)
61
+ rspec-support (3.1.2)
62
+ rvm-capistrano (1.4.1)
55
63
  capistrano (>= 2.0.0)
56
- systemu (2.5.0)
57
- term-ansicolor (1.0.5)
64
+ slop (3.6.0)
65
+ systemu (2.6.4)
66
+ term-ansicolor (1.3.0)
67
+ tins (~> 1.0)
58
68
  thor (0.11.7)
59
- versionomy (0.4.3)
60
- blockenspiel (>= 0.4.3)
69
+ tins (1.3.3)
61
70
 
62
71
  PLATFORMS
63
72
  ruby
64
73
 
65
74
  DEPENDENCIES
66
75
  bard!
67
- cucumber (~> 0.9.0)
68
- rspec (~> 1.3.0)
76
+ byebug
77
+ cucumber
78
+ rspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Micah Geisel
1
+ Copyright (c) 2014 Micah Geisel
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,124 +1,16 @@
1
- = BARD gem
1
+ = BARD
2
2
 
3
- This is a collection of tools designed to ease collaboration within BOTandROSE design.
4
- It wraps git, capistrano, thor, and rake to make things as simple as:
3
+ This is a collection of tools designed to ease collaboration within Bot and Rose Design.
4
+ It wraps git, capistrano, and rake to make things as simple as:
5
5
 
6
- bard push
7
6
  bard pull
7
+ bard stage
8
+ bard deploy
8
9
 
9
- === Requirements
10
- git --version >= 1.6.4
11
- rubygems --version >= 1.3.4
12
- ruby --version == 1.8.7
13
-
14
- === Joining Bard
15
-
16
- ==== On any platform:
17
- - gem install bard
18
-
19
- ==== On Linux:
20
-
21
- - Install RubyGems:
22
- $> wget ...
23
- $> ...
24
-
25
- - Install Rake:
26
- $> sudo gem install rake
27
- ( NOTE: the sudo )
28
-
29
- - Install Apache
30
- $> sudo apt-get install apache2
31
-
32
- - Install Mysql
33
- $> sudo apt-get install mysql-server
34
- $> sudo /etc/init.d/mysql start
35
- ( No password for root, if it asks )
36
-
37
- - Install Passenger
38
- $> sudo gem install passenger
39
-
40
- $> sudo apt-get install apache2-prefork-dev as root.
41
- $> sudo apt-get install libapr1-dev as root.
42
- $> sudo apt-get install libaprutil1
43
-
44
- $> sudo passenger-install-apache2-module
45
-
46
- - Setup rails environment:
47
- Add line to /etc/apache2/apache2.conf:
48
- RailsEnv development
49
- $> apache2ctl restart
50
-
51
- ==== On Mac:
52
- - ???Wtf ? I dunno. eff macs
53
-
54
- == Todos
55
-
56
- === Joining an existing project
57
- bard join will probably either do all these steps automatically, or help you do them:
58
- This list summarizes the existing steps needed to join a project.
59
-
60
- $> bard join <project-name>
61
-
62
- - Clone the project
63
- - (git clone git@git.botandrose.com:<project-name>.git)
64
- - Init and update submodules
65
-
66
- - Set up local environment:
67
- - Apache
68
- Put in /etc/apache2/sites-avaliable/<project-name>:
69
- <VirtualHost *:80>
70
- ServerName <project-name>.local
71
- DocumentRoot $HOME/$BardRoot/<project-name>/public
72
- </VirtualHost>
73
-
74
- $> a2ensite <project-name>
75
- $> apache2ctl restart
76
-
77
- - Set up /etc/hosts:
78
- append this line to /etc/hosts:
79
- 127.0.0.1 <project-name>.local
80
-
81
- - Setup database yaml
82
- - sensible default:
83
- login: &login
84
- adapter: mysql
85
- database: <project-name>
86
- username: root
87
- password:
88
- socket: /var/run/mysqld/mysqld.sock
89
-
90
- development:
91
- <<: *login
92
-
93
- test: &TEST
94
- <<: *login
95
- database: <project-name>_test
96
-
97
- cucumber:
98
- <<: *TEST
99
-
100
-
101
- - Set up gems:
102
- $> rake gems:install
103
-
104
- - Set up database
105
- $> rake db:create
106
- $> rake db:migrate
107
-
108
- - Seed database from staging or production
109
- $> bard data
110
-
111
- === Note on Patches/Pull Requests
112
-
113
- * Fork the project.
114
- * Make your feature addition or bug fix.
115
- * Add tests for it. This is important so I don't break it in a
116
- future version unintentionally.
117
- * Commit, do not mess with rakefile, version, or history.
118
- (if you want to have your own version, that is fine but
119
- bump version in a commit by itself I can ignore when I pull)
120
- * Send me a pull request. Bonus points for topic branches.
10
+ Seed database from staging or production:
11
+ bard data
121
12
 
122
13
  == Copyright
123
14
 
124
- Copyright (c) 2009 Micah Geisel, Nick Hogle. See LICENSE for details.
15
+ Copyright (c) 2014 Micah Geisel. See LICENSE for details.
16
+
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env rake
2
1
  require "bundler/gem_tasks"
2
+
@@ -1,26 +1,31 @@
1
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "bard/version"
2
5
 
3
- Gem::Specification.new do |gem|
4
- gem.authors = ["Micah Geisel", "Nick Hogle"]
5
- gem.email = ["micah@botandrose.com"]
6
- gem.description = %q{This immaculate work of engineering genius allows mere mortals to collaborate with beings of transcendent intelligence like Micah, Michael, and Nick.}
7
- gem.summary = %q{Tools for collaborating with Bot and Rose Design.}
8
- gem.homepage = "https://github.com/botandrose/bard"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bard"
8
+ spec.version = Bard::VERSION
9
+ spec.authors = ["Micah Geisel"]
10
+ spec.email = ["micah@botandrose.com"]
11
+ spec.summary = %Q{CLI to automate common development tasks.}
12
+ spec.description = %Q{CLI to automate common development tasks.}
13
+ spec.homepage = "http://github.com/botandrose/bard"
14
+ spec.license = "MIT"
9
15
 
10
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
11
- gem.files = `git ls-files`.split("\n")
12
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
- gem.name = "bard"
14
- gem.require_paths = ["lib"]
15
- gem.version = File.read("VERSION").chomp
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
16
20
 
17
- gem.add_dependency "thor", "0.11.7"
18
- gem.add_dependency "capistrano", "2.5.10"
19
- gem.add_dependency "rvm-capistrano"
20
- gem.add_dependency "systemu", ">=1.2.0"
21
- gem.add_dependency "term-ansicolor", ">=1.0.3"
22
- gem.add_dependency "bard-rake", ">=0.1.1"
21
+ spec.add_dependency "thor", "= 0.11.7"
22
+ spec.add_dependency "capistrano", "= 2.5.10"
23
+ spec.add_dependency "rvm-capistrano"
24
+ spec.add_dependency "systemu", ">= 1.2.0"
25
+ spec.add_dependency "term-ansicolor", ">= 1.0.3"
26
+ spec.add_dependency "bard-rake", ">= 0.1.1"
23
27
 
24
- gem.add_development_dependency "rspec", "~>1.3.0"
25
- gem.add_development_dependency "cucumber", "~>0.9.0"
28
+ spec.add_development_dependency "byebug"
29
+ spec.add_development_dependency "rspec"
30
+ spec.add_development_dependency "cucumber"
26
31
  end
@@ -3,47 +3,32 @@ $:.unshift File.expand_path(File.dirname(__FILE__))
3
3
  module Bard; end
4
4
 
5
5
  require "bard/base"
6
- require "bard/error"
7
6
  require "bard/git"
7
+ require "bard/ci"
8
8
 
9
9
  class Bard::CLI < Thor
10
- include Bard::CLI::Git
11
-
12
10
  desc "data [FROM=production, TO=local]", "copy database and assets from FROM to TO"
13
11
  def data(from = "production", to = "local")
14
- if to == "local"
15
- if from == "production" and heroku?
16
- exec "heroku db:pull --confirm #{project_name}"
17
- else
18
- exec "cap _2.5.10_ data:pull ROLES=#{from}"
19
- end
20
-
21
- else
22
- if from == "local"
23
- exec "cap _2.5.10_ data:push ROLES=#{to}"
24
- end
25
- end
12
+ exec "cap _2.5.10_ data:pull ROLES=#{from}" if to == "local"
13
+ exec "cap _2.5.10_ data:push ROLES=#{to}" if from == "local"
26
14
  end
27
15
 
28
16
  method_options %w( verbose -v ) => :boolean
29
17
  desc "pull", "pull changes to your local machine"
30
18
  def pull
31
- run_crucial "git pull --rebase origin #{current_branch}", options.verbose?
32
- run_crucial "bundle && bundle exec rake bootstrap", options.verbose?
33
- end
19
+ branch = Git.current_branch
34
20
 
35
- method_options %w( verbose -v ) => :boolean
36
- desc "push", "push local changes out to the remote"
37
- def push
38
- run_crucial "git push -u origin #{current_branch}", true
21
+ run_crucial "git pull --rebase origin #{branch}", options.verbose?
22
+ run_crucial "bundle && bundle exec rake bootstrap", options.verbose?
39
23
  end
40
24
 
41
25
  method_options %w( verbose -v ) => :boolean
42
26
  desc "stage", "pushes current branch, and stages it"
43
27
  def stage
44
- invoke :push
28
+ branch = Git.current_branch
45
29
 
46
- run_crucial "cap _2.5.10_ stage BRANCH=#{current_branch}", options.verbose?
30
+ run_crucial "git push -u origin #{branch}", true
31
+ run_crucial "cap _2.5.10_ stage BRANCH=#{branch}", options.verbose?
47
32
 
48
33
  puts green("Stage Succeeded")
49
34
  end
@@ -51,41 +36,34 @@ class Bard::CLI < Thor
51
36
  method_options %w( verbose -v ) => :boolean
52
37
  desc "deploy", "checks that branch is a ff with master, checks with ci, and then merges into master and deploys to production, and deletes branch."
53
38
  def deploy
54
- branch = current_branch
39
+ branch = Git.current_branch
55
40
 
56
- run_crucial "git fetch origin"
57
- raise MasterNonFastForwardError if not fast_forward_merge? "origin/master", "master"
41
+ run_crucial "git fetch origin master:master"
58
42
 
59
43
  if branch == "master"
60
- run_crucial "git push origin master"
44
+ run_crucial "git push origin master:master"
61
45
  invoke :ci
62
46
 
63
47
  else
64
- run_crucial "git checkout master"
65
- run_crucial "git merge origin/master"
66
- run_crucial "git checkout #{branch}"
67
- raise MasterNonFastForwardError if not fast_forward_merge? "master", branch
48
+ if not Git.fast_forward_merge? "master", branch
49
+ raise "The master branch has advanced since last deploy, probably due to a bugfix.\n Rebase your branch on top of it, and check for breakage."
50
+ end
68
51
 
69
- run_crucial "git push -f origin #{branch}"
52
+ run_crucial "git push -f origin #{branch}:#{branch}"
70
53
 
71
- invoke :ci, current_sha
54
+ invoke :ci
72
55
 
73
- run_crucial "git checkout master"
74
- run_crucial "git merge #{branch}"
75
- run_crucial "git push origin master"
56
+ run_crucial "git push origin #{branch}:master"
57
+ run_crucial "git fetch origin master:master"
76
58
  end
77
59
 
78
- if heroku?
79
- run_crucial "git push production master", options.verbose?
80
- run_crucial "heroku run rake bootstrap:production:post", options.verbose?
81
- else
82
- run_crucial "cap _2.5.10_ deploy", options.verbose?
83
- end
60
+ run_crucial "cap _2.5.10_ deploy", options.verbose?
84
61
 
85
62
  puts green("Deploy Succeeded")
86
63
 
87
64
  if branch != "master"
88
65
  puts "Deleting branch: #{branch}"
66
+ run_crucial "git checkout master" if current_branch == branch
89
67
  run_crucial "git push --delete origin #{branch}"
90
68
  run_crucial "git branch -d #{branch}"
91
69
  end
@@ -93,20 +71,14 @@ class Bard::CLI < Thor
93
71
 
94
72
  method_options %w( verbose -v ) => :boolean
95
73
  desc "ci", "runs ci against current HEAD"
96
- def ci sha=current_sha
97
- return unless has_ci?
98
-
99
- puts "Continuous integration: starting build on #{sha}..."
100
- last_build_number = get_last_build_number
101
- last_time_elapsed = get_last_time_elapsed
102
- start_ci sha
103
- sleep(2) while last_build_number == get_last_build_number
104
-
105
- start_time = Time.new.to_i
106
- while (response = `curl -s #{ci_host}/lastBuild/api/xml?token=botandrose`).include? "<building>true</building>"
107
- elapsed_time = Time.new.to_i - start_time
108
- if last_time_elapsed
109
- percentage = (elapsed_time.to_f / last_time_elapsed.to_f * 100).to_i
74
+ def ci
75
+ ci = CI.new(project_name, Git.current_sha)
76
+ return unless ci.exists?
77
+ puts "Continuous integration: starting build on #{Git.current_branch}..."
78
+
79
+ success = ci.run do |elapsed_time, last_time|
80
+ if last_time
81
+ percentage = (elapsed_time.to_f / last_time.to_f * 100).to_i
110
82
  output = " Estimated completion: #{percentage}%"
111
83
  else
112
84
  output = " No estimated completion time. Elapsed time: #{elapsed_time} sec"
@@ -114,61 +86,16 @@ class Bard::CLI < Thor
114
86
  print "\x08" * output.length
115
87
  print output
116
88
  $stdout.flush
117
- sleep(2)
118
- end
119
- puts
120
-
121
- case response
122
- when /<result>FAILURE<\/result>/ then
123
- puts
124
- puts `curl -s #{ci_host}/lastBuild/console?token=botandrose`.match(/<pre>(.+)<\/pre>/m)[1]
125
- puts
126
- raise TestsFailedError, "#{ci_host}/#{get_last_build_number}/console"
127
-
128
- when /<result>ABORTED<\/result>/ then
129
- raise TestsAbortedError, "#{ci_host}/#{get_last_build_number}/console"
130
-
131
- when /<result>SUCCESS<\/result>/ then
132
- puts "Continuous integration: success! deploying to production"
133
-
134
- else raise "Unknown response from CI server: #{response}"
135
89
  end
136
- end
137
-
138
- private
139
-
140
- def heroku?
141
- `git remote -v`.include? "production\tgit@heroku.com:"
142
- end
143
90
 
144
- def ci_host
145
- "http://botandrose:thecakeisalie!@ci.botandrose.com/job/#{project_name}"
146
- end
147
-
148
- def has_ci?
149
- `curl -s -I #{ci_host}/?token=botandrose` =~ /\b200 OK\b/
150
- end
151
-
152
- def start_ci sha=nil
153
- if sha
154
- command = "curl -s -I -X POST '#{ci_host}/buildWithParameters?token=botandrose&GIT_REF=#{sha}'"
91
+ if success
92
+ puts
93
+ puts "Continuous integration: success! deploying to production"
155
94
  else
156
- command = "curl -s -I -X POST '#{ci_host}/build?token=botandrose'"
95
+ puts
96
+ puts ci.console
97
+ puts "Automated tests failed!"
157
98
  end
158
- puts command if options.verbose?
159
- `#{command}`
160
- end
161
-
162
- def get_last_build_number
163
- response = `curl -s #{ci_host}/lastBuild/api/xml?token=botandrose`
164
- response.match(/<number>(\d+)<\/number>/)
165
- $1 ? $1.to_i : nil
166
- end
167
-
168
- def get_last_time_elapsed
169
- response = `curl -s #{ci_host}/lastStableBuild/api/xml?token=botandrose`
170
- response.match(/<duration>(\d+)<\/duration>/)
171
- $1 ? $1.to_i / 1000 : nil
172
99
  end
173
100
  end
174
101
 
@@ -8,7 +8,7 @@ class Bard::CLI < Thor
8
8
  private
9
9
 
10
10
  def fatal(message)
11
- raise Bard::CLI::Error, red("!!! ") + message
11
+ raise red("!!! ") + message
12
12
  end
13
13
 
14
14
  def run_crucial(command, verbose = false)
@@ -16,6 +16,8 @@ Capistrano::Configuration.instance(:must_exist).load do
16
16
  namespace "pull" do
17
17
  desc "pull data"
18
18
  task "default" do
19
+ exec "heroku db:pull --confirm #{project_name}" if heroku?
20
+
19
21
  run "cd #{application} && bundle exec rake db:dump && gzip -9f db/data.sql"
20
22
  transfer :down, "#{application}/db/data.sql.gz", "db/data.sql.gz"
21
23
  system "gunzip -f db/data.sql.gz && bundle exec rake db:load"
@@ -60,14 +62,28 @@ Capistrano::Configuration.instance(:must_exist).load do
60
62
  after 'data:push', 'data:push:assets'
61
63
 
62
64
  desc "push app to production"
63
- task :deploy, :roles => :production do
64
- system "git push github" if `git remote` =~ /\bgithub\b/
65
- run "cd #{application} && git pull origin master && bundle && bundle exec rake bootstrap:production"
65
+ task :deploy do
66
+ if heroku? "production"
67
+ system "git push production master"
68
+ system "heroku run rake bootstrap:production:post"
69
+ else
70
+ system "git push github" if `git remote` =~ /\bgithub\b/
71
+ run "cd #{application} && git pull origin master && bundle && bundle exec rake bootstrap:production", :roles => :production
72
+ end
66
73
  end
67
74
 
68
75
  desc "push app to staging"
69
- task :stage, :roles => :staging do
70
- branch = ENV.fetch("BRANCH")
71
- run "cd #{application} && git fetch && git checkout -f origin/#{branch} && bundle && bundle exec rake bootstrap:production"
76
+ task :stage do
77
+ if heroku? "staging"
78
+ system "git push -f staging master"
79
+ system "heroku run rake bootstrap:production:post"
80
+ else
81
+ branch = ENV.fetch("BRANCH")
82
+ run "cd #{application} && git fetch && git checkout -f origin/#{branch} && bundle && bundle exec rake bootstrap:production", :roles => :staging
83
+ end
84
+ end
85
+
86
+ def heroku? role
87
+ `git remote -v`.include? "#{role}\tgit@heroku.com:"
72
88
  end
73
89
  end
@@ -0,0 +1,51 @@
1
+ class Bard::CLI < Thor
2
+ class CI < Struct.new(:project_name, :current_sha)
3
+ def run
4
+ last_build_number = get_last_build_number
5
+ last_time_elapsed = get_last_time_elapsed
6
+ start
7
+ sleep(2) while last_build_number == get_last_build_number
8
+
9
+ start_time = Time.new.to_i
10
+ while (response = `curl -s #{ci_host}/lastBuild/api/xml?token=botandrose`).include? "<building>true</building>"
11
+ elapsed_time = Time.new.to_i - start_time
12
+ yield elapsed_time, last_time_elapsed
13
+ sleep(2)
14
+ end
15
+
16
+ response =~ /<result>SUCCESS<\/result>/
17
+ end
18
+
19
+ def exists?
20
+ `curl -s -I #{ci_host}/?token=botandrose` =~ /\b200 OK\b/
21
+ end
22
+
23
+ def console
24
+ raw = `curl -s #{ci_host}/lastBuild/console?token=botandrose`
25
+ raw[/<pre>(.+)<\/pre>/m, 1]
26
+ end
27
+
28
+ private
29
+
30
+ def ci_host
31
+ "http://botandrose:thecakeisalie!@ci.botandrose.com/job/#{project_name}"
32
+ end
33
+
34
+ def start
35
+ `curl -s -I -X POST '#{ci_host}/buildWithParameters?token=botandrose&GIT_REF=#{current_sha}'`
36
+ end
37
+
38
+ def get_last_build_number
39
+ response = `curl -s #{ci_host}/lastBuild/api/xml?token=botandrose`
40
+ response.match(/<number>(\d+)<\/number>/)
41
+ $1 ? $1.to_i : nil
42
+ end
43
+
44
+ def get_last_time_elapsed
45
+ response = `curl -s #{ci_host}/lastStableBuild/api/xml?token=botandrose`
46
+ response.match(/<duration>(\d+)<\/duration>/)
47
+ $1 ? $1.to_i / 1000 : nil
48
+ end
49
+ end
50
+ end
51
+
@@ -1,5 +1,5 @@
1
1
  module Bard::CLI::Git
2
- private
2
+ module_function
3
3
 
4
4
  def current_branch
5
5
  ref = `git symbolic-ref HEAD 2>&1`.chomp
@@ -12,14 +12,10 @@ module Bard::CLI::Git
12
12
  end
13
13
 
14
14
  def fast_forward_merge?(root, branch)
15
- root_head = run_crucial "git rev-parse #{root}"
16
- branch_head = run_crucial "git rev-parse #{branch}"
17
- @common_ancestor = find_common_ancestor root_head, branch_head
18
- @common_ancestor == root_head
19
- end
20
-
21
- def find_common_ancestor(head1, head2)
22
- run_crucial "git merge-base #{head1} #{head2}"
15
+ root_head = `git rev-parse #{root}`.chomp
16
+ branch_head = `git rev-parse #{branch}`.chomp
17
+ common_ancestor = `git merge-base #{root_head} #{branch_head}`.chomp
18
+ common_ancestor == root_head
23
19
  end
24
20
  end
25
21
 
@@ -0,0 +1,4 @@
1
+ module Bard
2
+ VERSION = "0.23.1"
3
+ end
4
+
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.23.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
- - Nick Hogle
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-11-29 00:00:00.000000000 Z
11
+ date: 2014-11-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thor
@@ -95,36 +94,49 @@ dependencies:
95
94
  - - ">="
96
95
  - !ruby/object:Gem::Version
97
96
  version: 0.1.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: byebug
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
98
111
  - !ruby/object:Gem::Dependency
99
112
  name: rspec
100
113
  requirement: !ruby/object:Gem::Requirement
101
114
  requirements:
102
- - - "~>"
115
+ - - ">="
103
116
  - !ruby/object:Gem::Version
104
- version: 1.3.0
117
+ version: '0'
105
118
  type: :development
106
119
  prerelease: false
107
120
  version_requirements: !ruby/object:Gem::Requirement
108
121
  requirements:
109
- - - "~>"
122
+ - - ">="
110
123
  - !ruby/object:Gem::Version
111
- version: 1.3.0
124
+ version: '0'
112
125
  - !ruby/object:Gem::Dependency
113
126
  name: cucumber
114
127
  requirement: !ruby/object:Gem::Requirement
115
128
  requirements:
116
- - - "~>"
129
+ - - ">="
117
130
  - !ruby/object:Gem::Version
118
- version: 0.9.0
131
+ version: '0'
119
132
  type: :development
120
133
  prerelease: false
121
134
  version_requirements: !ruby/object:Gem::Requirement
122
135
  requirements:
123
- - - "~>"
136
+ - - ">="
124
137
  - !ruby/object:Gem::Version
125
- version: 0.9.0
126
- description: This immaculate work of engineering genius allows mere mortals to collaborate
127
- with beings of transcendent intelligence like Micah, Michael, and Nick.
138
+ version: '0'
139
+ description: CLI to automate common development tasks.
128
140
  email:
129
141
  - micah@botandrose.com
130
142
  executables:
@@ -135,12 +147,13 @@ files:
135
147
  - ".document"
136
148
  - ".gitignore"
137
149
  - ".gitmodules"
150
+ - ".ruby-gemset"
151
+ - ".ruby-version"
138
152
  - Gemfile
139
153
  - Gemfile.lock
140
154
  - LICENSE
141
155
  - README.rdoc
142
156
  - Rakefile
143
- - VERSION
144
157
  - bard.gemspec
145
158
  - bin/bard
146
159
  - features/bard_check.feature
@@ -158,12 +171,14 @@ files:
158
171
  - lib/bard.rb
159
172
  - lib/bard/base.rb
160
173
  - lib/bard/capistrano.rb
161
- - lib/bard/error.rb
174
+ - lib/bard/ci.rb
162
175
  - lib/bard/git.rb
176
+ - lib/bard/version.rb
163
177
  - spec/bard_spec.rb
164
178
  - spec/spec_helper.rb
165
- homepage: https://github.com/botandrose/bard
166
- licenses: []
179
+ homepage: http://github.com/botandrose/bard
180
+ licenses:
181
+ - MIT
167
182
  metadata: {}
168
183
  post_install_message:
169
184
  rdoc_options: []
@@ -184,5 +199,19 @@ rubyforge_project:
184
199
  rubygems_version: 2.2.2
185
200
  signing_key:
186
201
  specification_version: 4
187
- summary: Tools for collaborating with Bot and Rose Design.
188
- test_files: []
202
+ summary: CLI to automate common development tasks.
203
+ test_files:
204
+ - features/bard_check.feature
205
+ - features/bard_deploy.feature
206
+ - features/bard_pull.feature
207
+ - features/bard_push.feature
208
+ - features/step_definitions/check_steps.rb
209
+ - features/step_definitions/git_steps.rb
210
+ - features/step_definitions/global_steps.rb
211
+ - features/step_definitions/rails_steps.rb
212
+ - features/step_definitions/submodule_steps.rb
213
+ - features/support/env.rb
214
+ - features/support/grit_ext.rb
215
+ - features/support/io.rb
216
+ - spec/bard_spec.rb
217
+ - spec/spec_helper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.23.0
@@ -1,25 +0,0 @@
1
- class Bard::CLI < Thor
2
- class NonFastForwardError < Bard::CLI::Error
3
- def message
4
- "Someone has pushed some changes since you last pulled.\n Kindly run bard pull, ensure that your your changes still work, and try again"
5
- end
6
- end
7
-
8
- class MasterNonFastForwardError < Bard::CLI::Error
9
- def message
10
- "The master branch has advanced since last deploy, probably due to a bugfix.\n Rebase your branch on top of it, and check for breakage."
11
- end
12
- end
13
-
14
- class TestsFailedError < Bard::CLI::Error
15
- def message
16
- "Automated tests failed!\n See #{super} for more info."
17
- end
18
- end
19
-
20
- class TestsAbortedError < Bard::CLI::Error
21
- def message
22
- "Automated tests aborted!\n See #{super} for more info."
23
- end
24
- end
25
- end