yes_ship_it 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 166ad586d456c70e04254032cacb88b08137af90
4
- data.tar.gz: 0b544b73f9391fa9eabe47e4d9ab1c86e934e7a6
3
+ metadata.gz: 168ad942fbfdb7207ece3f1fce5986fac3511b43
4
+ data.tar.gz: 57c44bc9c84c57bd10db8b989f886b3a9c596b69
5
5
  SHA512:
6
- metadata.gz: 937111a8dbbfcfae794dbd7b49db9520d5fe16923cff77628bfeb16de21f8a48201245b4167b36241de8b4031918e29a93ddb050fd03328e7a075f8b44276338
7
- data.tar.gz: 1247311f1d7fb9465b8a6a34ae841feb28e8ebe90216466eafa149ac4febcb3023f66743dec4289be37d8dd8aec29e9c2dcd33e65fbcc663da198ee8aba29a4d
6
+ metadata.gz: d36f142bd4848d0187e030f3d881027d140fa8e922fe3d4b91db372e709e8ddc14266157ddecef0c849058af7dd9e71195d5c10ce57de2e2dedfc2c17de1dc9c
7
+ data.tar.gz: 84a63ab61af12d0c76f173daf0c226c1f97cbb13581441499963c2ec99601b7c255b2c5306ae2f99b3a447b1c66d05c63e25f949976d186731e943055b789db8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Change log of yes_ship_it
2
2
 
3
+ ## Version 0.0.5
4
+
5
+ * Handle missing credentials for Rubygems, when pushing gems
6
+ * Handle the case when the origin in your git configuration includes the .git
7
+ extension
8
+ * When pushing to yes_it_shipped use the date is when the release happened not
9
+ when the release was pushed to the site (Issue #9)
10
+ * Add assertion `pushed_code` to check, if the released has been pushed to the
11
+ remote repository
12
+
3
13
  ## Version 0.0.4
4
14
 
5
15
  * Add yes_it_shipped assertion
@@ -27,7 +27,16 @@ module YSI
27
27
 
28
28
  def assert(dry_run: false)
29
29
  if !dry_run
30
- `gem push #{gem_file}`
30
+ begin
31
+ if !File.exist?(File.expand_path("~/.gem/credentials"))
32
+ @error = "You need to log in to Rubygems first by running `gem push #{gem_file}` manually"
33
+ return nil
34
+ end
35
+ Cheetah.run(["gem", "push", gem_file])
36
+ rescue Cheetah::ExecutionFailed => e
37
+ @error = e.message
38
+ return nil
39
+ end
31
40
  end
32
41
  gem_file
33
42
  end
@@ -0,0 +1,24 @@
1
+ module YSI
2
+ class PushedCode < Assertion
3
+ needs "release_branch"
4
+
5
+ def display_name
6
+ "pushed code"
7
+ end
8
+
9
+ def check
10
+ if Git.new.needs_push?
11
+ return nil
12
+ else
13
+ return "up-to-date"
14
+ end
15
+ end
16
+
17
+ def assert(dry_run: false)
18
+ if !dry_run
19
+ Git.new.push
20
+ end
21
+ return "pushed"
22
+ end
23
+ end
24
+ end
@@ -34,7 +34,9 @@ module YSI
34
34
  FileUtils.mkdir_p(File.dirname(release_archive))
35
35
  excludes = [".git", ".gitignore", "yes_ship_it.conf"]
36
36
  exclude_options = excludes.map { |e| "--exclude '#{e}'" }.join(" ")
37
- system("cd #{tmp_dir}; tar czf #{release_archive} #{exclude_options} #{archive_dir}")
37
+ if !system("cd #{tmp_dir}; tar czf #{release_archive} #{exclude_options} #{archive_dir}")
38
+ return nil
39
+ end
38
40
  end
39
41
  end
40
42
  filename
@@ -1,5 +1,7 @@
1
1
  module YSI
2
2
  class YesItShipped < Assertion
3
+ needs "tag"
4
+
3
5
  def display_name
4
6
  "pushed to yes-it-shipped"
5
7
  end
@@ -18,7 +20,7 @@ module YSI
18
20
  begin
19
21
  RestClient.post("https://yes-it-shipped.herokuapp.com/releases",
20
22
  project: engine.project_name, version: engine.version,
21
- release_date_time: Time.now, project_url: engine.project_url,
23
+ release_date_time: engine.tag_date, project_url: engine.project_url,
22
24
  release_url: engine.release_url, ysi_config_url: engine.config_url)
23
25
  rescue RestClient::Exception
24
26
  return nil
@@ -7,4 +7,5 @@ assertions:
7
7
  - built_gem
8
8
  - published_gem
9
9
  - pushed_tag
10
+ - pushed_code
10
11
  - yes_it_shipped
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module YSI
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -147,6 +147,10 @@ module YSI
147
147
  out.print "Asserting #{assertion.display_name}: "
148
148
  success = assertion.assert(dry_run: dry_run)
149
149
  if !success
150
+ if assertion.error
151
+ out.puts "error"
152
+ out.puts " " + assertion.error
153
+ end
150
154
  out.puts
151
155
  out.puts "Ran into an error. Stopping shipping."
152
156
  return 1
@@ -1,11 +1,29 @@
1
1
  module YSI
2
2
  class Git
3
+ def initialize(working_dir = Dir.pwd)
4
+ @working_dir = working_dir
5
+ end
6
+
3
7
  def run_git(args)
4
- `git #{args}`
8
+ Dir.chdir(@working_dir) do
9
+ `git #{args}`
10
+ end
5
11
  end
6
12
 
7
13
  def origin
8
- run_git("remote -v").match(/origin\s+(.*)\s+\(push\)/)[1]
14
+ run_git("remote -v").match(/origin\s+(.*?)(\.git)?\s+\(push\)/)[1]
15
+ end
16
+
17
+ 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")
21
+
22
+ remote_master == base && local_master != remote_master
23
+ end
24
+
25
+ def push
26
+ `git push`
9
27
  end
10
28
  end
11
29
  end
data/lib/yes_ship_it.rb CHANGED
@@ -4,6 +4,7 @@ require "optparse"
4
4
  require "inifile"
5
5
  require "rexml/document"
6
6
  require "erb"
7
+ require "cheetah"
7
8
 
8
9
  require_relative "yes_ship_it/assertion.rb"
9
10
  require_relative "yes_ship_it/engine.rb"
Binary file
Binary file
@@ -164,7 +164,8 @@ Checking built gem: error
164
164
  I need a gemspec: test_project.gemspec
165
165
  Checking published gem: skip (because dependency errored)
166
166
  Checking pushed tag: skip (because dependency errored)
167
- Checking pushed to yes-it-shipped: fail
167
+ Checking pushed code: skip (because dependency errored)
168
+ Checking pushed to yes-it-shipped: skip (because dependency errored)
168
169
 
169
170
  Couldn't ship test_project. Help me.
170
171
  EOT
@@ -1,26 +1,38 @@
1
1
  require_relative "spec_helper"
2
2
 
3
3
  describe "ship ruby gem" do
4
- it "builds gem" do
5
- out = double
6
- allow(out).to receive(:puts)
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
7
12
 
8
- test = Httpotemkin::Test.new(out: out)
9
- test.add_server("rubygems")
10
- test.add_server("api.rubygems")
11
- test.add_server("obs")
13
+ after(:all) do
14
+ @test.down
15
+ end
12
16
 
13
- test.run do |client|
14
- client.install_gem_from_spec("yes_ship_it.gemspec")
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
15
27
 
16
- remote_tar = File.expand_path("../data/red_herring-remote.tar.gz", __FILE__)
28
+ context "with existing credentials" do
29
+ it "builds gem" do
17
30
  checkout_tar = File.expand_path("../data/red_herring-checkout-build.tar.gz", __FILE__)
18
- client.inject_tarball(remote_tar)
19
- client.inject_tarball(checkout_tar)
31
+ @client.inject_tarball(checkout_tar)
20
32
 
21
- client.execute(["yes_ship_it.ruby2.1"], working_directory: "red_herring")
33
+ @client.execute(["yes_ship_it.ruby2.1"], working_directory: "red_herring")
22
34
 
23
- expect(client.exit_code).to eq(0)
35
+ expect(@client.exit_code).to eq(0)
24
36
 
25
37
  expected_output = <<EOT
26
38
  Shipping...
@@ -34,32 +46,18 @@ Asserting release archive: red_herring-0.0.2.tar.gz
34
46
 
35
47
  Shipped red_herring 0.0.2. Hooray!
36
48
  EOT
37
- expect(client.out).to eq(expected_output)
49
+ expect(@client.out).to eq(expected_output)
38
50
 
39
- expect(client.err.empty?).to be(true)
51
+ expect(@client.err).to eq("")
40
52
  end
41
- end
42
-
43
- it "pushes gem if it isn't pushed yet" do
44
- out = double
45
- allow(out).to receive(:puts)
46
-
47
- test = Httpotemkin::Test.new(out: out)
48
- test.add_server("rubygems")
49
- test.add_server("api.rubygems")
50
- test.add_server("obs")
51
53
 
52
- test.run do |client|
53
- client.install_gem_from_spec("yes_ship_it.gemspec")
54
-
55
- remote_tar = File.expand_path("../data/red_herring-remote.tar.gz", __FILE__)
54
+ it "pushes gem if it isn't pushed yet" do
56
55
  checkout_tar = File.expand_path("../data/red_herring-checkout-push.tar.gz", __FILE__)
57
- client.inject_tarball(remote_tar)
58
- client.inject_tarball(checkout_tar)
56
+ @client.inject_tarball(checkout_tar)
59
57
 
60
- client.execute(["yes_ship_it.ruby2.1"], working_directory: "red_herring")
58
+ @client.execute(["yes_ship_it.ruby2.1"], working_directory: "red_herring")
61
59
 
62
- expect(client.exit_code).to eq(0)
60
+ expect(@client.exit_code).to eq(0)
63
61
 
64
62
  expected_output = <<EOT
65
63
  Shipping...
@@ -75,32 +73,19 @@ Asserting published gem: red_herring-0.0.2.gem
75
73
 
76
74
  Shipped red_herring 0.0.2. Hooray!
77
75
  EOT
78
- expect(client.out).to eq(expected_output)
79
76
 
80
- expect(client.err.empty?).to be(true)
81
- end
82
- end
83
-
84
- it "doesn't push gem if it already is pushed" do
85
- out = double
86
- allow(out).to receive(:puts)
87
-
88
- test = Httpotemkin::Test.new(out: out)
89
- test.add_server("rubygems")
90
- test.add_server("api.rubygems")
91
- test.add_server("obs")
77
+ expect(@client.out).to eq(expected_output)
92
78
 
93
- test.run do |client|
94
- client.install_gem_from_spec("yes_ship_it.gemspec")
79
+ expect(@client.err).to eq("")
80
+ end
95
81
 
96
- remote_tar = File.expand_path("../data/red_herring-remote.tar.gz", __FILE__)
82
+ it "doesn't push gem if it already is pushed" do
97
83
  checkout_tar = File.expand_path("../data/red_herring-checkout-not-push.tar.gz", __FILE__)
98
- client.inject_tarball(remote_tar)
99
- client.inject_tarball(checkout_tar)
84
+ @client.inject_tarball(checkout_tar)
100
85
 
101
- client.execute(["yes_ship_it.ruby2.1"], working_directory: "red_herring")
86
+ @client.execute(["yes_ship_it.ruby2.1"], working_directory: "red_herring")
102
87
 
103
- expect(client.exit_code).to eq(0)
88
+ expect(@client.exit_code).to eq(0)
104
89
 
105
90
  expected_output = <<EOT
106
91
  Shipping...
@@ -111,9 +96,46 @@ Checking published gem: 0.0.1
111
96
 
112
97
  red_herring 0.0.1 already shipped
113
98
  EOT
114
- expect(client.out).to eq(expected_output)
99
+ expect(@client.out).to eq(expected_output)
115
100
 
116
- expect(client.err.empty?).to be(true)
101
+ expect(@client.err.empty?).to be(true)
102
+ end
103
+ end
104
+
105
+ context "without existing credentials" do
106
+ before(:each) do
107
+ @client.execute(["mv", "/root/.gem/credentials", "/tmp"])
108
+
109
+ checkout_tar = File.expand_path("../data/red_herring-checkout-push.tar.gz", __FILE__)
110
+ @client.inject_tarball(checkout_tar)
111
+ end
112
+
113
+ after(:each) do
114
+ @client.execute(["mv", "/tmp/credentials", "/root/.gem/"])
115
+ end
116
+
117
+ it "tells how to login" do
118
+ @client.execute(["yes_ship_it.ruby2.1"], working_directory: "red_herring")
119
+
120
+ expect(@client.exit_code).to eq(1)
121
+
122
+ expected_output = <<EOT
123
+ Shipping...
124
+
125
+ Checking version number: 0.0.2
126
+ Checking tag: fail
127
+ Checking built gem: fail
128
+ Checking published gem: fail
129
+
130
+ Asserting tag: v0.0.2
131
+ Asserting built gem: red_herring-0.0.2.gem
132
+ Asserting published gem: error
133
+ You need to log in to Rubygems first by running `gem push red_herring-0.0.2.gem` manually
134
+
135
+ Ran into an error. Stopping shipping.
136
+ EOT
137
+ expect(@client.out).to eq(expected_output)
138
+ expect(@client.err.empty?).to be(true)
117
139
  end
118
140
  end
119
141
  end
@@ -0,0 +1,14 @@
1
+ require_relative "../spec_helper.rb"
2
+
3
+ describe YSI::PublishedGem do
4
+ describe "#assert" do
5
+ it "returns nil if there is an error" do
6
+ engine = YSI::Engine
7
+ allow(engine).to receive(:project_name).and_return("IdontExist")
8
+ allow(engine).to receive(:version).and_return("0.0")
9
+ assertion = YSI::PublishedGem.new(YSI::Engine)
10
+
11
+ expect(assertion.assert).to be(nil)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ require_relative "../spec_helper"
2
+
3
+ include GivenFilesystemSpecHelpers
4
+
5
+ describe YSI::PushedCode do
6
+ use_given_filesystem
7
+
8
+ it "pushes code" do
9
+ expect_any_instance_of(YSI::Git).to receive(:push).and_return("pushed")
10
+ dir = given_directory
11
+ setup_test_git_repo("007", dir)
12
+
13
+ engine = YSI::Engine.new
14
+ assertion = YSI::PushedCode.new(engine)
15
+ Dir.chdir(File.join(dir, "red_herring")) do
16
+ expect(assertion.check).to be(nil)
17
+ expect(assertion.assert).to eq "pushed"
18
+ end
19
+ end
20
+ end
@@ -42,7 +42,6 @@ EOT
42
42
 
43
43
  describe "#assert" do
44
44
  it "pushes release" do
45
- allow(Time).to receive(:now).and_return(Time.parse("20151208T141655+0100"))
46
45
  stub_request(:post, "https://yes-it-shipped.herokuapp.com/releases").
47
46
  with(
48
47
  :body => {
@@ -64,6 +63,7 @@ EOT
64
63
  engine = YSI::Engine.new
65
64
  allow(engine).to receive(:project_name).and_return("dummy")
66
65
  engine.version = "1.1.1"
66
+ engine.tag_date = Time.parse("20151208T141655+0100")
67
67
 
68
68
  assertion = YSI::YesItShipped.new(engine)
69
69
 
@@ -1,13 +1,46 @@
1
1
  require_relative "spec_helper"
2
2
 
3
+ include GivenFilesystemSpecHelpers
4
+
3
5
  describe YSI::Git do
4
- it "#origin" do
5
- allow(subject).to receive(:run_git).with("remote -v").and_return(<<EOT
6
+ describe "#origin" do
7
+
8
+ it "grabs the url without the extension" do
9
+ allow(subject).to receive(:run_git).with("remote -v").and_return(<<EOT
6
10
  origin git@github.com:cornelius/red_herring (fetch)
7
11
  origin git@github.com:cornelius/red_herring (push)
8
12
  EOT
9
- )
13
+ )
14
+ expect(subject.origin).to eq("git@github.com:cornelius/red_herring")
15
+ end
16
+
17
+ it "grabs the url with the extension" do
18
+ allow(subject).to receive(:run_git).with("remote -v").and_return(<<EOT
19
+ origin git@github.com:cornelius/red_herring.git (fetch)
20
+ origin git@github.com:cornelius/red_herring.git (push)
21
+ EOT
22
+ )
23
+ expect(subject.origin).to eq("git@github.com:cornelius/red_herring")
24
+ end
25
+ end
26
+
27
+ describe "#needs_push?" do
28
+ use_given_filesystem
29
+
30
+ it "returns true if local changes are not in remote branch" do
31
+ dir = given_directory
32
+ setup_test_git_repo("007", dir)
33
+ git = YSI::Git.new(File.join(dir, "red_herring"))
34
+
35
+ expect(git.needs_push?).to be(true)
36
+ end
37
+
38
+ it "returns false if local changes are in remote branch" do
39
+ dir = given_directory
40
+ setup_test_git_repo("008", dir)
41
+ git = YSI::Git.new(File.join(dir, "red_herring"))
10
42
 
11
- expect(subject.origin).to eq("git@github.com:cornelius/red_herring")
43
+ expect(git.needs_push?).to be(false)
44
+ end
12
45
  end
13
46
  end
data/yes_ship_it.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.add_runtime_dependency "inifile"
19
19
  s.add_runtime_dependency "rest-client"
20
+ s.add_runtime_dependency "cheetah"
20
21
 
21
22
  s.add_development_dependency "rspec", "~>3"
22
23
  s.add_development_dependency "given_filesystem"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yes_ship_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cornelius Schumacher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-08 00:00:00.000000000 Z
11
+ date: 2015-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inifile
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cheetah
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -126,6 +140,7 @@ files:
126
140
  - assertions/built_gem.rb
127
141
  - assertions/change_log.rb
128
142
  - assertions/published_gem.rb
143
+ - assertions/pushed_code.rb
129
144
  - assertions/pushed_tag.rb
130
145
  - assertions/release_archive.rb
131
146
  - assertions/release_branch.rb
@@ -151,6 +166,8 @@ files:
151
166
  - spec/data/red_herring-004.tar.gz
152
167
  - spec/data/red_herring-005.tar.gz
153
168
  - spec/data/red_herring-006.tar.gz
169
+ - spec/data/red_herring-007.tar.gz
170
+ - spec/data/red_herring-008.tar.gz
154
171
  - spec/data/version/version.go
155
172
  - spec/data/version/version.rb
156
173
  - spec/data/yes_ship_it.conf
@@ -167,6 +184,8 @@ files:
167
184
  - spec/system/spec_helper.rb
168
185
  - spec/unit/assertion_spec.rb
169
186
  - spec/unit/assertions/change_log_spec.rb
187
+ - spec/unit/assertions/published_gem_spec.rb
188
+ - spec/unit/assertions/pushed_code_spec.rb
170
189
  - spec/unit/assertions/pushed_tag_spec.rb
171
190
  - spec/unit/assertions/release_archive_spec.rb
172
191
  - spec/unit/assertions/release_branch_spec.rb