volley 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +49 -1
- data/features/publisher.feature +1 -1
- data/features/step_definitions/publisher_steps.rb +3 -2
- data/lib/volley/dsl/action.rb +1 -0
- data/lib/volley/dsl/plan.rb +28 -3
- data/lib/volley/dsl/push_action.rb +11 -0
- data/lib/volley/publisher/amazons3.rb +16 -4
- data/lib/volley/publisher/base.rb +5 -1
- data/lib/volley/version.rb +1 -1
- data/spec/dsl_plan_spec.rb +2 -2
- data/spec/publisher_spec.rb +11 -2
- metadata +2 -2
data/Rakefile
CHANGED
@@ -39,4 +39,52 @@ task :test do
|
|
39
39
|
rescue => e
|
40
40
|
puts "#{e.message} at #{e.backtrace.first}"
|
41
41
|
end
|
42
|
-
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def changelog(last=nil, single=false)
|
45
|
+
command="git --no-pager log --format='%an::::%h::::%s'"
|
46
|
+
|
47
|
+
list = `git tag`
|
48
|
+
|
49
|
+
puts "# Changelog"
|
50
|
+
puts
|
51
|
+
|
52
|
+
list.lines.reject{|e| e =~ /\.alpha/}.reverse_each do |t|
|
53
|
+
tag = t.chomp
|
54
|
+
|
55
|
+
if last
|
56
|
+
check = { }
|
57
|
+
out = []
|
58
|
+
log = `#{command} #{last}...#{tag}`
|
59
|
+
log.lines.each do |line|
|
60
|
+
(who, hash, msg) = line.split('::::')
|
61
|
+
unless check[msg]
|
62
|
+
unless msg =~ /^Merge branch/ || msg =~ /CHANGELOG/ || msg =~ /^(v|version|changes for|preparing|ready for release|ready to release|bump version)*\s*(v|version)*\d+\.\d+\.\d+/
|
63
|
+
msg.gsub(" *", "\n*").gsub(/^\*\*/, " *").lines.each do |l|
|
64
|
+
line = l =~ /^(\s+)*\*/ ? l : "* #{l}"
|
65
|
+
out << line
|
66
|
+
end
|
67
|
+
check[msg] = hash
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
puts "## #{last}:"
|
72
|
+
out.each { |e| puts e }
|
73
|
+
#puts log
|
74
|
+
puts
|
75
|
+
end
|
76
|
+
|
77
|
+
last = tag
|
78
|
+
exit if single
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "generate changelog output"
|
83
|
+
task :changelog do
|
84
|
+
changelog
|
85
|
+
end
|
86
|
+
|
87
|
+
desc "show current changes (changelog output from HEAD to most recent tag)"
|
88
|
+
task :current do
|
89
|
+
changelog("HEAD",true)
|
90
|
+
end
|
data/features/publisher.feature
CHANGED
@@ -36,7 +36,7 @@ Feature: Publisher
|
|
36
36
|
Scenario: Duplicate Artifact
|
37
37
|
Given I have a populated repository
|
38
38
|
When I publish a duplicate artifact test/staging/12
|
39
|
-
Then I should receive an exception
|
39
|
+
Then I should not receive an exception
|
40
40
|
|
41
41
|
# TODO: make this work
|
42
42
|
# Scenario: Duplicate Artifact force
|
@@ -56,8 +56,9 @@ When /^I publish a duplicate artifact (.*)$/ do |desc|
|
|
56
56
|
When I publish the artifact #{desc}
|
57
57
|
}
|
58
58
|
begin
|
59
|
-
publish(desc)
|
59
|
+
@duplicate_published = publish(desc)
|
60
60
|
rescue => e
|
61
|
+
puts "exception: #{e.message}"
|
61
62
|
@exception = e
|
62
63
|
end
|
63
64
|
end
|
@@ -66,7 +67,7 @@ end
|
|
66
67
|
When /^I force publish a duplicate artifact (.*)$/ do |desc|
|
67
68
|
steps %Q{
|
68
69
|
When I publish the artifact #{desc}
|
69
|
-
|
70
|
+
}
|
70
71
|
begin
|
71
72
|
publish(desc)
|
72
73
|
rescue => e
|
data/lib/volley/dsl/action.rb
CHANGED
data/lib/volley/dsl/plan.rb
CHANGED
@@ -25,6 +25,7 @@ module Volley
|
|
25
25
|
|
26
26
|
@name = name.to_sym
|
27
27
|
@project = options[:project]
|
28
|
+
@stopped = false
|
28
29
|
@block = block
|
29
30
|
@files = []
|
30
31
|
@arguments = { }
|
@@ -43,6 +44,7 @@ module Volley
|
|
43
44
|
else
|
44
45
|
argument :descriptor, :convert => :descriptor, :convert_opts => { :partial => true }
|
45
46
|
end
|
47
|
+
argument :force
|
46
48
|
end
|
47
49
|
|
48
50
|
def call(options={ })
|
@@ -57,7 +59,13 @@ module Volley
|
|
57
59
|
|
58
60
|
Volley::Log.info ">> #{@project.name}:#@name"
|
59
61
|
|
60
|
-
|
62
|
+
begin
|
63
|
+
run_actions
|
64
|
+
rescue => e
|
65
|
+
puts "plan#call error: #{e.message} at #{e.backtrace.first}"
|
66
|
+
ap self
|
67
|
+
raise e
|
68
|
+
end
|
61
69
|
[branch, version].join(":")
|
62
70
|
end
|
63
71
|
|
@@ -77,12 +85,21 @@ module Volley
|
|
77
85
|
out.join(" ")
|
78
86
|
end
|
79
87
|
|
80
|
-
def run_actions
|
88
|
+
def run_actions
|
81
89
|
@stage_order.each do |stage|
|
90
|
+
@current_stage = stage
|
82
91
|
@stages[stage].call
|
83
92
|
end
|
84
93
|
end
|
85
94
|
|
95
|
+
def stop
|
96
|
+
@stopped = true
|
97
|
+
end
|
98
|
+
|
99
|
+
def stopped?
|
100
|
+
@stopped
|
101
|
+
end
|
102
|
+
|
86
103
|
def method_missing(n, *args)
|
87
104
|
Volley::Log.warn "** plan DSL does not support method: #{n} #{args.join(',')}"
|
88
105
|
raise "not supported"
|
@@ -173,7 +190,12 @@ module Volley
|
|
173
190
|
:descriptor => args.descriptor,
|
174
191
|
:args => {},
|
175
192
|
}.merge(options)
|
176
|
-
|
193
|
+
action = Volley::Dsl::VolleyAction.new("volley-#{plan}", o)
|
194
|
+
#if @current_stage == :post
|
195
|
+
# action.call
|
196
|
+
#else
|
197
|
+
@stages[:main].add action
|
198
|
+
#end
|
177
199
|
end
|
178
200
|
|
179
201
|
def file(file)
|
@@ -227,6 +249,9 @@ module Volley
|
|
227
249
|
@arguments.each do |k, v|
|
228
250
|
v.check
|
229
251
|
end
|
252
|
+
if @arguments[:force] && Volley::Dsl.publisher
|
253
|
+
Volley::Dsl.publisher.force = true
|
254
|
+
end
|
230
255
|
end
|
231
256
|
end
|
232
257
|
end
|
@@ -12,6 +12,17 @@ module Volley
|
|
12
12
|
raise "stage instance must be set" unless @stage
|
13
13
|
raise "plan instance must be set" unless @plan
|
14
14
|
|
15
|
+
@plan.action :check, :pre do
|
16
|
+
raise "branch(#{branch}) and version(#{version}) must be specified" unless branch && version
|
17
|
+
p = @plan.project.name
|
18
|
+
b = branch
|
19
|
+
v = version
|
20
|
+
if Volley::Dsl.publisher.exists?(p, b, v)
|
21
|
+
log ".. artifact exists: #{p}@#{b}:#{v}"
|
22
|
+
@plan.stop unless args.force
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
15
26
|
@plan.action :files, :main do
|
16
27
|
raise "branch(#{branch}) and version(#{version}) must be specified" unless branch && version
|
17
28
|
|
@@ -18,7 +18,8 @@ module Volley
|
|
18
18
|
[]
|
19
19
|
end
|
20
20
|
|
21
|
-
def branches(
|
21
|
+
def branches(project)
|
22
|
+
pr = project.to_s
|
22
23
|
r = files[:desc][pr].keys || [] rescue []
|
23
24
|
Volley::Log.info "could not find #{pr}" unless r.count > 0
|
24
25
|
r
|
@@ -27,7 +28,9 @@ module Volley
|
|
27
28
|
[]
|
28
29
|
end
|
29
30
|
|
30
|
-
def versions(
|
31
|
+
def versions(project, branch)
|
32
|
+
pr = project.to_s
|
33
|
+
br = branch.to_s
|
31
34
|
r = files[:desc][pr][br].keys || [] rescue []
|
32
35
|
Volley::Log.info "could not find #{pr}@#{br}" unless r.count > 0
|
33
36
|
r
|
@@ -36,7 +39,10 @@ module Volley
|
|
36
39
|
[]
|
37
40
|
end
|
38
41
|
|
39
|
-
def contents(
|
42
|
+
def contents(project, branch, version)
|
43
|
+
pr = project.to_s
|
44
|
+
br = branch.to_s
|
45
|
+
vr = version.to_s
|
40
46
|
r = files[:desc][pr][br][vr].map {|e| e.gsub("#{pr}/#{br}/#{vr}/","")} || [] rescue []
|
41
47
|
Volley::Log.info "could not find #{pr}@#{br}:#{vr}" unless r.count > 0
|
42
48
|
r
|
@@ -46,7 +52,13 @@ module Volley
|
|
46
52
|
end
|
47
53
|
|
48
54
|
def exists?(project, branch, version)
|
49
|
-
|
55
|
+
pr = project.to_s
|
56
|
+
br = branch.to_s
|
57
|
+
vr = version.to_s
|
58
|
+
!files[:desc][pr][br][vr].nil?
|
59
|
+
rescue => e
|
60
|
+
Volley::Log.debug "exists? error: #{e.message}"
|
61
|
+
false
|
50
62
|
end
|
51
63
|
|
52
64
|
def delete_project(project)
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Volley
|
2
2
|
module Publisher
|
3
3
|
class Base
|
4
|
+
attr_accessor :force
|
5
|
+
|
4
6
|
def initialize(options={ })
|
5
7
|
@options = {
|
6
8
|
:overwrite => false,
|
@@ -11,6 +13,7 @@ module Volley
|
|
11
13
|
@local = optional(:local, Volley.config.directory)
|
12
14
|
@loglevel = @debug ? :info : :debug
|
13
15
|
@latest = {}
|
16
|
+
@force = false
|
14
17
|
|
15
18
|
load_configuration
|
16
19
|
end
|
@@ -60,7 +63,8 @@ module Volley
|
|
60
63
|
end
|
61
64
|
|
62
65
|
def push(project, branch, version, localfiles)
|
63
|
-
|
66
|
+
v = version == "latest" ? latest_version(project, branch) : version
|
67
|
+
return false if exists?(project, branch, v) && !@force
|
64
68
|
|
65
69
|
localfiles = [*localfiles].flatten
|
66
70
|
log "^^ #{me}#push"
|
data/lib/volley/version.rb
CHANGED
data/spec/dsl_plan_spec.rb
CHANGED
@@ -57,14 +57,14 @@ describe Volley::Dsl::Plan do
|
|
57
57
|
|
58
58
|
it "should handle arguments" do
|
59
59
|
@plan.argument(:testarg)
|
60
|
-
expect(@plan.arguments.count).to eq(
|
60
|
+
expect(@plan.arguments.count).to eq(3) # descriptor and testarg
|
61
61
|
@plan.call(:args => {:descriptor => "test@trunk/1",:testarg => "true"})
|
62
62
|
expect(@plan.args.testarg).to eq("true")
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should handle arguments (with remote false)" do
|
66
66
|
@notremote.argument(:testarg)
|
67
|
-
expect(@notremote.arguments.count).to eq(
|
67
|
+
expect(@notremote.arguments.count).to eq(3) # descriptor and testarg
|
68
68
|
@notremote.call(:args => {:testarg => "true"})
|
69
69
|
expect(@notremote.args.testarg).to eq("true")
|
70
70
|
end
|
data/spec/publisher_spec.rb
CHANGED
@@ -63,8 +63,17 @@ shared_examples_for Volley::Publisher::Base do
|
|
63
63
|
expect(@pub.latest("spec", "trunk")).to eq("spec/trunk/3")
|
64
64
|
end
|
65
65
|
|
66
|
-
it "should
|
67
|
-
expect
|
66
|
+
it "should fail to publish a duplicate artifact" do
|
67
|
+
expect(@pub.push("spec", "trunk", "1", "./trunk-1.tgz")).to eq(false)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should be able to force publish a duplicate artifact" do
|
71
|
+
Dir.chdir("#{root}/test/")
|
72
|
+
o = @pub.force
|
73
|
+
@pub.force = true
|
74
|
+
expect(@pub.push("spec", "trunk", "1", "./trunk-1.tgz")).to eq(true)
|
75
|
+
@pub.force = o
|
76
|
+
Dir.chdir(root)
|
68
77
|
end
|
69
78
|
|
70
79
|
it "should be able to delete a project" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volley
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|