factorylabs-auto_tagger 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +6 -0
- data/.gitignore +6 -0
- data/CHANGELOG +30 -0
- data/MIT-LICENSE +20 -0
- data/README.md +176 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/auto_tagger.gemspec +83 -0
- data/bin/autotag +38 -0
- data/features/autotag.feature +39 -0
- data/features/deployment.feature +29 -0
- data/features/step_definitions/autotag_steps.rb +41 -0
- data/features/step_definitions/deployment_steps.rb +53 -0
- data/features/support/env.rb +8 -0
- data/features/support/step_helpers.rb +136 -0
- data/features/templates/cap_ext_deploy.erb +32 -0
- data/features/templates/deploy.erb +34 -0
- data/features/templates/stage.erb +1 -0
- data/geminstaller.yml +7 -0
- data/lib/auto_tagger.rb +10 -0
- data/lib/auto_tagger/auto_tagger.rb +26 -0
- data/lib/auto_tagger/capistrano_helper.rb +39 -0
- data/lib/auto_tagger/commander.rb +15 -0
- data/lib/auto_tagger/recipes.rb +54 -0
- data/lib/auto_tagger/repository.rb +42 -0
- data/lib/auto_tagger/stage_manager.rb +23 -0
- data/lib/auto_tagger/tag.rb +41 -0
- data/spec/auto_tagger/auto_tagger_spec.rb +85 -0
- data/spec/auto_tagger/capistrano_helper_spec.rb +146 -0
- data/spec/auto_tagger/commander_spec.rb +17 -0
- data/spec/auto_tagger/repository_spec.rb +72 -0
- data/spec/auto_tagger/stage_manager_spec.rb +34 -0
- data/spec/auto_tagger/tag_spec.rb +66 -0
- data/spec/spec_helper.rb +7 -0
- metadata +116 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe StageManager do
|
4
|
+
|
5
|
+
describe ".new" do
|
6
|
+
[nil, ""].each do |value|
|
7
|
+
it "blows up if there are stages == #{value.inspect}" do
|
8
|
+
proc do
|
9
|
+
StageManager.new(value)
|
10
|
+
end.should raise_error(StageManager::NoStagesSpecifiedError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#previous_stage" do
|
16
|
+
it "returns the previous stage as a string if there is more than one stage, and there is a current stage" do
|
17
|
+
StageManager.new([:foo, :bar]).previous_stage(:bar).should == "foo"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns nil if there is no previous stage" do
|
21
|
+
StageManager.new([:bar]).previous_stage(:bar).should be_nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it "deals with mixed strings and symbols" do
|
25
|
+
StageManager.new([:"foo-bar", "baz"]).previous_stage(:baz).should == "foo-bar"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns nil if there is no current stage" do
|
29
|
+
StageManager.new([:bar]).previous_stage(nil).should be_nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Tag do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@repository = Object.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".new" do
|
10
|
+
it "sets the repository" do
|
11
|
+
Tag.new(@repository).repository.should == @repository
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#find_all" do
|
16
|
+
it "returns an array of tags" do
|
17
|
+
mock(@repository).run("git tag") { "ci_01\nci_02" }
|
18
|
+
Tag.new(@repository).find_all.should == ["ci_01", "ci_02"]
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns an empty array if there are none" do
|
22
|
+
mock(@repository).run("git tag") { "" }
|
23
|
+
Tag.new(@repository).find_all.should be_empty
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#latest_from" do
|
28
|
+
before do
|
29
|
+
@tag = Tag.new(@repository)
|
30
|
+
mock(@tag).find_all { ["ci/01", "ci/02"] }
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns the latest tag that starts with the specified stage" do
|
34
|
+
@tag.latest_from(:ci).should == "ci/02"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns nil if none match" do
|
38
|
+
@tag.latest_from(:staging).should be_nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#fetch_tags" do
|
43
|
+
it "sends the correct command" do
|
44
|
+
mock(@repository).run!("git fetch origin --tags")
|
45
|
+
Tag.new(@repository).fetch
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#push" do
|
50
|
+
it "sends the correct command" do
|
51
|
+
mock(@repository).run!("git push origin --tags")
|
52
|
+
Tag.new(@repository).push
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#create" do
|
57
|
+
it "creates the right command and returns the name" do
|
58
|
+
time = Time.local(2001,1,1)
|
59
|
+
mock(Time).now.once {time}
|
60
|
+
tag_name = "ci/#{time.utc.strftime('%Y%m%d%H%M%S')}"
|
61
|
+
mock(@repository).run!("git tag #{tag_name}")
|
62
|
+
Tag.new(@repository).create("ci").should == tag_name
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: factorylabs-auto_tagger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jeff Dean
|
13
|
+
- Brian Takita
|
14
|
+
- Mike Grafton
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2010-04-06 00:00:00 -06:00
|
20
|
+
default_executable: autotag
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: capistrano
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 5
|
32
|
+
- 3
|
33
|
+
version: 2.5.3
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
description:
|
37
|
+
email: jeff@zilkey.com
|
38
|
+
executables:
|
39
|
+
- autotag
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- README.md
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- CHANGELOG
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- VERSION
|
52
|
+
- auto_tagger.gemspec
|
53
|
+
- bin/autotag
|
54
|
+
- features/autotag.feature
|
55
|
+
- features/deployment.feature
|
56
|
+
- features/step_definitions/autotag_steps.rb
|
57
|
+
- features/step_definitions/deployment_steps.rb
|
58
|
+
- features/support/env.rb
|
59
|
+
- features/support/step_helpers.rb
|
60
|
+
- features/templates/cap_ext_deploy.erb
|
61
|
+
- features/templates/deploy.erb
|
62
|
+
- features/templates/stage.erb
|
63
|
+
- geminstaller.yml
|
64
|
+
- lib/auto_tagger.rb
|
65
|
+
- lib/auto_tagger/auto_tagger.rb
|
66
|
+
- lib/auto_tagger/capistrano_helper.rb
|
67
|
+
- lib/auto_tagger/commander.rb
|
68
|
+
- lib/auto_tagger/recipes.rb
|
69
|
+
- lib/auto_tagger/repository.rb
|
70
|
+
- lib/auto_tagger/stage_manager.rb
|
71
|
+
- lib/auto_tagger/tag.rb
|
72
|
+
- spec/auto_tagger/auto_tagger_spec.rb
|
73
|
+
- spec/auto_tagger/capistrano_helper_spec.rb
|
74
|
+
- spec/auto_tagger/commander_spec.rb
|
75
|
+
- spec/auto_tagger/repository_spec.rb
|
76
|
+
- spec/auto_tagger/stage_manager_spec.rb
|
77
|
+
- spec/auto_tagger/tag_spec.rb
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
has_rdoc: true
|
80
|
+
homepage: http://github.com/zilkey/auto_tagger
|
81
|
+
licenses: []
|
82
|
+
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options:
|
85
|
+
- --charset=UTF-8
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
requirements: []
|
103
|
+
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 1.3.6
|
106
|
+
signing_key:
|
107
|
+
specification_version: 3
|
108
|
+
summary: Helps you automatically create tags for each stage in a multi-stage deploment and deploy from the latest tag from the previous environment
|
109
|
+
test_files:
|
110
|
+
- spec/auto_tagger/auto_tagger_spec.rb
|
111
|
+
- spec/auto_tagger/capistrano_helper_spec.rb
|
112
|
+
- spec/auto_tagger/commander_spec.rb
|
113
|
+
- spec/auto_tagger/repository_spec.rb
|
114
|
+
- spec/auto_tagger/stage_manager_spec.rb
|
115
|
+
- spec/auto_tagger/tag_spec.rb
|
116
|
+
- spec/spec_helper.rb
|