packaging 0.108.2 → 0.109.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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -2
  3. data/lib/packaging/artifactory.rb +15 -10
  4. data/lib/packaging/config/validations.rb +1 -1
  5. data/lib/packaging/config.rb +5 -5
  6. data/lib/packaging/deb/repo.rb +4 -4
  7. data/lib/packaging/nuget.rb +1 -1
  8. data/lib/packaging/paths.rb +4 -3
  9. data/lib/packaging/sign/msi.rb +6 -8
  10. data/lib/packaging/util/execution.rb +1 -1
  11. data/lib/packaging/util/ezbake.rb +1 -1
  12. data/lib/packaging/util/file.rb +4 -6
  13. data/lib/packaging/util/net.rb +8 -12
  14. data/lib/packaging/util/ship.rb +17 -7
  15. data/lib/packaging/util/tool.rb +1 -1
  16. data/lib/packaging/util/version.rb +7 -5
  17. data/spec/lib/packaging/config_spec.rb +300 -279
  18. data/spec/lib/packaging/deb/repo_spec.rb +138 -76
  19. data/spec/lib/packaging/deb_spec.rb +28 -25
  20. data/spec/lib/packaging/repo_spec.rb +52 -31
  21. data/spec/lib/packaging/rpm/repo_spec.rb +18 -37
  22. data/spec/lib/packaging/sign_spec.rb +22 -43
  23. data/spec/lib/packaging/tar_spec.rb +48 -44
  24. data/spec/lib/packaging/util/execution_spec.rb +32 -32
  25. data/spec/lib/packaging/util/file_spec.rb +112 -75
  26. data/spec/lib/packaging/util/gpg_spec.rb +24 -19
  27. data/spec/lib/packaging/util/jenkins_spec.rb +79 -48
  28. data/spec/lib/packaging/util/misc_spec.rb +13 -8
  29. data/spec/lib/packaging/util/net_spec.rb +193 -152
  30. data/spec/lib/packaging/util/rake_utils_spec.rb +24 -18
  31. data/spec/lib/packaging_spec.rb +7 -9
  32. data/tasks/apple.rake +7 -8
  33. data/tasks/deb.rake +1 -1
  34. data/tasks/fetch.rake +2 -2
  35. data/tasks/mock.rake +3 -3
  36. data/tasks/nightly_repos.rake +11 -9
  37. data/tasks/rpm.rake +2 -3
  38. data/tasks/ship.rake +4 -2
  39. data/tasks/sign.rake +8 -10
  40. data/tasks/z_data_dump.rake +3 -3
  41. metadata +46 -33
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Pkg::Util::Gpg" do
4
- let(:gpg) { "/local/bin/gpg" }
5
- let(:keychain) { "/usr/local/bin/keychain" }
6
- let(:gpg_key) { "abcd1234" }
7
- let(:target_file) { "/tmp/file" }
3
+ describe 'Pkg::Util::Gpg' do
4
+ let(:gpg) { '/local/bin/gpg' }
5
+ let(:keychain) { '/usr/local/bin/keychain' }
6
+ let(:gpg_key) { 'abcd1234' }
7
+ let(:target_file) { '/tmp/file' }
8
8
 
9
9
  before(:each) do
10
10
  reset_env(['RPM_GPG_AGENT'])
@@ -12,36 +12,37 @@ describe "Pkg::Util::Gpg" do
12
12
  end
13
13
 
14
14
  describe '#key' do
15
- it "fails if Pkg::Config.gpg_key isn't set" do
15
+ it 'fails if Pkg::Config.gpg_key isn\'t set' do
16
16
  allow(Pkg::Config).to receive(:gpg_key).and_return(nil)
17
17
  expect { Pkg::Util::Gpg.key }.to raise_error(RuntimeError)
18
18
  end
19
- it "fails if Pkg::Config.gpg_key is an empty string" do
19
+ it 'fails if Pkg::Config.gpg_key is an empty string' do
20
20
  allow(Pkg::Config).to receive(:gpg_key).and_return('')
21
21
  expect { Pkg::Util::Gpg.key }.to raise_error(RuntimeError)
22
22
  end
23
23
  end
24
24
 
25
25
  describe '#kill_keychain' do
26
- it "doesn't reload the keychain if already loaded" do
26
+ it 'doesn\'t reload the keychain if already loaded' do
27
27
  Pkg::Util::Gpg.instance_variable_set("@keychain_loaded", true)
28
- Pkg::Util::Gpg.should_receive(:kill_keychain).never
29
- Pkg::Util::Gpg.should_receive(:start_keychain).never
28
+
29
+ expect(Pkg::Util::Gpg).not_to receive(:kill_keychain)
30
+ expect(Pkg::Util::Gpg).not_to receive(:start_keychain)
30
31
  Pkg::Util::Gpg.load_keychain
31
32
  Pkg::Util::Gpg.instance_variable_set("@keychain_loaded", nil)
32
33
  end
33
34
 
34
35
  it "doesn't reload the keychain if ENV['RPM_GPG_AGENT'] is set" do
35
36
  ENV['RPM_GPG_AGENT'] = 'blerg'
36
- Pkg::Util::Gpg.should_receive(:kill_keychain).never
37
- Pkg::Util::Gpg.should_receive(:start_keychain).never
37
+ expect(Pkg::Util::Gpg).not_to receive(:kill_keychain)
38
+ expect(Pkg::Util::Gpg).not_to receive(:start_keychain)
38
39
  Pkg::Util::Gpg.load_keychain
39
40
  end
40
41
 
41
42
  it 'kills and starts the keychain if not loaded already' do
42
43
  Pkg::Util::Gpg.instance_variable_set("@keychain_loaded", nil)
43
- Pkg::Util::Gpg.should_receive(:kill_keychain).once
44
- Pkg::Util::Gpg.should_receive(:start_keychain).once
44
+ expect(Pkg::Util::Gpg).to receive(:kill_keychain).once
45
+ expect(Pkg::Util::Gpg).to receive(:start_keychain).once
45
46
  Pkg::Util::Gpg.load_keychain
46
47
  end
47
48
  end
@@ -49,15 +50,19 @@ describe "Pkg::Util::Gpg" do
49
50
  describe '#sign_file' do
50
51
  it 'adds special flags if RPM_GPG_AGENT is set' do
51
52
  ENV['RPM_GPG_AGENT'] = 'blerg'
52
- additional_flags = "--no-tty --use-agent"
53
- Pkg::Util::Tool.should_receive(:find_tool).with('gpg').and_return(gpg)
54
- Pkg::Util::Execution.should_receive(:capture3).with("#{gpg}\s#{additional_flags}\s--armor --detach-sign -u #{gpg_key} #{target_file}")
53
+ additional_flags = '--no-tty --use-agent'
54
+ expect(Pkg::Util::Tool).to receive(:find_tool).with('gpg').and_return(gpg)
55
+ expect(Pkg::Util::Execution)
56
+ .to receive(:capture3)
57
+ .with("#{gpg}\s#{additional_flags}\s--armor --detach-sign -u #{gpg_key} #{target_file}")
55
58
  Pkg::Util::Gpg.sign_file(target_file)
56
59
  end
57
60
 
58
61
  it 'signs without extra flags when RPM_GPG_AGENT is not set' do
59
- Pkg::Util::Tool.should_receive(:find_tool).with('gpg').and_return(gpg)
60
- Pkg::Util::Execution.should_receive(:capture3).with("#{gpg}\s\s--armor --detach-sign -u #{gpg_key} #{target_file}")
62
+ expect(Pkg::Util::Tool).to receive(:find_tool).with('gpg').and_return(gpg)
63
+ expect(Pkg::Util::Execution)
64
+ .to receive(:capture3)
65
+ .with("#{gpg}\s\s--armor --detach-sign -u #{gpg_key} #{target_file}")
61
66
  Pkg::Util::Gpg.sign_file(target_file)
62
67
  end
63
68
  end
@@ -1,9 +1,10 @@
1
1
  # -*- ruby -*-
2
2
  require 'spec_helper'
3
+ require 'json'
3
4
 
4
5
  describe Pkg::Util::Jenkins do
5
- let(:build_host) {"Jenkins-foo"}
6
- let(:name) {"job-foo"}
6
+ let(:build_host) { 'Jenkins-foo' }
7
+ let(:name) { 'job-foo' }
7
8
  around do |example|
8
9
  old_build_host = Pkg::Config.jenkins_build_host
9
10
  Pkg::Config.jenkins_build_host = build_host
@@ -11,51 +12,77 @@ describe Pkg::Util::Jenkins do
11
12
  Pkg::Config.jenkins_build_host = old_build_host
12
13
  end
13
14
 
14
- describe "#create_jenkins_job" do
15
- let(:xml_file) {"bar.xml"}
15
+ describe '#create_jenkins_job' do
16
+ let(:xml_file) { 'bar.xml' }
16
17
 
17
- it "should call curl_form_data with the correct arguments" do
18
- Pkg::Util::Net.should_receive(:curl_form_data).with("http://#{build_host}/createItem?name=#{name}", ["-H", '"Content-Type: application/xml"', "--data-binary", "@#{xml_file}"])
18
+ it 'should call curl_form_data with the correct arguments' do
19
+ expect(Pkg::Util::Net)
20
+ .to receive(:curl_form_data)
21
+ .with("http://#{build_host}/createItem?name=#{name}",
22
+ ['-H', '"Content-Type: application/xml"',
23
+ '--data-binary',
24
+ "@#{xml_file}"])
19
25
  Pkg::Util::Jenkins.create_jenkins_job(name, xml_file)
20
26
  end
21
27
  end
22
28
 
23
- describe "#jenkins_job_exists?" do
24
-
25
- it "should call curl_form_data with correct arguments" do
26
- Pkg::Util::Net.should_receive(:curl_form_data).with("http://#{build_host}/job/#{name}/config.xml", ["--silent", "--fail"], :quiet => true).and_return(['output', 0])
27
- Pkg::Util::Execution.should_receive(:success?).and_return(true)
29
+ describe '#jenkins_job_exists?' do
30
+ it 'should call curl_form_data with correct arguments' do
31
+ expect(Pkg::Util::Net)
32
+ .to receive(:curl_form_data)
33
+ .with("http://#{build_host}/job/#{name}/config.xml",
34
+ ['--silent', '--fail'],
35
+ quiet: true)
36
+ .and_return(['output', 0])
37
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(true)
28
38
  Pkg::Util::Jenkins.jenkins_job_exists?(name)
29
39
  end
30
40
 
31
- it "should return false on job not existing" do
32
- Pkg::Util::Net.should_receive(:curl_form_data).with("http://#{build_host}/job/#{name}/config.xml", ["--silent", "--fail"], :quiet => true).and_return(['output', 1])
33
- Pkg::Util::Execution.should_receive(:success?).and_return(false)
34
- Pkg::Util::Jenkins.jenkins_job_exists?(name).should be_false
41
+ it 'should return false on job not existing' do
42
+ expect(Pkg::Util::Net)
43
+ .to receive(:curl_form_data)
44
+ .with("http://#{build_host}/job/#{name}/config.xml",
45
+ ['--silent', '--fail'],
46
+ quiet: true)
47
+ .and_return(['output', 1])
48
+ expect(Pkg::Util::Execution)
49
+ .to receive(:success?)
50
+ .and_return(false)
51
+ expect(Pkg::Util::Jenkins.jenkins_job_exists?(name)).to be false
35
52
  end
36
53
 
37
- it "should return false if curl_form_data raised a runtime error" do
38
- Pkg::Util::Net.should_receive(:curl_form_data).with("http://#{build_host}/job/#{name}/config.xml", ["--silent", "--fail"], :quiet => true).and_return(false)
39
- Pkg::Util::Jenkins.jenkins_job_exists?(name).should be_false
54
+ it 'should return false if curl_form_data raised a runtime error' do
55
+ expect(Pkg::Util::Net)
56
+ .to receive(:curl_form_data)
57
+ .with("http://#{build_host}/job/#{name}/config.xml",
58
+ ['--silent', '--fail'],
59
+ quiet: true)
60
+ .and_return(false)
61
+ expect(Pkg::Util::Jenkins.jenkins_job_exists?(name)).to be false
40
62
  end
41
63
 
42
- it "should return true when job exists" do
43
- Pkg::Util::Net.should_receive(:curl_form_data).with("http://#{build_host}/job/#{name}/config.xml", ["--silent", "--fail"], :quiet => true).and_return(['output', 0])
44
- Pkg::Util::Execution.should_receive(:success?).and_return(true)
45
- Pkg::Util::Jenkins.jenkins_job_exists?(name).should be_true
64
+ it 'should return true when job exists' do
65
+ expect(Pkg::Util::Net)
66
+ .to receive(:curl_form_data)
67
+ .with("http://#{build_host}/job/#{name}/config.xml",
68
+ ['--silent', '--fail'],
69
+ quiet: true)
70
+ .and_return(['output', 0])
71
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(true)
72
+ expect(Pkg::Util::Jenkins.jenkins_job_exists?(name)).to be true
46
73
  end
47
74
  end
48
75
 
49
76
  describe '#poll_jenkins_job' do
50
- let(:job_url) { "http://cat.meow/" }
77
+ let(:job_url) { 'http://cat.meow' }
51
78
  let(:build_url) { "#{job_url}/1" }
52
- let(:result) { "SUCCESS" }
53
- let(:job_hash) { {'lastBuild' => { 'url' => build_url } }}
54
- let(:build_hash) { {'result' => result, 'building' => false } }
79
+ let(:result) { 'SUCCESS' }
80
+ let(:job_hash) { { 'lastBuild' => { 'url' => build_url } } }
81
+ let(:build_hash) { { 'result' => result, 'building' => false } }
55
82
 
56
83
  before :each do
57
- subject.stub(:get_jenkins_info).with(job_url).and_return(job_hash)
58
- subject.stub(:wait_for_build).with(build_url).and_return(build_hash)
84
+ allow(subject).to receive(:get_jenkins_info).with(job_url).and_return(job_hash)
85
+ allow(subject).to receive(:wait_for_build).with(build_url).and_return(build_hash)
59
86
  end
60
87
 
61
88
  context "when polling the given url" do
@@ -66,47 +93,51 @@ describe Pkg::Util::Jenkins do
66
93
  end
67
94
 
68
95
  describe '#wait_for_build' do
69
- let(:job_url) { "http://cat.meow/" }
96
+ let(:job_url) { 'http://cat.meow' }
70
97
  let(:build_url) { "#{job_url}/1" }
71
- let(:build_hash) { {'building' => false } }
98
+ let(:build_hash) { { 'building' => false } }
72
99
 
73
100
  context "when waiting for the given build to finish" do
74
101
  it "return the resulting build_hash when build completes successfully" do
75
- subject.should_receive(:get_jenkins_info).with(job_url).and_return(build_hash)
102
+ expect(subject).to receive(:get_jenkins_info).with(job_url).and_return(build_hash)
76
103
  subject.wait_for_build(job_url)
77
104
  end
78
105
  end
79
106
  end
80
107
 
81
108
  describe '#get_jenkins_info' do
82
- let(:url) { "http://cat.meow/" }
109
+ let(:url) { 'http://cat.meow' }
83
110
  let(:uri) { URI(url) }
84
111
  let(:response) { double }
85
- let(:valid_json) { "{\"employees\":[
86
- {\"firstName\":\"John\", \"lastName\":\"Doe\"},
87
- {\"firstName\":\"Anna\", \"lastName\":\"Smith\"},
88
- {\"firstName\":\"Peter\", \"lastName\":\"Jones\"} ]}" }
112
+ let(:valid_json) do
113
+ {
114
+ 'employees' => [
115
+ { 'firstName' => 'John', 'lastName' => 'Doe' },
116
+ { 'firstName' => 'Anna', 'lastName' => 'Smith' },
117
+ { 'firstName' => 'Peter', 'lastName' => 'Jones' }
118
+ ]
119
+ }.to_json
120
+ end
89
121
 
90
122
  before :each do
91
- response.stub(:body).and_return( valid_json )
92
- response.stub(:code).and_return( '200' )
93
- Pkg::Util::Jenkins.should_receive(:URI).and_return(uri)
123
+ allow(response).to receive(:body).and_return(valid_json)
124
+ allow(response).to receive(:code).and_return('200')
125
+ expect(Pkg::Util::Jenkins).to receive(:URI).and_return(uri)
94
126
  end
95
127
 
96
- context "when making HTTP GET request to given url" do
97
- it "should return Hash of JSON contents when response is non-error" do
98
- Net::HTTP.should_receive(:get_response).with(uri).and_return(response)
128
+ context 'when making HTTP GET request to given url' do
129
+ it 'should return Hash of JSON contents when response is non-error' do
130
+ expect(Net::HTTP).to receive(:get_response).with(uri).and_return(response)
99
131
  subject.get_jenkins_info(url)
100
132
  end
101
133
 
102
- it "should raise Runtime error when response is error" do
103
- response.stub(:code).and_return( '400' )
104
- Net::HTTP.should_receive(:get_response).with(uri).and_return(response)
105
- expect{
134
+ it 'should raise Runtime error when response is error' do
135
+ allow(response).to receive(:code).and_return('400')
136
+ expect(Net::HTTP).to receive(:get_response).with(uri).and_return(response)
137
+ expect do
106
138
  subject.get_jenkins_info(url)
107
- }.to raise_error(Exception, /Unable to query .*, please check that it is valid./)
139
+ end.to raise_error(Exception, /Unable to query .*, please check that it is valid./)
108
140
  end
109
141
  end
110
142
  end
111
-
112
143
  end
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe 'Pkg::Util::Misc' do
5
- context "#search_and_replace" do
5
+ context '#search_and_replace' do
6
6
  let(:orig_string) { "#!/bin/bash\necho '__REPO_NAME__'" }
7
7
  let(:updated_string) { "#!/bin/bash\necho 'abcdefg'" }
8
8
  let(:good_replacements) do
@@ -13,19 +13,24 @@ describe 'Pkg::Util::Misc' do
13
13
  end
14
14
 
15
15
  it 'replaces the token with the Pkg::Config variable' do
16
- Pkg::Config.config_from_hash({:project => "foo", :repo_name => 'abcdefg'})
17
- Pkg::Util::Misc.search_and_replace(orig_string, good_replacements).should eq(updated_string)
16
+ Pkg::Config.config_from_hash({ project: 'foo', repo_name: 'abcdefg' })
17
+ expect(Pkg::Util::Misc.search_and_replace(orig_string, good_replacements))
18
+ .to eq(updated_string)
18
19
  end
19
20
 
20
21
  it 'does no replacement if the Pkg::Config variable is not set' do
21
- Pkg::Config.config_from_hash({:project => 'foo',})
22
- Pkg::Util::Misc.search_and_replace(orig_string, good_replacements).should eq(orig_string)
22
+ Pkg::Config.config_from_hash({ project: 'foo' })
23
+ expect(Pkg::Util::Misc.search_and_replace(orig_string, good_replacements))
24
+ .to eq(orig_string)
23
25
  end
24
26
 
25
27
  it 'warns and continues if the Pkg::Config variable is unknown to packaging' do
26
- Pkg::Config.config_from_hash({:project => 'foo',})
27
- Pkg::Util::Misc.should_receive(:warn).with("replacement value for '#{warn_replacements.keys.first}' probably shouldn't be nil")
28
- Pkg::Util::Misc.search_and_replace(orig_string, warn_replacements).should eq(orig_string)
28
+ Pkg::Config.config_from_hash({ project: 'foo' })
29
+ expect(Pkg::Util::Misc)
30
+ .to receive(:warn)
31
+ .with("replacement value for '#{warn_replacements.keys.first}' probably shouldn't be nil")
32
+ expect(Pkg::Util::Misc.search_and_replace(orig_string, warn_replacements))
33
+ .to eq(orig_string)
29
34
  end
30
35
  end
31
36
  end