gta 0.0.1 → 0.1.0

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: 27c920a2a56f8e301489d77634ce463854a5ffa1
4
- data.tar.gz: f548a008605b16f83c651681d97f70447cc3e80d
3
+ metadata.gz: c7556ec1e18be52cee268ff3ed3cd789105e5b25
4
+ data.tar.gz: 191ddf38c622d9f52314950c99a424939aff830c
5
5
  SHA512:
6
- metadata.gz: 25f6527c6ddc4a6a9165a62a87fe2d5857bf07a959889daa5055b2a780f16cade8384f8ab642c84ef03a2b029a5480872b9c59420d6bccbf325d4c3d8041844b
7
- data.tar.gz: 76dc5ee7aebea7764d994cf3b53f4efac5f9d5ddd185c061fba665c90b70d87d20e7009f0959ce089aa3460f645138af61311f5c24b0e10f1eee8578ef74904f
6
+ metadata.gz: b075eed67f7f9f287854b4111a6f1b3d745b2f2fa7c4d942494a1e048c970e59ca7b4eae55c66904dff51d4578e87e5acb087085a5ee49f37c9712112292f381
7
+ data.tar.gz: 0a198413b848c8fc4db13ba529b901149e9eb1e30b8f400572d98054686f5a70e55bf7f7c8ed1d7b74876085c7b4146c8ba04d5205f3c33e8be3f9ae54adefcd
data/Rakefile CHANGED
@@ -1 +1,2 @@
1
1
  require "bundler/gem_tasks"
2
+ require "#{File.dirname(__FILE__)}/lib/gta/tasks.rb"
@@ -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
@@ -28,6 +28,10 @@ module GTA
28
28
  sh "git remote add #{name} #{repository}"
29
29
  end
30
30
 
31
+ def checkout
32
+ sh "git checkout -b #{name} -t #{name}/#{branch}"
33
+ end
34
+
31
35
  def push(s=source, forced=nil)
32
36
  sh push_command(source_from(s), forced)
33
37
  end
@@ -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
+
@@ -1,3 +1,3 @@
1
1
  module GTA
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -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
- source_stage: ci
9
+ source: ci
6
10
  tag: staging/*
7
11
  repository: git@heroku.com:activator-staging.git
8
12
 
9
13
  qa:
10
- source_stage: staging
14
+ source: staging
11
15
  repository: git@heroku.com:activator-qa.git
12
16
 
13
17
  production:
14
- source_stage: qa
18
+ source: qa
15
19
  repository: git@heroku.com:activator-production.git
@@ -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 == 4
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
@@ -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.1
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