bard 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bard.gemspec +2 -1
- data/lib/bard/capistrano.rb +105 -0
- metadata +2 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.8
|
data/bard.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bard}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Micah Geisel", "Nick Hogle"]
|
@@ -41,6 +41,7 @@ Gem::Specification.new do |s|
|
|
41
41
|
"features/support/grit_ext.rb",
|
42
42
|
"features/support/io.rb",
|
43
43
|
"lib/bard.rb",
|
44
|
+
"lib/bard/capistrano.rb",
|
44
45
|
"lib/bard/check.rb",
|
45
46
|
"lib/bard/error.rb",
|
46
47
|
"lib/bard/git.rb",
|
@@ -0,0 +1,105 @@
|
|
1
|
+
role :staging, "staging@staging.botandrose.com"
|
2
|
+
|
3
|
+
namespace "data" do
|
4
|
+
namespace "pull" do
|
5
|
+
desc "pull data from production"
|
6
|
+
task :default, :roles => :production do
|
7
|
+
data_pull :production
|
8
|
+
end
|
9
|
+
task :staging, :roles => :staging do
|
10
|
+
data_pull :staging
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "pull data from production"
|
14
|
+
task :yml, :roles => :production do
|
15
|
+
run "cd #{application} && rake db:data:dump && gzip -9f db/data.yml"
|
16
|
+
transfer :down, "#{application}/db/data.yml.gz", "db/data.yml.gz"
|
17
|
+
system "gunzip -f db/data.yml.gz"
|
18
|
+
system "rake db:data:load"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def data_pull(env)
|
24
|
+
config = YAML::load(File.open("config/database.yml"))
|
25
|
+
source = config[env.to_s]
|
26
|
+
target = config["development"]
|
27
|
+
run "cd #{application} && mysqldump -u#{source["username"]} #{"-p#{source["password"]}" if source["password"]} '#{source["database"]}' > db/data.sql && gzip -9f db/data.sql"
|
28
|
+
transfer :down, "#{application}/db/data.sql.gz", "db/data.sql.gz"
|
29
|
+
run "cd #{application} && rm db/data.sql.gz"
|
30
|
+
system "gunzip -f db/data.sql.gz"
|
31
|
+
system "echo 'DROP DATABASE `#{target["database"]}`; CREATE DATABASE `#{target["database"]}`;' | mysql -u#{target["username"]}"
|
32
|
+
system "mysql -u#{target["username"]} '#{target["database"]}' < db/data.sql"
|
33
|
+
# system "rm db/data.sql"
|
34
|
+
end
|
35
|
+
|
36
|
+
namespace "deploy" do
|
37
|
+
desc "push app from staging to production"
|
38
|
+
task :default, :roles => :production do
|
39
|
+
begin
|
40
|
+
|
41
|
+
if `curl -s -I http://integrity.botandrose.com/#{application}` !~ /\b404\b/
|
42
|
+
puts "Integrity: verifying build..."
|
43
|
+
system "curl -sX POST http://integrity.botandrose.com/#{application}/builds"
|
44
|
+
while true
|
45
|
+
response = `curl -s http://integrity.botandrose.com/#{application}`
|
46
|
+
break unless response =~ /div class='(building|pending)' id='last_build'/
|
47
|
+
sleep(1)
|
48
|
+
end
|
49
|
+
case response
|
50
|
+
when /div class='failed' id='last_build'/ then raise TestsFailedError
|
51
|
+
when /div class='success' id='last_build'/ then success "Integrity: success! deploying to production"
|
52
|
+
else raise "Unknown response from CI server:\n#{response}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
system "git push" if `git remote show origin` =~ /github\.com/
|
57
|
+
run "cd #{application} && git pull"
|
58
|
+
run "cd #{application} && rake gems:install" if File.exist?("Rakefile")
|
59
|
+
run "cd #{application} && script/runner 'Sass::Plugin.options[:always_update] = true; Sass::Plugin.update_stylesheets'" if File.exist?("public/stylesheets/sass") or File.exist?("app/sass")
|
60
|
+
run "cd #{application} && rake asset:packager:build_all" if File.exist?("vendor/plugins/asset_packager")
|
61
|
+
run "cd #{application} && git submodule init && git submodule update" if File.exist?(".gitmodules")
|
62
|
+
run "cd #{application} && rake db:migrate && rake restart" if File.exist?("Rakefile")
|
63
|
+
success "Deploy Succeeded"
|
64
|
+
|
65
|
+
rescue BardError => e
|
66
|
+
handle_error e
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def readline(prompt)
|
71
|
+
STDOUT.print(prompt)
|
72
|
+
STDOUT.flush
|
73
|
+
STDIN.gets
|
74
|
+
end
|
75
|
+
|
76
|
+
def handle_error(error)
|
77
|
+
name = error.message.split('::').last.gsub(/([A-Z])/, " \\1").gsub(/^ /,'').gsub(/ Error/, '')
|
78
|
+
failure "!!! Deploy Error: #{name}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
## ERROR HANDLING
|
83
|
+
|
84
|
+
def handle_error(error)
|
85
|
+
name = error.message.split('::').last.gsub(/([A-Z])/, " \\1").gsub(/^ /,'').gsub(/ Error/, '')
|
86
|
+
failure "!!! Deploy Error: #{name}"
|
87
|
+
end
|
88
|
+
|
89
|
+
class BardError < Capistrano::Error; end
|
90
|
+
class TestsFailedError < BardError; end
|
91
|
+
class WorkingDirectoryDirtyError < BardError; end
|
92
|
+
class StagingWorkingDirectoryDirtyError < BardError; end
|
93
|
+
class NonFastForwardError < BardError; end
|
94
|
+
|
95
|
+
def success(msg)
|
96
|
+
puts "#{GREEN}#{msg}#{DEFAULT}"
|
97
|
+
end
|
98
|
+
|
99
|
+
def failure(msg)
|
100
|
+
abort "#{RED}#{msg}#{DEFAULT}"
|
101
|
+
end
|
102
|
+
|
103
|
+
GREEN = "\033[1;32m"
|
104
|
+
RED = "\033[1;31m"
|
105
|
+
DEFAULT = "\033[0m"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- features/support/grit_ext.rb
|
126
126
|
- features/support/io.rb
|
127
127
|
- lib/bard.rb
|
128
|
+
- lib/bard/capistrano.rb
|
128
129
|
- lib/bard/check.rb
|
129
130
|
- lib/bard/error.rb
|
130
131
|
- lib/bard/git.rb
|