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,15 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Pkg::Deb::Repo" do
4
- let(:wget) { "/opt/tools/bin/wget" }
5
- let(:builds_server) { "saturn.puppetlabs.net" }
6
- let(:project) { "deb_repos" }
7
- let(:ref) { "1234abcd" }
3
+ describe 'Pkg::Deb::Repo' do
4
+ let(:wget) { '/opt/tools/bin/wget' }
5
+ let(:builds_server) { 'saturn.puppetlabs.net' }
6
+ let(:project) { 'deb_repos' }
7
+ let(:ref) { '1234abcd' }
8
8
  let(:base_url) { "http://#{builds_server}/#{project}/#{ref}" }
9
9
  let(:cows) { ["bionic", "focal", "buster", ""] }
10
- let(:wget_results) { cows.map {|cow| "#{base_url}/repos/apt/#{cow}" }.join("\n") }
10
+ let(:wget_results) { cows.map { |cow| "#{base_url}/repos/apt/#{cow}" }.join("\n") }
11
11
  let(:wget_garbage) { "\n and an index\nhttp://somethingelse.com/robots" }
12
- let(:repo_configs) { cows.reject {|cow| cow.empty?}.map {|dist| "pkg/repo_configs/deb/pl-#{project}-#{ref}-#{dist}.list" } }
12
+ let(:repo_configs) do
13
+ cows.reject(&:empty?).map { |dist| "pkg/repo_configs/deb/pl-#{project}-#{ref}-#{dist}.list" }
14
+ end
13
15
 
14
16
  # Setup and tear down for the tests
15
17
  around do |example|
@@ -29,126 +31,186 @@ describe "Pkg::Deb::Repo" do
29
31
  Pkg::Config.jenkins_repo_path = orig_repo_path
30
32
  end
31
33
 
32
- describe "#generate_repo_configs" do
33
- it "fails if wget isn't available" do
34
- Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_raise(RuntimeError)
35
- expect {Pkg::Deb::Repo.generate_repo_configs}.to raise_error(RuntimeError)
34
+ describe '#generate_repo_configs' do
35
+ it 'fails if wget isn\'t available' do
36
+ expect(Pkg::Util::Tool)
37
+ .to receive(:find_tool)
38
+ .with('wget', { required: true })
39
+ .and_raise(RuntimeError)
40
+ expect { Pkg::Deb::Repo.generate_repo_configs }.to raise_error(RuntimeError)
36
41
  end
37
42
 
38
- it "warns if there are no deb repos available for the build" do
39
- Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget)
40
- Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 1 --no-parent #{base_url}/repos/apt/ 2>&1").and_raise(RuntimeError)
41
- Pkg::Deb::Repo.should_receive(:warn).with("No debian repos available for #{project} at #{ref}.")
43
+ it 'warns if there are no deb repos available for the build' do
44
+ expect(Pkg::Util::Tool)
45
+ .to receive(:find_tool)
46
+ .with('wget', { required: true })
47
+ .and_return(wget)
48
+ expect(Pkg::Util::Execution)
49
+ .to receive(:capture3)
50
+ .with("#{wget} --spider -r -l 1 --no-parent #{base_url}/repos/apt/ 2>&1")
51
+ .and_raise(RuntimeError)
52
+ expect(Pkg::Deb::Repo)
53
+ .to receive(:warn)
54
+ .with("No debian repos available for #{project} at #{ref}.")
42
55
  Pkg::Deb::Repo.generate_repo_configs
43
56
  end
44
57
 
45
- it "writes the expected repo configs to disk" do
46
- Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget)
47
- Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 1 --no-parent #{base_url}/repos/apt/ 2>&1").and_return(wget_results + wget_garbage)
48
- FileUtils.should_receive(:mkdir_p).with("pkg/repo_configs/deb")
58
+ it 'writes the expected repo configs to disk' do
59
+ expect(Pkg::Util::Tool)
60
+ .to receive(:find_tool)
61
+ .with('wget', { required: true })
62
+ .and_return(wget)
63
+ expect(Pkg::Util::Execution)
64
+ .to receive(:capture3)
65
+ .with("#{wget} --spider -r -l 1 --no-parent #{base_url}/repos/apt/ 2>&1")
66
+ .and_return(wget_results + wget_garbage)
67
+ expect(FileUtils).to receive(:mkdir_p).with('pkg/repo_configs/deb')
49
68
  config = []
50
69
  repo_configs.each_with_index do |repo_config, i|
51
70
  config[i] = double(File)
52
- File.should_receive(:open).with(repo_config, 'w').and_yield(config[i])
53
- config[i].should_receive(:puts)
71
+ expect(File).to receive(:open).with(repo_config, 'w').and_yield(config[i])
72
+ expect(config[i]).to receive(:puts)
54
73
  end
55
74
  Pkg::Deb::Repo.generate_repo_configs
56
75
  end
57
76
  end
58
77
 
59
- describe "#retrieve_repo_configs" do
60
- it "fails if wget isn't available" do
61
- Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_raise(RuntimeError)
62
- expect {Pkg::Deb::Repo.generate_repo_configs}.to raise_error(RuntimeError)
78
+ describe '#retrieve_repo_configs' do
79
+ it 'fails if wget isn\'t available' do
80
+ expect(Pkg::Util::Tool)
81
+ .to receive(:find_tool)
82
+ .with('wget', { required: true })
83
+ .and_raise(RuntimeError)
84
+ expect { Pkg::Deb::Repo.generate_repo_configs }.to raise_error(RuntimeError)
63
85
  end
64
86
 
65
- it "warns if there are no deb repos available for the build" do
66
- Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget)
67
- FileUtils.should_receive(:mkdir_p).with("pkg/repo_configs").and_return(true)
68
- Pkg::Util::Execution.should_receive(:capture3).with("#{wget} -r -np -nH --cut-dirs 3 -P pkg/repo_configs --reject 'index*' #{base_url}/repo_configs/deb/").and_raise(RuntimeError)
69
- expect {Pkg::Deb::Repo.retrieve_repo_configs}.to raise_error(RuntimeError, /Couldn't retrieve deb apt repo configs/)
87
+ it 'warns if there are no deb repos available for the build' do
88
+ expect(Pkg::Util::Tool)
89
+ .to receive(:find_tool)
90
+ .with('wget', { required: true })
91
+ .and_return(wget)
92
+ expect(FileUtils)
93
+ .to receive(:mkdir_p)
94
+ .with('pkg/repo_configs')
95
+ .and_return(true)
96
+ expect(Pkg::Util::Execution)
97
+ .to receive(:capture3)
98
+ .with("#{wget} -r -np -nH --cut-dirs 3 -P pkg/repo_configs --reject 'index*' #{base_url}/repo_configs/deb/")
99
+ .and_raise(RuntimeError)
100
+ expect { Pkg::Deb::Repo.retrieve_repo_configs }
101
+ .to raise_error(RuntimeError, /Couldn't retrieve deb apt repo configs/)
70
102
  end
71
103
  end
72
104
 
73
- describe "#repo_creation_command" do
74
- let(:prefix) { "thing" }
75
- let(:artifact_directory) { ["/a/b/c/bionic"] }
105
+ describe '#repo_creation_command' do
106
+ let(:prefix) { 'thing' }
107
+ let(:artifact_directory) { ['/a/b/c/bionic'] }
76
108
 
77
- it "returns a command to make repos" do
109
+ it 'returns a command to make repos' do
78
110
  command = Pkg::Deb::Repo.repo_creation_command(prefix, artifact_directory)
79
- command.should match(/reprepro/)
80
- command.should match(/#{prefix}/)
81
- command.should match(/#{artifact_directory}/)
111
+ expect(command).to match(/reprepro/)
112
+ expect(command).to match(/#{prefix}/)
113
+ expect(command).to match(/#{artifact_directory}/)
82
114
  end
83
115
  end
84
116
 
85
- describe "#create_repos" do
86
- let(:command) { "/usr/bin/make some repos" }
87
- let(:artifact_directory) { "/tmp/dir/thing" }
117
+ describe '#create_repos' do
118
+ let(:command) { '/usr/bin/make some repos' }
119
+ let(:artifact_directory) { '/tmp/dir/thing' }
88
120
  let(:pkg_directories) { ['place/to/deb/bionic', 'other/deb/focal'] }
89
121
 
90
- it "generates repo configs remotely and then ships them" do
91
- File.stub(:join) {artifact_directory}
92
- Pkg::Repo.should_receive(:directories_that_contain_packages).and_return(pkg_directories)
93
- Pkg::Repo.should_receive(:populate_repo_directory)
94
- Pkg::Deb::Repo.should_receive(:repo_creation_command).and_return(command)
95
- Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, command)
96
- Pkg::Deb::Repo.should_receive(:generate_repo_configs)
97
- Pkg::Deb::Repo.should_receive(:ship_repo_configs)
98
- Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock" )
122
+ it 'generates repo configs remotely and then ships them' do
123
+ allow(File).to receive(:join).and_return(artifact_directory)
124
+ expect(Pkg::Repo).to receive(:directories_that_contain_packages).and_return(pkg_directories)
125
+ expect(Pkg::Repo).to receive(:populate_repo_directory)
126
+ expect(Pkg::Deb::Repo).to receive(:repo_creation_command).and_return(command)
127
+ expect(Pkg::Util::Net)
128
+ .to receive(:remote_execute)
129
+ .with(Pkg::Config.distribution_server, command)
130
+ expect(Pkg::Deb::Repo).to receive(:generate_repo_configs)
131
+ expect(Pkg::Deb::Repo).to receive(:ship_repo_configs)
132
+ expect(Pkg::Util::Net)
133
+ .to receive(:remote_execute)
134
+ .with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock")
99
135
  Pkg::Deb::Repo.create_repos
100
136
  end
101
137
  end
102
138
 
103
- describe "#ship_repo_configs" do
104
- it "warns if there are no repo configs to ship" do
105
- File.should_receive(:exist?).with("pkg/repo_configs/deb").and_return(true)
106
- Pkg::Util::File.should_receive(:empty_dir?).with("pkg/repo_configs/deb").and_return(true)
107
- Pkg::Deb::Repo.should_receive(:warn).with("No repo configs have been generated! Try pl:deb_repo_configs.")
139
+ describe '#ship_repo_configs' do
140
+ it 'warns if there are no repo configs to ship' do
141
+ expect(File).to receive(:exist?).with('pkg/repo_configs/deb').and_return(true)
142
+ expect(Pkg::Util::File)
143
+ .to receive(:empty_dir?)
144
+ .with("pkg/repo_configs/deb")
145
+ .and_return(true)
146
+ expect(Pkg::Deb::Repo)
147
+ .to receive(:warn)
148
+ .with('No repo configs have been generated! Try pl:deb_repo_configs.')
108
149
  Pkg::Deb::Repo.ship_repo_configs
109
150
  end
110
151
 
111
- it "ships repo configs to the build server" do
112
- File.should_receive(:exist?).with("pkg/repo_configs/deb").and_return(true)
113
- Pkg::Config.jenkins_repo_path = "/a/b/c/d"
114
- Pkg::Config.distribution_server = "a.host.that.wont.exist"
152
+ it 'ships repo configs to the build server' do
153
+ expect(File).to receive(:exist?).with('pkg/repo_configs/deb').and_return(true)
154
+ Pkg::Config.jenkins_repo_path = '/a/b/c/d'
155
+ Pkg::Config.distribution_server = 'a.host.that.wont.exist'
115
156
  repo_dir = "#{Pkg::Config.jenkins_repo_path}/#{Pkg::Config.project}/#{Pkg::Config.ref}/repo_configs/deb"
116
- Pkg::Util::File.should_receive(:empty_dir?).with("pkg/repo_configs/deb").and_return(false)
117
- Pkg::Util::RakeUtils.should_receive(:invoke_task).with("pl:fetch")
118
- Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
119
- Pkg::Util::Execution.should_receive(:retry_on_fail).with(:times => 3)
157
+ expect(Pkg::Util::File)
158
+ .to receive(:empty_dir?)
159
+ .with('pkg/repo_configs/deb')
160
+ .and_return(false)
161
+ expect(Pkg::Util::RakeUtils)
162
+ .to receive(:invoke_task)
163
+ .with("pl:fetch")
164
+ expect(Pkg::Util::Net)
165
+ .to receive(:remote_execute)
166
+ .with(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
167
+ expect(Pkg::Util::Execution)
168
+ .to receive(:retry_on_fail)
169
+ .with(times: 3)
120
170
  Pkg::Deb::Repo.ship_repo_configs
121
171
  end
122
172
  end
123
173
 
124
- describe "#sign_repos" do
125
- it "fails without reprepro" do
126
- Pkg::Util::Tool.should_receive(:find_tool).with('reprepro', {:required => true}).and_raise(RuntimeError)
174
+ describe '#sign_repos' do
175
+ it 'fails without reprepro' do
176
+ expect(Pkg::Util::Tool)
177
+ .to receive(:find_tool)
178
+ .with('reprepro', { required: true })
179
+ .and_raise(RuntimeError)
127
180
  expect { Pkg::Deb::Repo.sign_repos }.to raise_error(RuntimeError)
128
181
  end
129
182
 
130
- it "makes a repo for each dist" do
183
+ it 'makes a repo for each dist' do
131
184
  # stub out start_keychain to prevent actual keychain starts.
132
- Pkg::Util::Gpg.stub(:start_keychain)
185
+ allow(Pkg::Util::Gpg).to receive(:start_keychain)
133
186
 
134
- dists = cows.reject { |cow| cow.empty? }
187
+ dists = cows.reject(&:empty?)
135
188
  distfiles = {}
136
- Pkg::Util::File.should_receive(:directories).with("repos/apt").and_return(dists)
189
+ expect(Pkg::Util::File)
190
+ .to receive(:directories)
191
+ .with('repos/apt')
192
+ .and_return(dists)
137
193
 
138
194
  # Let the keychain command happen if find_tool('keychain') finds it
139
- keychain_command = "/usr/bin/keychain -k mine"
195
+ keychain_command = '/usr/bin/keychain -k mine'
140
196
  allow(Pkg::Util::Execution).to receive(:capture3) { keychain_command }
141
197
 
142
198
  # Enforce reprepro
143
- reprepro_command = "/bin/reprepro"
144
- Pkg::Util::Tool.should_receive(:check_tool).with("reprepro").and_return(reprepro_command)
145
- Pkg::Util::Execution.should_receive(:capture3).at_least(1).times.with("#{reprepro_command} -vvv --confdir ./conf --dbdir ./db --basedir ./ export")
199
+ reprepro_command = '/bin/reprepro'
200
+ expect(Pkg::Util::Tool)
201
+ .to receive(:check_tool)
202
+ .with('reprepro')
203
+ .and_return(reprepro_command)
204
+ expect(Pkg::Util::Execution)
205
+ .to receive(:capture3)
206
+ .at_least(1).times
207
+ .with("#{reprepro_command} -vvv --confdir ./conf --dbdir ./db --basedir ./ export")
146
208
 
147
209
  dists.each do |dist|
148
210
  distfiles[dist] = double
149
- Dir.should_receive(:chdir).with("repos/apt/#{dist}").and_yield
150
- File.should_receive(:open).with("conf/distributions", "w").and_yield(distfiles[dist])
151
- distfiles[dist].should_receive(:puts)
211
+ expect(Dir).to receive(:chdir).with("repos/apt/#{dist}").and_yield
212
+ expect(File).to receive(:open).with('conf/distributions', 'w').and_yield(distfiles[dist])
213
+ expect(distfiles[dist]).to receive(:puts)
152
214
  end
153
215
 
154
216
  Pkg::Deb::Repo.sign_repos
@@ -3,50 +3,53 @@ require 'spec_helper'
3
3
  require 'packaging/deb'
4
4
 
5
5
  describe 'deb.rb' do
6
- describe "#set_cow_envs" do
6
+ describe '#set_cow_envs' do
7
7
  before(:each) do
8
- reset_env(["DIST", "ARCH", "PE_VER", "BUILDMIRROR"])
8
+ reset_env(['DIST', 'ARCH', 'PE_VER', 'BUILDMIRROR'])
9
9
  Pkg::Config.deb_build_mirrors = nil
10
10
  Pkg::Config.build_pe = nil
11
11
  Pkg::Config.pe_version = nil
12
12
  end
13
13
 
14
14
  after(:all) do
15
- reset_env(["DIST", "ARCH", "PE_VER", "BUILDMIRROR"])
15
+ reset_env(['DIST', 'ARCH', 'PE_VER', 'BUILDMIRROR'])
16
16
  Pkg::Config.deb_build_mirrors = nil
17
17
  Pkg::Config.build_pe = nil
18
18
  Pkg::Config.pe_version = nil
19
19
  end
20
20
 
21
- it "should always set DIST and ARCH correctly" do
22
- Pkg::Deb.send(:set_cow_envs, "base-wheezy-i386.cow")
23
- ENV["DIST"].should eq("wheezy")
24
- ENV["ARCH"].should eq("i386")
25
- ENV["PE_VER"].should be_nil
26
- ENV["BUILDMIRROR"].should be_nil
21
+ it 'should always set DIST and ARCH correctly' do
22
+ Pkg::Deb.send(:set_cow_envs, 'base-wheezy-i386.cow')
23
+ expect(ENV['DIST']).to eq('wheezy')
24
+ expect(ENV['ARCH']).to eq('i386')
25
+ expect(ENV['PE_VER']).to be nil
26
+ expect(ENV['BUILDMIRROR']).to be nil
27
27
  end
28
28
 
29
- it "should set BUILDMIRROR if Pkg::Config.deb_build_mirrors is set" do
30
- Pkg::Config.deb_build_mirrors = ["deb http://pl-build-tools.delivery.puppetlabs.net/debian __DIST__ main", "deb http://debian.is.awesome/wait no it is not"]
31
- Pkg::Deb.send(:set_cow_envs, "base-wheezy-i386.cow")
32
- ENV["DIST"].should eq("wheezy")
33
- ENV["ARCH"].should eq("i386")
34
- ENV["PE_VER"].should be_nil
35
- ENV["BUILDMIRROR"].should eq("deb http://pl-build-tools.delivery.puppetlabs.net/debian wheezy main | deb http://debian.is.awesome/wait no it is not")
29
+ it 'should set BUILDMIRROR if Pkg::Config.deb_build_mirrors is set' do
30
+ Pkg::Config.deb_build_mirrors = [
31
+ 'deb http://pl-build-tools.delivery.puppetlabs.net/debian __DIST__ main',
32
+ 'deb http://debian.is.awesome/wait no it is not'
33
+ ]
34
+ Pkg::Deb.send(:set_cow_envs, 'base-wheezy-i386.cow')
35
+ expect(ENV['DIST']).to eq('wheezy')
36
+ expect(ENV['ARCH']).to eq('i386')
37
+ expect(ENV['PE_VER']).to be nil
38
+ expect(ENV['BUILDMIRROR']).to eq('deb http://pl-build-tools.delivery.puppetlabs.net/debian wheezy main | deb http://debian.is.awesome/wait no it is not')
36
39
  end
37
40
 
38
- it "should set PE_VER if Pkg::Config.build_pe is truthy" do
41
+ it 'should set PE_VER if Pkg::Config.build_pe is truthy' do
39
42
  Pkg::Config.build_pe = true
40
- Pkg::Config.pe_version = "3.2"
41
- Pkg::Deb.send(:set_cow_envs, "base-wheezy-i386.cow")
42
- ENV["DIST"].should eq("wheezy")
43
- ENV["ARCH"].should eq("i386")
44
- ENV["PE_VER"].should eq("3.2")
45
- ENV["BUILDMIRROR"].should be_nil
43
+ Pkg::Config.pe_version = '3.2'
44
+ Pkg::Deb.send(:set_cow_envs, 'base-wheezy-i386.cow')
45
+ expect(ENV['DIST']).to eq('wheezy')
46
+ expect(ENV['ARCH']).to eq('i386')
47
+ expect(ENV['PE_VER']).to eq('3.2')
48
+ expect(ENV['BUILDMIRROR']).to be nil
46
49
  end
47
50
 
48
- it "should fail on a badly formatted cow" do
49
- expect { Pkg::Deb.send(:set_cow_envs, "wheezy-i386") }.to raise_error(RuntimeError)
51
+ it 'should fail on a badly formatted cow' do
52
+ expect { Pkg::Deb.send(:set_cow_envs, 'wheezy-i386') }.to raise_error(RuntimeError)
50
53
  end
51
54
  end
52
55
  end
@@ -1,23 +1,25 @@
1
1
  # -*- ruby -*-
2
2
  require 'spec_helper'
3
- describe "#Pkg::Repo" do
3
+
4
+ describe '#Pkg::Repo' do
4
5
  let(:platform_repo_stub) do
5
6
  [
6
- {"name"=>"el-4-i386", "repo_location"=>"repos/el/4/**/i386"},
7
- {"name"=>"el-5-i386", "repo_location"=>"repos/el/5/**/i386"},
8
- {"name"=>"el-6-i386", "repo_location"=>"repos/el/6/**/i386"}
7
+ { "name" => "el-4-i386", "repo_location" => "repos/el/4/**/i386" },
8
+ { "name" => "el-5-i386", "repo_location" => "repos/el/5/**/i386" },
9
+ { "name" => "el-6-i386", "repo_location" => "repos/el/6/**/i386" }
9
10
  ]
10
11
  end
11
- describe "#create_signed_repo_archive" do
12
- it "should change to the correct dir" do
13
- allow(Pkg::Util::Tool).to receive(:check_tool).and_return("tarcommand")
14
- allow(Pkg::Config).to receive(:project).and_return("project")
15
- allow(Pkg::Util::Version).to receive(:dot_version).and_return("1.1.1")
12
+
13
+ describe '#create_signed_repo_archive' do
14
+ it 'should change to the correct dir' do
15
+ allow(Pkg::Util::Tool).to receive(:check_tool).and_return('tarcommand')
16
+ allow(Pkg::Config).to receive(:project).and_return('project')
17
+ allow(Pkg::Util::Version).to receive(:dot_version).and_return('1.1.1')
16
18
  allow(Pkg::Util::File).to receive(:empty_dir?).and_return(false)
17
19
  allow(Pkg::Util::Execution).to receive(:capture3)
18
20
 
19
21
  expect(Dir).to receive(:chdir).with('pkg/project/1.1.1').and_yield
20
- Pkg::Repo.create_signed_repo_archive("/path", "project-debian-6-i386", "version")
22
+ Pkg::Repo.create_signed_repo_archive('/path', 'project-debian-6-i386', 'version')
21
23
  end
22
24
 
23
25
  it 'should use a ref if ref is specified as versioning' do
@@ -54,19 +56,23 @@ describe "#Pkg::Repo" do
54
56
  allow(Pkg::Util::File).to receive(:empty_dir?).and_return(true)
55
57
  ENV['FAIL_ON_MISSING_TARGET'] = 'true'
56
58
 
57
- expect{Pkg::Repo.create_signed_repo_archive('/path', 'project-debian-6-i386', 'version')}.to raise_error(RuntimeError, 'Error: missing packages under /path')
59
+ expect do
60
+ Pkg::Repo.create_signed_repo_archive('/path', 'project-debian-6-i386', 'version')
61
+ end.to raise_error(RuntimeError, 'Error: missing packages under /path')
58
62
  end
59
63
 
60
- it "should only warn if ENV['FAIL_ON_MISSING_TARGET'] is false and empty_dir? is true" do
61
- allow(Pkg::Util::Tool).to receive(:check_tool).and_return("tarcommand")
62
- allow(Pkg::Config).to receive(:project).and_return("project")
63
- allow(Pkg::Util::Version).to receive(:dot_version).and_return("1.1.1")
64
+ it 'should only warn if ENV[\'FAIL_ON_MISSING_TARGET\'] is false and empty_dir? is true' do
65
+ allow(Pkg::Util::Tool).to receive(:check_tool).and_return('tarcommand')
66
+ allow(Pkg::Config).to receive(:project).and_return('project')
67
+ allow(Pkg::Util::Version).to receive(:dot_version).and_return('1.1.1')
64
68
  allow(Pkg::Util::Execution).to receive(:capture3)
65
- allow(Dir).to receive(:chdir).with("pkg/project/1.1.1").and_yield
69
+ allow(Dir).to receive(:chdir).with('pkg/project/1.1.1').and_yield
66
70
  allow(Pkg::Util::File).to receive(:empty_dir?).and_return(true)
67
- ENV['FAIL_ON_MISSING_TARGET'] = "false"
71
+ ENV['FAIL_ON_MISSING_TARGET'] = 'false'
68
72
 
69
- expect{Pkg::Repo.create_signed_repo_archive("/path", "project-debian-6-i386", "version")}.not_to raise_error
73
+ expect do
74
+ Pkg::Repo.create_signed_repo_archive('/path', 'project-debian-6-i386', 'version')
75
+ end.not_to raise_error
70
76
  end
71
77
 
72
78
  it 'should invoke tar correctly' do
@@ -76,7 +82,9 @@ describe "#Pkg::Repo" do
76
82
  allow(Dir).to receive(:chdir).with('pkg/project/1.1.1').and_yield
77
83
  allow(Pkg::Util::File).to receive(:empty_dir?).and_return(false)
78
84
 
79
- expect(Pkg::Util::Execution).to receive(:capture3).with('tarcommand --owner=0 --group=0 --create --gzip --file repos/project-debian-6-i386.tar.gz /path')
85
+ expect(Pkg::Util::Execution)
86
+ .to receive(:capture3)
87
+ .with('tarcommand --owner=0 --group=0 --create --gzip --file repos/project-debian-6-i386.tar.gz /path')
80
88
  Pkg::Repo.create_signed_repo_archive('/path', 'project-debian-6-i386', 'version')
81
89
  end
82
90
  end
@@ -88,32 +96,38 @@ describe "#Pkg::Repo" do
88
96
  allow(Pkg::Util::Version).to receive(:dot_version).and_return('1.1.1')
89
97
  allow(Dir).to receive(:chdir).with('pkg/project/1.1.1').and_yield
90
98
 
91
- expect(Pkg::Repo).to receive(:create_signed_repo_archive).with('repos/el/4/**/i386', 'project-el-4-i386', 'version')
92
- expect(Pkg::Repo).to receive(:create_signed_repo_archive).with('repos/el/5/**/i386', 'project-el-5-i386', 'version')
93
- expect(Pkg::Repo).to receive(:create_signed_repo_archive).with('repos/el/6/**/i386', 'project-el-6-i386', 'version')
99
+ expect(Pkg::Repo)
100
+ .to receive(:create_signed_repo_archive)
101
+ .with('repos/el/4/**/i386', 'project-el-4-i386', 'version')
102
+ expect(Pkg::Repo)
103
+ .to receive(:create_signed_repo_archive)
104
+ .with('repos/el/5/**/i386', 'project-el-5-i386', 'version')
105
+ expect(Pkg::Repo)
106
+ .to receive(:create_signed_repo_archive)
107
+ .with('repos/el/6/**/i386', 'project-el-6-i386', 'version')
94
108
 
95
109
  allow(Pkg::Util::Execution).to receive(:capture3)
96
110
  Pkg::Repo.create_all_repo_archives('project', 'version')
97
111
  end
98
112
  end
99
113
 
100
- describe "#argument_required?" do
101
- let(:repo_command) { "some command with __REPO_PATH__ but not repo name or anything" }
114
+ describe '#argument_required?' do
115
+ let(:repo_command) { 'some command with __REPO_PATH__ but not repo name or anything' }
102
116
  let(:required_arg) { 'repo_path' }
103
117
  let(:optional_arg) { 'repo_name' }
104
118
 
105
119
  it 'should return true if command requires arg' do
106
- expect(Pkg::Repo.argument_required?(required_arg, repo_command)).to be_true
120
+ expect(Pkg::Repo.argument_required?(required_arg, repo_command)).to be true
107
121
  end
108
122
 
109
123
  it 'should return false if command does not need arg' do
110
- expect(Pkg::Repo.argument_required?(optional_arg, repo_command)).to be_false
124
+ expect(Pkg::Repo.argument_required?(optional_arg, repo_command)).to be false
111
125
  end
112
126
  end
113
127
 
114
- describe "#update_repo" do
128
+ describe '#update_repo' do
115
129
  let(:remote_host) { 'weth.delivery.puppetlabs.net' }
116
- let(:repo_command) { "some command with __REPO_NAME__ and __REPO_PATH__ and stuff" }
130
+ let(:repo_command) { 'some command with __REPO_NAME__ and __REPO_PATH__ and stuff' }
117
131
  let(:repo_name) { 'puppet5' }
118
132
  let(:repo_path) { '/opt/repository/apt' }
119
133
  let(:apt_releases) { ['stretch', 'trusty', 'xenial'] }
@@ -124,12 +138,19 @@ describe "#Pkg::Repo" do
124
138
  end
125
139
 
126
140
  it 'should fail if required params are nil' do
127
- expect{ Pkg::Repo.update_repo(remote_host, repo_command, { :repo_path => repo_path }) }.to raise_error(RuntimeError, /Missing required argument 'repo_name'/)
141
+ expect do
142
+ Pkg::Repo.update_repo(remote_host, repo_command, { repo_path: repo_path })
143
+ end.to raise_error(RuntimeError, /Missing required argument 'repo_name'/)
128
144
  end
129
145
 
130
146
  it 'should execute command if optional params are nil' do
131
- expect(Pkg::Util::Net).to receive(:remote_execute).with(remote_host, "some command with #{repo_name} and #{repo_path} and stuff")
132
- Pkg::Repo.update_repo(remote_host, repo_command, { :repo_name => repo_name, :repo_path => repo_path })
147
+ expect(Pkg::Util::Net)
148
+ .to receive(:remote_execute)
149
+ .with(remote_host, "some command with #{repo_name} and #{repo_path} and stuff")
150
+ Pkg::Repo.update_repo(remote_host, repo_command, {
151
+ repo_name: repo_name,
152
+ repo_path: repo_path
153
+ })
133
154
  end
134
155
  end
135
156
  end
@@ -6,7 +6,7 @@ describe 'Pkg::Rpm::Repo' do
6
6
  let(:project) { 'rpm_repos' }
7
7
  let(:ref) { '1234abcd' }
8
8
  let(:base_url) { "http://#{builds_server}/#{project}/#{ref}" }
9
- let(:mocks) { %w[el-5-i386 el-5-x86_64 el-5-SRPMS] }
9
+ let(:mocks) { ['el-5-i386', 'el-5-x86_64', 'el-5-SRPMS'] }
10
10
  let(:wget_results) do
11
11
  mocks.map do |mock|
12
12
  dist, version, arch = mock.split('-')
@@ -41,7 +41,7 @@ describe 'Pkg::Rpm::Repo' do
41
41
  allow(Pkg::Util::Tool)
42
42
  .to receive(:find_tool)
43
43
  .with('wget', { required: true })
44
- .and_return(false)
44
+ .and_return false
45
45
  expect { Pkg::Rpm::Repo.generate_repo_configs }.to raise_error(RuntimeError)
46
46
  end
47
47
 
@@ -63,7 +63,7 @@ describe 'Pkg::Rpm::Repo' do
63
63
  it 'writes the expected repo configs to disk' do
64
64
  expect(Pkg::Util::Tool)
65
65
  .to receive(:find_tool)
66
- .with("wget", { required: true })
66
+ .with('wget', { required: true })
67
67
  .and_return(wget)
68
68
  expect(Pkg::Util::Execution)
69
69
  .to receive(:capture3)
@@ -76,7 +76,7 @@ describe 'Pkg::Rpm::Repo' do
76
76
  .with("#{wget} --spider -r -l 1 --no-parent #{cur_result} 2>&1")
77
77
  .and_return("#{cur_result}/thing.rpm")
78
78
  end
79
- expect(FileUtils).to receive(:mkdir_p).with('pkg/repo_configs/rpm')
79
+ expect(FileUtils).to receive(:mkdir_p).with("pkg/repo_configs/rpm")
80
80
  config = []
81
81
  repo_configs.each_with_index do |repo_config, i|
82
82
  expect(Pkg::Paths).to receive(:tag_from_artifact_path).and_return(mocks[i])
@@ -89,24 +89,13 @@ describe 'Pkg::Rpm::Repo' do
89
89
  end
90
90
  end
91
91
 
92
- describe '#retrieve_repo_configs' do
93
- it 'fails if wget isn\'t available' do
94
- allow(Pkg::Util::Tool)
95
- .to receive(:find_tool)
96
- .with('wget', { required: true })
97
- .and_return(false)
98
- expect { Pkg::Rpm::Repo.generate_repo_configs }.to raise_error(RuntimeError)
99
- end
100
-
101
- it 'fails if there are no deb repos available for the build' do
92
+ describe "#retrieve_repo_configs" do
93
+ it "fails if there are no deb repos available for the build" do
102
94
  expect(Pkg::Util::Tool)
103
95
  .to receive(:find_tool)
104
96
  .with('wget', { required: true })
105
97
  .and_return(wget)
106
- expect(FileUtils)
107
- .to receive(:mkdir_p)
108
- .with('pkg/repo_configs')
109
- .and_return(true)
98
+ expect(FileUtils).to receive(:mkdir_p).with('pkg/repo_configs').and_return(true)
110
99
  expect(Pkg::Util::Execution)
111
100
  .to receive(:capture3)
112
101
  .with("#{wget} -r -np -nH --cut-dirs 3 -P pkg/repo_configs --reject 'index*' #{base_url}/repo_configs/rpm/")
@@ -124,10 +113,8 @@ describe 'Pkg::Rpm::Repo' do
124
113
  expect(Pkg::Rpm::Repo)
125
114
  .to receive(:repo_creation_command)
126
115
  .with(target_directory)
127
- .and_return("run this thing")
128
- expect(Pkg::Util::Execution)
129
- .to receive(:capture3)
130
- .with("bash -c 'run this thing'")
116
+ .and_return('run this thing')
117
+ expect(Pkg::Util::Execution).to receive(:capture3).with("bash -c 'run this thing'")
131
118
  Pkg::Rpm::Repo.create_local_repos(target_directory)
132
119
  end
133
120
  end
@@ -157,9 +144,11 @@ describe 'Pkg::Rpm::Repo' do
157
144
  describe '#ship_repo_configs' do
158
145
  it 'warn if there are no repo configs to ship' do
159
146
  Pkg::Config.jenkins_repo_path = '/a/b/c/d'
160
- expect(Dir).to receive(:exist?).with("pkg/repo_configs/rpm").and_return(false)
161
- expect(Pkg::Rpm::Repo).to receive(:warn)
162
- expect(Pkg::Util::RakeUtils).not_to receive(:invoke_task)
147
+ expect(Dir).to receive(:exist?).with("pkg/repo_configs/rpm").and_return(true)
148
+ expect(Dir).to receive(:empty?).with("pkg/repo_configs/rpm").and_return(true)
149
+ expect(Pkg::Rpm::Repo)
150
+ .to receive(:warn)
151
+ .with(/^No repo_configs found in.*Skipping repo shipping/)
163
152
  Pkg::Rpm::Repo.ship_repo_configs
164
153
  end
165
154
 
@@ -168,22 +157,14 @@ describe 'Pkg::Rpm::Repo' do
168
157
  Pkg::Config.project = 'thing2'
169
158
  Pkg::Config.ref = 'abcd1234'
170
159
  Pkg::Config.distribution_server = 'a.host.that.wont.exist'
171
- repo_dir = File.join(
172
- Pkg::Config.jenkins_repo_path,
173
- Pkg::Config.project,
174
- Pkg::Config.ref,
175
- 'repo_configs',
176
- 'rpm'
177
- )
178
- expect(Dir).to receive(:exist?).with('pkg/repo_configs/rpm').and_return(true)
179
- expect(Dir).to receive(:empty?).with('pkg/repo_configs/rpm').and_return(false)
160
+ repo_dir = "#{Pkg::Config.jenkins_repo_path}/#{Pkg::Config.project}/#{Pkg::Config.ref}/repo_configs/rpm"
161
+ expect(Dir).to receive(:exist?).with("pkg/repo_configs/rpm").and_return(true)
162
+ expect(Dir).to receive(:empty?).with("pkg/repo_configs/rpm").and_return(false)
180
163
  expect(Pkg::Util::RakeUtils).to receive(:invoke_task).with('pl:fetch')
181
164
  expect(Pkg::Util::Net)
182
165
  .to receive(:remote_execute)
183
166
  .with(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
184
- expect(Pkg::Util::Net)
185
- .to receive(:rsync_to)
186
- .with('pkg/repo_configs/rpm/', Pkg::Config.distribution_server, repo_dir)
167
+ expect(Pkg::Util::Execution).to receive(:retry_on_fail).with(times: 3)
187
168
  Pkg::Rpm::Repo.ship_repo_configs
188
169
  end
189
170
  end