bard 0.23.0 → 0.23.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -1
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +52 -42
- data/LICENSE +1 -1
- data/README.rdoc +9 -117
- data/Rakefile +1 -1
- data/bard.gemspec +26 -21
- data/lib/bard.rb +35 -108
- data/lib/bard/base.rb +1 -1
- data/lib/bard/capistrano.rb +22 -6
- data/lib/bard/ci.rb +51 -0
- data/lib/bard/git.rb +5 -9
- data/lib/bard/version.rb +4 -0
- metadata +48 -19
- data/VERSION +0 -1
- data/lib/bard/error.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07d5c93a6df172df91066f90c0bc8832aeb68b80
|
4
|
+
data.tar.gz: fceecc7432bd7e7fed5e6f43efae4a44b02662cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 716ea0db922225e502aeacefff4e53d2d45e29d455ff62c2008be67d82420f5517d299da35e293216a38990eefb94d786451cd7408e4f33d463e3815a1f5170a
|
7
|
+
data.tar.gz: 66847050ea9676a3f92f541e49a4101aa7bd36f3c50098f92f11ada2f5ca97ceb67d00c40e271920fa499628cc2f53b25fed24fd5fd7ee1024241e652c0371a8
|
data/.gitignore
CHANGED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
bard
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.2
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,68 +1,78 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bard (0.
|
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://
|
13
|
+
remote: http://rubygems.org/
|
17
14
|
specs:
|
18
|
-
bard-rake (0.
|
19
|
-
|
20
|
-
builder (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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
net-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
rspec (
|
54
|
-
|
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
|
-
|
57
|
-
|
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
|
-
|
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
|
-
|
68
|
-
|
76
|
+
byebug
|
77
|
+
cucumber
|
78
|
+
rspec
|
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,124 +1,16 @@
|
|
1
|
-
= BARD
|
1
|
+
= BARD
|
2
2
|
|
3
|
-
This is a collection of tools designed to ease collaboration within
|
4
|
-
It wraps git, capistrano,
|
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
|
-
|
10
|
-
|
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)
|
15
|
+
Copyright (c) 2014 Micah Geisel. See LICENSE for details.
|
16
|
+
|
data/Rakefile
CHANGED
data/bard.gemspec
CHANGED
@@ -1,26 +1,31 @@
|
|
1
|
-
#
|
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 |
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
25
|
-
|
28
|
+
spec.add_development_dependency "byebug"
|
29
|
+
spec.add_development_dependency "rspec"
|
30
|
+
spec.add_development_dependency "cucumber"
|
26
31
|
end
|
data/lib/bard.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
32
|
-
run_crucial "bundle && bundle exec rake bootstrap", options.verbose?
|
33
|
-
end
|
19
|
+
branch = Git.current_branch
|
34
20
|
|
35
|
-
|
36
|
-
|
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
|
-
|
28
|
+
branch = Git.current_branch
|
45
29
|
|
46
|
-
run_crucial "
|
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
|
-
|
65
|
-
|
66
|
-
|
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
|
54
|
+
invoke :ci
|
72
55
|
|
73
|
-
run_crucial "git
|
74
|
-
run_crucial "git
|
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
|
-
|
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
|
97
|
-
|
98
|
-
|
99
|
-
puts "Continuous integration: starting build on #{
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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
|
-
|
145
|
-
|
146
|
-
|
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
|
-
|
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
|
|
data/lib/bard/base.rb
CHANGED
data/lib/bard/capistrano.rb
CHANGED
@@ -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
|
64
|
-
|
65
|
-
|
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
|
70
|
-
|
71
|
-
|
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
|
data/lib/bard/ci.rb
ADDED
@@ -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
|
+
|
data/lib/bard/git.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Bard::CLI::Git
|
2
|
-
|
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 =
|
16
|
-
branch_head =
|
17
|
-
|
18
|
-
|
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
|
|
data/lib/bard/version.rb
ADDED
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.
|
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-
|
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:
|
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:
|
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
|
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
|
126
|
-
description:
|
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/
|
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:
|
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:
|
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
|
data/lib/bard/error.rb
DELETED
@@ -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
|