yes_ship_it 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/MIT-LICENSE +17 -0
- data/assertions/built_gem.rb +4 -10
- data/assertions/change_log.rb +6 -12
- data/assertions/published_gem.rb +7 -13
- data/assertions/pushed_code.rb +4 -6
- data/assertions/pushed_tag.rb +4 -6
- data/assertions/release_archive.rb +9 -14
- data/assertions/release_branch.rb +3 -4
- data/assertions/submitted_rpm.rb +21 -35
- data/assertions/tag.rb +5 -7
- data/assertions/version.rb +10 -6
- data/assertions/working_directory.rb +3 -4
- data/assertions/yes_it_shipped.rb +6 -12
- data/bin/yes_ship_it +23 -10
- data/lib/version.rb +1 -1
- data/lib/yes_ship_it/assertion.rb +9 -3
- data/lib/yes_ship_it/dry_executor.rb +15 -0
- data/lib/yes_ship_it/engine.rb +30 -18
- data/lib/yes_ship_it/exceptions.rb +3 -0
- data/lib/yes_ship_it/executor.rb +37 -0
- data/lib/yes_ship_it/git.rb +8 -7
- data/lib/yes_ship_it/init.rb +50 -0
- data/lib/yes_ship_it/plugin.rb +76 -0
- data/lib/yes_ship_it.rb +4 -0
- data/spec/data/init/ruby/lib/version.rb +3 -0
- data/spec/data/plugins/my_other_plugin.rb +14 -0
- data/spec/data/plugins/my_plugin.rb +14 -0
- data/spec/data/version/polkaversion.h +1 -0
- data/spec/data/yes_ship_it.plugins.conf +4 -0
- data/spec/integration/cli_spec.rb +155 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/system/data/red_herring-checkout-dry-run.tar.gz +0 -0
- data/spec/system/data/red_herring-checkout-rpm.tar.gz +0 -0
- data/spec/system/dry_run_spec.rb +59 -0
- data/spec/system/rpm_spec.rb +62 -0
- data/spec/system/ruby_gem_spec.rb +2 -3
- data/spec/unit/assertion_spec.rb +11 -1
- data/spec/unit/assertions/change_log_spec.rb +6 -2
- data/spec/unit/assertions/published_gem_spec.rb +6 -4
- data/spec/unit/assertions/pushed_code_spec.rb +1 -1
- data/spec/unit/assertions/version_spec.rb +5 -0
- data/spec/unit/assertions/yes_it_shipped_spec.rb +1 -1
- data/spec/unit/dry_executor_spec.rb +5 -0
- data/spec/unit/engine_spec.rb +16 -0
- data/spec/unit/executor_spec.rb +26 -0
- data/spec/unit/git_spec.rb +5 -4
- data/spec/unit/init_spec.rb +49 -0
- data/spec/unit/plugin_spec.rb +18 -0
- data/spec/unit/support/assertion_examples.rb +4 -4
- data/spec/unit/support/executor_examples.rb +17 -0
- metadata +23 -3
data/lib/yes_ship_it/engine.rb
CHANGED
@@ -1,15 +1,28 @@
|
|
1
1
|
module YSI
|
2
2
|
class Engine
|
3
3
|
attr_reader :assertions
|
4
|
+
attr_reader :executor
|
4
5
|
attr_accessor :version, :tag_date, :release_archive
|
5
6
|
attr_accessor :out
|
6
|
-
attr_accessor :dry_run
|
7
7
|
attr_accessor :data_dir
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@assertions = []
|
11
11
|
@out = STDOUT
|
12
12
|
@data_dir = File.expand_path("~/.ysi")
|
13
|
+
self.dry_run = false
|
14
|
+
end
|
15
|
+
|
16
|
+
def dry_run=(dry_run)
|
17
|
+
if dry_run
|
18
|
+
@executor = DryExecutor.new
|
19
|
+
else
|
20
|
+
@executor = Executor.new
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def dry_run?
|
25
|
+
@executor.is_a?(DryExecutor)
|
13
26
|
end
|
14
27
|
|
15
28
|
def read_config(yaml)
|
@@ -61,7 +74,7 @@ module YSI
|
|
61
74
|
|
62
75
|
def github_project_name
|
63
76
|
if !@github_project_name
|
64
|
-
origin = Git.new.origin
|
77
|
+
origin = Git.new(Executor.new).origin
|
65
78
|
@github_project_name = origin.match("git@github.com:(.*)")[1]
|
66
79
|
end
|
67
80
|
@github_project_name
|
@@ -111,18 +124,18 @@ module YSI
|
|
111
124
|
skipped_assertions << assertion
|
112
125
|
next
|
113
126
|
end
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
if assertion.error
|
119
|
-
out.puts "error"
|
120
|
-
out.puts " " + assertion.error
|
121
|
-
errored_assertions.push(assertion)
|
127
|
+
begin
|
128
|
+
success = assertion.check
|
129
|
+
if success
|
130
|
+
out.puts success
|
122
131
|
else
|
123
132
|
out.puts "fail"
|
124
133
|
failed_assertions.push(assertion)
|
125
134
|
end
|
135
|
+
rescue AssertionError => e
|
136
|
+
out.puts "error"
|
137
|
+
out.puts " " + e.message
|
138
|
+
errored_assertions.push(assertion)
|
126
139
|
end
|
127
140
|
end
|
128
141
|
|
@@ -141,16 +154,15 @@ module YSI
|
|
141
154
|
return 0
|
142
155
|
else
|
143
156
|
failed_assertions.each do |assertion|
|
144
|
-
if dry_run
|
157
|
+
if dry_run?
|
145
158
|
out.print "Dry run: "
|
146
159
|
end
|
147
160
|
out.print "Asserting #{assertion.display_name}: "
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
end
|
161
|
+
begin
|
162
|
+
success = assertion.assert(executor)
|
163
|
+
rescue AssertionError => e
|
164
|
+
out.puts "error"
|
165
|
+
out.puts " " + e.message
|
154
166
|
out.puts
|
155
167
|
out.puts "Ran into an error. Stopping shipping."
|
156
168
|
return 1
|
@@ -159,7 +171,7 @@ module YSI
|
|
159
171
|
end
|
160
172
|
|
161
173
|
out.puts
|
162
|
-
if dry_run
|
174
|
+
if dry_run?
|
163
175
|
out.puts "Did a dry run of shipping #{project_name} #{version}." +
|
164
176
|
" Nothing was changed."
|
165
177
|
else
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module YSI
|
2
|
+
class Executor
|
3
|
+
def run_command(args, working_directory: Dir.pwd)
|
4
|
+
begin
|
5
|
+
Dir.chdir(working_directory) do
|
6
|
+
Cheetah.run(args, stdout: :capture)
|
7
|
+
end
|
8
|
+
rescue Cheetah::ExecutionFailed => e
|
9
|
+
raise YSI::AssertionError.new(e.message)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def http_post(url, data)
|
14
|
+
begin
|
15
|
+
RestClient.post(url, data)
|
16
|
+
rescue RestClient::Exception => e
|
17
|
+
raise YSI::AssertionError.new(e.message)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def http_put(url, data, options)
|
22
|
+
begin
|
23
|
+
RestClient.put(url, data, options)
|
24
|
+
rescue RestClient::Exception => e
|
25
|
+
raise YSI::AssertionError.new(e.message)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def http_delete(url)
|
30
|
+
begin
|
31
|
+
RestClient.delete(url)
|
32
|
+
rescue RestClient::Exception => e
|
33
|
+
raise YSI::AssertionError.new(e.message)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/yes_ship_it/git.rb
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
module YSI
|
2
2
|
class Git
|
3
|
-
def initialize(working_dir = Dir.pwd)
|
3
|
+
def initialize(executor, working_dir = Dir.pwd)
|
4
|
+
@executor = executor
|
4
5
|
@working_dir = working_dir
|
5
6
|
end
|
6
7
|
|
7
8
|
def run_git(args)
|
8
9
|
Dir.chdir(@working_dir) do
|
9
|
-
|
10
|
+
@executor.run_command(["git"] + args)
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
14
|
def origin
|
14
|
-
run_git("remote -v").match(/origin\s+(.*?)(\.git)?\s+\(push\)/)[1]
|
15
|
+
run_git(["remote", "-v"]).match(/origin\s+(.*?)(\.git)?\s+\(push\)/)[1]
|
15
16
|
end
|
16
17
|
|
17
18
|
def needs_push?
|
18
|
-
local_master = run_git("rev-parse master")
|
19
|
-
remote_master = run_git("rev-parse origin/master")
|
20
|
-
base = run_git("merge-base master origin/master")
|
19
|
+
local_master = run_git(["rev-parse", "master"])
|
20
|
+
remote_master = run_git(["rev-parse", "origin/master"])
|
21
|
+
base = run_git(["merge-base", "master", "origin/master"])
|
21
22
|
|
22
23
|
remote_master == base && local_master != remote_master
|
23
24
|
end
|
24
25
|
|
25
26
|
def push
|
26
|
-
|
27
|
+
run_git(["push"])
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module YSI
|
2
|
+
class Init
|
3
|
+
attr_accessor :out
|
4
|
+
|
5
|
+
def initialize(path)
|
6
|
+
@path = path
|
7
|
+
|
8
|
+
@out = STDOUT
|
9
|
+
end
|
10
|
+
|
11
|
+
def setup_config
|
12
|
+
config_file = File.join(@path, "yes_ship_it.conf")
|
13
|
+
|
14
|
+
if File.exist?(config_file)
|
15
|
+
out.puts "There already is a file `yes_ship_it.conf`."
|
16
|
+
out.puts
|
17
|
+
out.puts "This project does not seem to need initialization."
|
18
|
+
return
|
19
|
+
end
|
20
|
+
|
21
|
+
out.puts "Initialized directory for shipping."
|
22
|
+
out.puts
|
23
|
+
File.open(config_file, "w") do |f|
|
24
|
+
f.puts "# Experimental release automation. See https://github.com/cornelius/yes_ship_it."
|
25
|
+
if File.exist?(File.join(@path, "lib", "version.rb"))
|
26
|
+
out.puts "It looks like this is is Ruby project."
|
27
|
+
|
28
|
+
f.puts "include:"
|
29
|
+
f.puts " ruby_gem"
|
30
|
+
else
|
31
|
+
out.puts "Couldn't determine type of project, wrote a generic template."
|
32
|
+
|
33
|
+
f.puts "assertions:"
|
34
|
+
f.puts " - release_branch"
|
35
|
+
f.puts " - working_directory"
|
36
|
+
f.puts " - version"
|
37
|
+
f.puts " - change_log"
|
38
|
+
f.puts " - tag"
|
39
|
+
f.puts " - pushed_tag"
|
40
|
+
f.puts " - pushed_code"
|
41
|
+
f.puts " - yes_it_shipped"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
out.puts
|
45
|
+
out.puts "Check the file `yes_ship_it.conf` and adapt it to your needs."
|
46
|
+
out.puts
|
47
|
+
out.puts "Happy shipping!"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module YSI
|
2
|
+
class Plugin
|
3
|
+
attr_accessor :out, :err
|
4
|
+
|
5
|
+
def initialize(path)
|
6
|
+
@plugin_dir = File.join(path, "yes_ship_it", "assertions")
|
7
|
+
|
8
|
+
@out = STDOUT
|
9
|
+
@err = STDERR
|
10
|
+
end
|
11
|
+
|
12
|
+
def load
|
13
|
+
plugin_paths = []
|
14
|
+
if File.exist?(@plugin_dir)
|
15
|
+
plugin_paths = Dir.glob("#{@plugin_dir}/*.rb").sort
|
16
|
+
end
|
17
|
+
|
18
|
+
plugins = {}
|
19
|
+
plugin_paths.each do |plugin_path|
|
20
|
+
plugin_name = File.basename(plugin_path, ".rb")
|
21
|
+
require plugin_path
|
22
|
+
plugins[plugin_name] = YSI::Assertion.class_for_name(plugin_name)
|
23
|
+
end
|
24
|
+
|
25
|
+
plugins
|
26
|
+
end
|
27
|
+
|
28
|
+
def list
|
29
|
+
plugins = load
|
30
|
+
|
31
|
+
if plugins.empty?
|
32
|
+
out.puts "There are no local plugins."
|
33
|
+
out.puts
|
34
|
+
out.puts "Create one with `yes_ship_it plugin init MyAssertion`."
|
35
|
+
out.puts
|
36
|
+
out.puts "Documentation about how to write plugins can be found at"
|
37
|
+
out.puts
|
38
|
+
out.puts " https://github.com/cornelius/yes_ship_it/wiki/plugins"
|
39
|
+
else
|
40
|
+
plugins.each do |plugin_name, plugin_class|
|
41
|
+
out.puts "#{plugin_name}: #{plugin_class.display_name}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def generate(name, display_name)
|
47
|
+
plugin_path = File.join(@plugin_dir, name + ".rb")
|
48
|
+
|
49
|
+
if File.exist?(plugin_path)
|
50
|
+
err.puts "Can't generate plugin. Plugin already exists at `#{plugin_path}`."
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
|
54
|
+
FileUtils.mkdir_p(@plugin_dir)
|
55
|
+
|
56
|
+
File.open(plugin_path, "w") do |f|
|
57
|
+
f.puts "module YSI"
|
58
|
+
f.puts " class #{YSI::Assertion.class_name(name)} < Assertion"
|
59
|
+
f.puts " def self.display_name"
|
60
|
+
f.puts " \"#{display_name}\""
|
61
|
+
f.puts " end"
|
62
|
+
f.puts
|
63
|
+
f.puts " def check"
|
64
|
+
f.puts " end"
|
65
|
+
f.puts
|
66
|
+
f.puts " def assert(executor)"
|
67
|
+
f.puts " \"help me to do it\""
|
68
|
+
f.puts " end"
|
69
|
+
f.puts " end"
|
70
|
+
f.puts "end"
|
71
|
+
end
|
72
|
+
|
73
|
+
out.puts "Generated assertion plugin at `#{plugin_path}`."
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/yes_ship_it.rb
CHANGED
@@ -10,6 +10,10 @@ require_relative "yes_ship_it/assertion.rb"
|
|
10
10
|
require_relative "yes_ship_it/engine.rb"
|
11
11
|
require_relative "yes_ship_it/exceptions.rb"
|
12
12
|
require_relative "yes_ship_it/git.rb"
|
13
|
+
require_relative "yes_ship_it/executor.rb"
|
14
|
+
require_relative "yes_ship_it/dry_executor.rb"
|
15
|
+
require_relative "yes_ship_it/init.rb"
|
16
|
+
require_relative "yes_ship_it/plugin.rb"
|
13
17
|
|
14
18
|
assertions_dir = File.expand_path("../../assertions", __FILE__)
|
15
19
|
Dir[File.join(assertions_dir, "*.rb")].each { |f| require(f) }
|
@@ -0,0 +1 @@
|
|
1
|
+
#define POLKA_VERSION "0.8"
|
@@ -221,6 +221,33 @@ EOT
|
|
221
221
|
file_list = `tar tzf #{release_archive}`.split("\n").sort
|
222
222
|
expect(file_list).to eq(expected_file_list.split("\n").sort)
|
223
223
|
end
|
224
|
+
|
225
|
+
it "loads plugins" do
|
226
|
+
dir = nil
|
227
|
+
given_directory do
|
228
|
+
dir = given_directory "red_herring" do
|
229
|
+
given_file("yes_ship_it.conf", from: "yes_ship_it.plugins.conf")
|
230
|
+
given_directory "yes_ship_it" do
|
231
|
+
given_directory_from_data "assertions", from: "plugins"
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
expected_output = <<EOT
|
237
|
+
Shipping...
|
238
|
+
|
239
|
+
Checking My awesome plugin: fail
|
240
|
+
Checking My other even more awesome plugin: fail
|
241
|
+
|
242
|
+
Dry run: Asserting My awesome plugin: help me to do it
|
243
|
+
Dry run: Asserting My other even more awesome plugin: done
|
244
|
+
|
245
|
+
Did a dry run of shipping red_herring . Nothing was changed.
|
246
|
+
EOT
|
247
|
+
expect(run_command(args: ["--dry-run"],
|
248
|
+
working_directory: File.join(dir))).
|
249
|
+
to exit_with_success(expected_output)
|
250
|
+
end
|
224
251
|
end
|
225
252
|
|
226
253
|
describe "changelog helper" do
|
@@ -250,12 +277,29 @@ EOT
|
|
250
277
|
end
|
251
278
|
|
252
279
|
describe "init" do
|
280
|
+
it "fails if there already is a config" do
|
281
|
+
dir = given_directory do
|
282
|
+
given_dummy_file("yes_ship_it.conf")
|
283
|
+
end
|
284
|
+
|
285
|
+
expected_output = <<EOT
|
286
|
+
There already is a file `yes_ship_it.conf`.
|
287
|
+
|
288
|
+
This project does not seem to need initialization.
|
289
|
+
EOT
|
290
|
+
|
291
|
+
expect(run_command(args: ["init"], working_directory: dir)).
|
292
|
+
to exit_with_success(expected_output)
|
293
|
+
end
|
294
|
+
|
253
295
|
it "initializes directory with generic template" do
|
254
296
|
dir = given_directory
|
255
297
|
|
256
298
|
expected_output = <<EOT
|
257
299
|
Initialized directory for shipping.
|
258
300
|
|
301
|
+
Couldn't determine type of project, wrote a generic template.
|
302
|
+
|
259
303
|
Check the file `yes_ship_it.conf` and adapt it to your needs.
|
260
304
|
|
261
305
|
Happy shipping!
|
@@ -263,10 +307,118 @@ EOT
|
|
263
307
|
|
264
308
|
expect(run_command(args: ["init"], working_directory: dir)).
|
265
309
|
to exit_with_success(expected_output)
|
310
|
+
end
|
266
311
|
|
267
|
-
|
268
|
-
|
269
|
-
)
|
312
|
+
it "initializes directory with specific template" do
|
313
|
+
dir = nil
|
314
|
+
given_directory("init") do
|
315
|
+
dir = given_directory_from_data("ruby", from: "init/ruby" )
|
316
|
+
end
|
317
|
+
|
318
|
+
expected_output = <<EOT
|
319
|
+
Initialized directory for shipping.
|
320
|
+
|
321
|
+
It looks like this is is Ruby project.
|
322
|
+
|
323
|
+
Check the file `yes_ship_it.conf` and adapt it to your needs.
|
324
|
+
|
325
|
+
Happy shipping!
|
326
|
+
EOT
|
327
|
+
|
328
|
+
expect(run_command(args: ["init"], working_directory: dir)).
|
329
|
+
to exit_with_success(expected_output)
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
describe "plugin" do
|
334
|
+
it "fails when no sub command is given" do
|
335
|
+
expect(run_command(args: ["plugin"])).to exit_with_error(1, /Invalid command/)
|
336
|
+
end
|
337
|
+
|
338
|
+
it "fails when invalid sub command is given" do
|
339
|
+
result = run_command(args: ["plugin", "xxx"])
|
340
|
+
expect(result).to exit_with_error(1, /Invalid command/)
|
341
|
+
expect(result.stderr).to match /Usage:/
|
342
|
+
end
|
343
|
+
|
344
|
+
describe "list" do
|
345
|
+
it "shows message when there are no plugins" do
|
346
|
+
dir = given_directory
|
347
|
+
|
348
|
+
expected_output = <<EOT
|
349
|
+
There are no local plugins.
|
350
|
+
|
351
|
+
Create one with `yes_ship_it plugin init MyAssertion`.
|
352
|
+
|
353
|
+
Documentation about how to write plugins can be found at
|
354
|
+
|
355
|
+
https://github.com/cornelius/yes_ship_it/wiki/plugins
|
356
|
+
EOT
|
357
|
+
|
358
|
+
expect(run_command(args: ["plugin", "list"], working_directory: dir)).
|
359
|
+
to exit_with_success(expected_output)
|
360
|
+
end
|
361
|
+
|
362
|
+
it "lists plugins" do
|
363
|
+
dir = given_directory do
|
364
|
+
given_directory "yes_ship_it" do
|
365
|
+
given_directory_from_data "assertions", from: "plugins"
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
expected_output = <<EOT
|
370
|
+
my_other_plugin: My other even more awesome plugin
|
371
|
+
my_plugin: My awesome plugin
|
372
|
+
EOT
|
373
|
+
|
374
|
+
expect(run_command(args: ["plugin", "list"], working_directory: dir)).
|
375
|
+
to exit_with_success(expected_output)
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
describe "generate" do
|
380
|
+
it "fails when arguments are missing" do
|
381
|
+
expected_output = <<EOT
|
382
|
+
Parameters are missing. Use for example
|
383
|
+
|
384
|
+
yes_ship_it plugin generate my_plugin "My plugin"
|
385
|
+
|
386
|
+
to generate a plugin `my_plugin` with a display name of "My plugin".
|
387
|
+
EOT
|
388
|
+
expect(run_command(args: ["plugin", "generate"])).to exit_with_error(1, expected_output)
|
389
|
+
end
|
390
|
+
|
391
|
+
it "fails when plugin already exists" do
|
392
|
+
dir = given_directory do
|
393
|
+
given_directory "yes_ship_it" do
|
394
|
+
given_directory "assertions" do
|
395
|
+
given_dummy_file "my_plugin.rb"
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
plugin_path = File.join(dir, "yes_ship_it", "assertions", "my_plugin.rb")
|
401
|
+
|
402
|
+
expected_output = <<EOT
|
403
|
+
Can't generate plugin. Plugin already exists at `#{plugin_path}`.
|
404
|
+
EOT
|
405
|
+
expect(run_command(args: ["plugin", "generate", "my_plugin", "My Plugin"], working_directory: dir)).
|
406
|
+
to exit_with_error(1, expected_output)
|
407
|
+
end
|
408
|
+
|
409
|
+
it "creates new plugin" do
|
410
|
+
dir = given_directory
|
411
|
+
plugin_path = File.join(dir, "yes_ship_it", "assertions", "my_plugin.rb")
|
412
|
+
|
413
|
+
expected_output = <<EOT
|
414
|
+
Generated assertion plugin at `#{plugin_path}`.
|
415
|
+
EOT
|
416
|
+
expect(run_command(args: ["plugin", "generate", "my_plugin", "My awesome plugin"], working_directory: dir)).
|
417
|
+
to exit_with_success(expected_output)
|
418
|
+
|
419
|
+
expected_code = File.read(given_file("plugins/my_plugin.rb"))
|
420
|
+
expect(File.read(plugin_path)).to eq(expected_code)
|
421
|
+
end
|
270
422
|
end
|
271
423
|
end
|
272
424
|
end
|
data/spec/spec_helper.rb
CHANGED
Binary file
|
Binary file
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe "dry run" do
|
4
|
+
before(:all) do
|
5
|
+
out = StringIO.new
|
6
|
+
@test = Httpotemkin::Test.new(out: out)
|
7
|
+
@test.add_server("rubygems")
|
8
|
+
@test.add_server("api.rubygems")
|
9
|
+
@test.add_server("obs")
|
10
|
+
@test.up
|
11
|
+
end
|
12
|
+
|
13
|
+
after(:all) do
|
14
|
+
@test.down
|
15
|
+
end
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
@client = @test.start_client
|
19
|
+
@client.install_gem_from_spec("yes_ship_it.gemspec")
|
20
|
+
remote_tar = File.expand_path("../data/red_herring-remote.tar.gz", __FILE__)
|
21
|
+
@client.inject_tarball(remote_tar)
|
22
|
+
end
|
23
|
+
|
24
|
+
after(:each) do
|
25
|
+
@test.stop_client
|
26
|
+
end
|
27
|
+
|
28
|
+
it "doesn't do changes" do
|
29
|
+
checkout_tar = File.expand_path("../data/red_herring-checkout-dry-run.tar.gz", __FILE__)
|
30
|
+
@client.inject_tarball(checkout_tar)
|
31
|
+
|
32
|
+
@client.execute(["yes_ship_it.ruby2.1", "--dry-run"], working_directory: "red_herring")
|
33
|
+
|
34
|
+
expected_output = <<EOT
|
35
|
+
Shipping...
|
36
|
+
|
37
|
+
Checking release branch: master
|
38
|
+
Checking working directory: clean
|
39
|
+
Checking version number: 0.0.2
|
40
|
+
Checking change log: CHANGELOG.md
|
41
|
+
Checking tag: fail
|
42
|
+
Checking built gem: fail
|
43
|
+
Checking published gem: fail
|
44
|
+
Checking pushed tag: fail
|
45
|
+
Checking pushed code: fail
|
46
|
+
|
47
|
+
Dry run: Asserting tag: v0.0.2
|
48
|
+
Dry run: Asserting built gem: red_herring-0.0.2.gem
|
49
|
+
Dry run: Asserting published gem: red_herring-0.0.2.gem
|
50
|
+
Dry run: Asserting pushed tag: v0.0.2
|
51
|
+
Dry run: Asserting pushed code: pushed
|
52
|
+
|
53
|
+
Did a dry run of shipping red_herring 0.0.2. Nothing was changed.
|
54
|
+
EOT
|
55
|
+
expect(@client.err).to eq("")
|
56
|
+
expect(@client.out).to eq(expected_output)
|
57
|
+
expect(@client.exit_code).to eq(0)
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe "rpm" do
|
4
|
+
before(:all) do
|
5
|
+
out = StringIO.new
|
6
|
+
@test = Httpotemkin::Test.new(out: out)
|
7
|
+
@test.add_server("rubygems")
|
8
|
+
@test.add_server("api.rubygems")
|
9
|
+
@test.add_server("obs")
|
10
|
+
@test.up
|
11
|
+
end
|
12
|
+
|
13
|
+
after(:all) do
|
14
|
+
@test.down
|
15
|
+
end
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
@client = @test.start_client
|
19
|
+
@client.install_gem_from_spec("yes_ship_it.gemspec")
|
20
|
+
remote_tar = File.expand_path("../data/red_herring-remote.tar.gz", __FILE__)
|
21
|
+
@client.inject_tarball(remote_tar)
|
22
|
+
end
|
23
|
+
|
24
|
+
after(:each) do
|
25
|
+
@test.stop_client
|
26
|
+
end
|
27
|
+
|
28
|
+
it "pushes to obs" do
|
29
|
+
checkout_tar = File.expand_path("../data/red_herring-checkout-rpm.tar.gz", __FILE__)
|
30
|
+
@client.inject_tarball(checkout_tar)
|
31
|
+
|
32
|
+
@client.execute(["yes_ship_it.ruby2.1"], working_directory: "red_herring")
|
33
|
+
|
34
|
+
expected_output = <<EOT
|
35
|
+
Shipping...
|
36
|
+
|
37
|
+
Checking release branch: master
|
38
|
+
Checking working directory: clean
|
39
|
+
Checking version number: 0.0.2
|
40
|
+
Checking change log: CHANGELOG.md
|
41
|
+
Checking tag: fail
|
42
|
+
Checking release archive: fail
|
43
|
+
Checking submitted RPM: fail
|
44
|
+
Checking pushed tag: fail
|
45
|
+
Checking pushed code: fail
|
46
|
+
|
47
|
+
Asserting tag: v0.0.2
|
48
|
+
Asserting release archive: red_herring-0.0.2.tar.gz
|
49
|
+
Asserting submitted RPM: ...
|
50
|
+
Uploading release archive 'red_herring-0.0.2.tar.gz'
|
51
|
+
Uploading spec file 'red_herring.spec'
|
52
|
+
... home:cschum:go/red_herring
|
53
|
+
Asserting pushed tag: v0.0.2
|
54
|
+
Asserting pushed code: pushed
|
55
|
+
|
56
|
+
Shipped red_herring 0.0.2. Hooray!
|
57
|
+
EOT
|
58
|
+
expect(@client.err).to eq("")
|
59
|
+
expect(@client.out).to eq(expected_output)
|
60
|
+
expect(@client.exit_code).to eq(0)
|
61
|
+
end
|
62
|
+
end
|