gta 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/lib/gta/manager.rb +24 -12
- data/lib/gta/stage.rb +4 -0
- data/lib/gta/tasks.rb +1 -0
- data/lib/gta/tasks/deploy.rake +45 -0
- data/lib/gta/version.rb +1 -1
- data/spec/fixtures/config/gta.yml +7 -3
- data/spec/manager_spec.rb +16 -1
- data/spec/stage_spec.rb +7 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7556ec1e18be52cee268ff3ed3cd789105e5b25
|
4
|
+
data.tar.gz: 191ddf38c622d9f52314950c99a424939aff830c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b075eed67f7f9f287854b4111a6f1b3d745b2f2fa7c4d942494a1e048c970e59ca7b4eae55c66904dff51d4578e87e5acb087085a5ee49f37c9712112292f381
|
7
|
+
data.tar.gz: 0a198413b848c8fc4db13ba529b901149e9eb1e30b8f400572d98054686f5a70e55bf7f7c8ed1d7b74876085c7b4146c8ba04d5205f3c33e8be3f9ae54adefcd
|
data/Rakefile
CHANGED
data/lib/gta/manager.rb
CHANGED
@@ -6,6 +6,30 @@ module GTA
|
|
6
6
|
@config_path = config_path
|
7
7
|
end
|
8
8
|
|
9
|
+
def push_to(name, forced = nil)
|
10
|
+
s = stage!(name)
|
11
|
+
fetch
|
12
|
+
if forced == :force
|
13
|
+
s.force_push
|
14
|
+
else
|
15
|
+
s.push
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def checkout(name)
|
20
|
+
stage!(name).checkout
|
21
|
+
end
|
22
|
+
|
23
|
+
alias :co :checkout
|
24
|
+
|
25
|
+
def fetch
|
26
|
+
stages.each(&:fetch)
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup
|
30
|
+
stages.each(&:add_remote)
|
31
|
+
end
|
32
|
+
|
9
33
|
def config
|
10
34
|
@config ||= YAML.load(File.read(config_path))
|
11
35
|
end
|
@@ -21,17 +45,5 @@ module GTA
|
|
21
45
|
def stage!(name)
|
22
46
|
stage(name) || (raise ArgumentError.new("Stage #{name} not found"))
|
23
47
|
end
|
24
|
-
|
25
|
-
def push_to(name)
|
26
|
-
stage!(name).push
|
27
|
-
end
|
28
|
-
|
29
|
-
def fetch
|
30
|
-
stages.each(&:fetch)
|
31
|
-
end
|
32
|
-
|
33
|
-
def setup
|
34
|
-
stages.each(&:add_remote)
|
35
|
-
end
|
36
48
|
end
|
37
49
|
end
|
data/lib/gta/stage.rb
CHANGED
data/lib/gta/tasks.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
load "#{File.dirname(__FILE__)}/tasks/deploy.rake"
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'gta'
|
2
|
+
|
3
|
+
namespace :deploy do
|
4
|
+
stage_name_error = "stage name required, run rake with argument rake:deploy[staging]"
|
5
|
+
desc 'task that will be run before a deploy'
|
6
|
+
task :before
|
7
|
+
|
8
|
+
desc 'task that will be run after a deploy'
|
9
|
+
task :after
|
10
|
+
|
11
|
+
# the meat of a deploy, a git push from source to destination
|
12
|
+
task :gta_push, :stage_name do |t, args|
|
13
|
+
raise stage_name_error unless stage_name = args[:stage_name]
|
14
|
+
manager = GTA::Manager.new(ENV['GTA_CONFIG_PATH'])
|
15
|
+
manager.push_to(stage_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
# a forced version of the meat of the matter
|
19
|
+
task :gta_force_push, :stage_name do |t, args|
|
20
|
+
raise stage_name_error unless stage_name = args[:stage_name]
|
21
|
+
manager = GTA::Manager.new(ENV['GTA_CONFIG_PATH'])
|
22
|
+
manager.push_to(stage_name, :force)
|
23
|
+
end
|
24
|
+
|
25
|
+
task :wrap, :stage_name do |t, args|
|
26
|
+
stage_name = args[:stage_name]
|
27
|
+
Rake::Task["deploy:before"].invoke(stage_name)
|
28
|
+
Rake::Task["deploy:gta_push"].invoke(stage_name)
|
29
|
+
Rake::Task["deploy:before"].invoke(stage_name)
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'force push deploy, running before and after tasks'
|
33
|
+
task :force, :stage_name do |t, args|
|
34
|
+
stage_name = args[:stage_name]
|
35
|
+
Rake::Task["deploy:before"].invoke(stage_name)
|
36
|
+
Rake::Task["deploy:gta_force_push"].invoke(stage_name)
|
37
|
+
Rake::Task["deploy:before"].invoke(stage_name)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "push deploy, running before and after tasks"
|
42
|
+
task :deploy, :stage_name do |t, args|
|
43
|
+
Rake::Task["deploy:wrap"].invoke(args[:stage_name])
|
44
|
+
end
|
45
|
+
|
data/lib/gta/version.rb
CHANGED
@@ -1,15 +1,19 @@
|
|
1
|
+
origin:
|
2
|
+
repository: git@github.com:socialchorus/activator.git
|
3
|
+
|
1
4
|
ci:
|
5
|
+
source: origin
|
2
6
|
repository: git@github.com:socialchorus/activator.git
|
3
7
|
|
4
8
|
staging:
|
5
|
-
|
9
|
+
source: ci
|
6
10
|
tag: staging/*
|
7
11
|
repository: git@heroku.com:activator-staging.git
|
8
12
|
|
9
13
|
qa:
|
10
|
-
|
14
|
+
source: staging
|
11
15
|
repository: git@heroku.com:activator-qa.git
|
12
16
|
|
13
17
|
production:
|
14
|
-
|
18
|
+
source: qa
|
15
19
|
repository: git@heroku.com:activator-production.git
|
data/spec/manager_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe GTA::Manager do
|
|
5
5
|
let(:manager) { GTA::Manager.new(config_path) }
|
6
6
|
|
7
7
|
it "builds stages for each entry in the yml" do
|
8
|
-
manager.stages.size.should ==
|
8
|
+
manager.stages.size.should == 5
|
9
9
|
manager.stages.map(&:class).uniq.should == [GTA::Stage]
|
10
10
|
end
|
11
11
|
|
@@ -38,10 +38,25 @@ describe GTA::Manager do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe '#push_to' do
|
41
|
+
before do
|
42
|
+
manager.stub(:fetch)
|
43
|
+
manager.stage(:qa).stub(:push)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "fetches" do
|
47
|
+
manager.should_receive(:fetch)
|
48
|
+
manager.push_to(:qa)
|
49
|
+
end
|
50
|
+
|
41
51
|
it "tells the right stage to push itself" do
|
42
52
|
manager.stage(:qa).should_receive(:push)
|
43
53
|
manager.push_to(:qa)
|
44
54
|
end
|
55
|
+
|
56
|
+
it "will force with the right arguments" do
|
57
|
+
manager.stage(:qa).should_receive(:force_push)
|
58
|
+
manager.push_to(:qa, :force)
|
59
|
+
end
|
45
60
|
end
|
46
61
|
|
47
62
|
describe '#setup' do
|
data/spec/stage_spec.rb
CHANGED
@@ -39,6 +39,13 @@ describe GTA::Stage do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
describe '#checkout' do
|
43
|
+
it "send the command to checkout a tracking branch from the remote" do
|
44
|
+
stage.should_receive(:sh).with("git checkout -b staging -t staging/master")
|
45
|
+
stage.checkout
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
42
49
|
describe '#fetch' do
|
43
50
|
it "calls the right git command" do
|
44
51
|
stage.should_receive(:sh).with("git fetch staging")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- socialchorus
|
@@ -73,6 +73,8 @@ files:
|
|
73
73
|
- lib/gta/remote_db.rb
|
74
74
|
- lib/gta/sh.rb
|
75
75
|
- lib/gta/stage.rb
|
76
|
+
- lib/gta/tasks.rb
|
77
|
+
- lib/gta/tasks/deploy.rake
|
76
78
|
- lib/gta/version.rb
|
77
79
|
- spec/fixtures/config/gta.yml
|
78
80
|
- spec/manager_spec.rb
|