packaging 0.88.77
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.
- checksums.yaml +7 -0
- data/LICENSE +17 -0
- data/README-Solaris.md +117 -0
- data/README.md +977 -0
- data/lib/packaging.rb +32 -0
- data/lib/packaging/archive.rb +126 -0
- data/lib/packaging/artifactory.rb +651 -0
- data/lib/packaging/artifactory/extensions.rb +94 -0
- data/lib/packaging/config.rb +492 -0
- data/lib/packaging/config/params.rb +387 -0
- data/lib/packaging/config/validations.rb +13 -0
- data/lib/packaging/deb.rb +28 -0
- data/lib/packaging/deb/repo.rb +264 -0
- data/lib/packaging/gem.rb +70 -0
- data/lib/packaging/metrics.rb +15 -0
- data/lib/packaging/nuget.rb +39 -0
- data/lib/packaging/paths.rb +376 -0
- data/lib/packaging/platforms.rb +507 -0
- data/lib/packaging/repo.rb +155 -0
- data/lib/packaging/retrieve.rb +75 -0
- data/lib/packaging/rpm.rb +5 -0
- data/lib/packaging/rpm/repo.rb +254 -0
- data/lib/packaging/sign.rb +8 -0
- data/lib/packaging/sign/deb.rb +9 -0
- data/lib/packaging/sign/dmg.rb +41 -0
- data/lib/packaging/sign/ips.rb +57 -0
- data/lib/packaging/sign/msi.rb +124 -0
- data/lib/packaging/sign/rpm.rb +115 -0
- data/lib/packaging/tar.rb +163 -0
- data/lib/packaging/util.rb +146 -0
- data/lib/packaging/util/date.rb +20 -0
- data/lib/packaging/util/execution.rb +85 -0
- data/lib/packaging/util/file.rb +125 -0
- data/lib/packaging/util/git.rb +174 -0
- data/lib/packaging/util/git_tags.rb +73 -0
- data/lib/packaging/util/gpg.rb +66 -0
- data/lib/packaging/util/jenkins.rb +95 -0
- data/lib/packaging/util/misc.rb +69 -0
- data/lib/packaging/util/net.rb +410 -0
- data/lib/packaging/util/os.rb +17 -0
- data/lib/packaging/util/platform.rb +40 -0
- data/lib/packaging/util/rake_utils.rb +112 -0
- data/lib/packaging/util/serialization.rb +19 -0
- data/lib/packaging/util/ship.rb +300 -0
- data/lib/packaging/util/tool.rb +41 -0
- data/lib/packaging/util/version.rb +334 -0
- data/spec/fixtures/config/ext/build_defaults.yaml +2 -0
- data/spec/fixtures/config/ext/project_data.yaml +2 -0
- data/spec/fixtures/configs/components/test_file.json +1 -0
- data/spec/fixtures/configs/components/test_file_2.json +0 -0
- data/spec/fixtures/configs/components/test_file_not_tagged.json +1 -0
- data/spec/fixtures/configs/components/test_file_wrong_ext.txt +0 -0
- data/spec/fixtures/configs/components/test_file_wrong_ext.wrong +0 -0
- data/spec/fixtures/util/pre_tasks.yaml +4 -0
- data/spec/lib/packaging/artifactory_spec.rb +221 -0
- data/spec/lib/packaging/config_spec.rb +576 -0
- data/spec/lib/packaging/deb/repo_spec.rb +157 -0
- data/spec/lib/packaging/deb_spec.rb +52 -0
- data/spec/lib/packaging/gem_spec.rb +86 -0
- data/spec/lib/packaging/paths_spec.rb +418 -0
- data/spec/lib/packaging/platforms_spec.rb +178 -0
- data/spec/lib/packaging/repo_spec.rb +135 -0
- data/spec/lib/packaging/retrieve_spec.rb +100 -0
- data/spec/lib/packaging/rpm/repo_spec.rb +133 -0
- data/spec/lib/packaging/sign_spec.rb +133 -0
- data/spec/lib/packaging/tar_spec.rb +116 -0
- data/spec/lib/packaging/util/execution_spec.rb +56 -0
- data/spec/lib/packaging/util/file_spec.rb +139 -0
- data/spec/lib/packaging/util/git_spec.rb +160 -0
- data/spec/lib/packaging/util/git_tag_spec.rb +36 -0
- data/spec/lib/packaging/util/gpg_spec.rb +64 -0
- data/spec/lib/packaging/util/jenkins_spec.rb +112 -0
- data/spec/lib/packaging/util/misc_spec.rb +31 -0
- data/spec/lib/packaging/util/net_spec.rb +259 -0
- data/spec/lib/packaging/util/os_spec.rb +31 -0
- data/spec/lib/packaging/util/rake_utils_spec.rb +70 -0
- data/spec/lib/packaging/util/ship_spec.rb +199 -0
- data/spec/lib/packaging/util/version_spec.rb +123 -0
- data/spec/lib/packaging_spec.rb +19 -0
- data/spec/spec_helper.rb +22 -0
- data/static_artifacts/PackageInfo.plist +3 -0
- data/tasks/00_utils.rake +214 -0
- data/tasks/30_metrics.rake +33 -0
- data/tasks/apple.rake +268 -0
- data/tasks/archive.rake +69 -0
- data/tasks/build.rake +12 -0
- data/tasks/clean.rake +5 -0
- data/tasks/config.rake +35 -0
- data/tasks/deb.rake +129 -0
- data/tasks/deb_repos.rake +28 -0
- data/tasks/deprecated.rake +130 -0
- data/tasks/doc.rake +20 -0
- data/tasks/education.rake +57 -0
- data/tasks/fetch.rake +60 -0
- data/tasks/gem.rake +159 -0
- data/tasks/jenkins.rake +538 -0
- data/tasks/jenkins_dynamic.rake +202 -0
- data/tasks/load_extras.rake +21 -0
- data/tasks/mock.rake +348 -0
- data/tasks/nightly_repos.rake +286 -0
- data/tasks/pe_deb.rake +12 -0
- data/tasks/pe_rpm.rake +13 -0
- data/tasks/pe_ship.rake +226 -0
- data/tasks/pe_sign.rake +13 -0
- data/tasks/pe_tar.rake +5 -0
- data/tasks/retrieve.rake +52 -0
- data/tasks/rpm.rake +66 -0
- data/tasks/rpm_repos.rake +29 -0
- data/tasks/ship.rake +692 -0
- data/tasks/sign.rake +154 -0
- data/tasks/tag.rake +8 -0
- data/tasks/tar.rake +28 -0
- data/tasks/update.rake +16 -0
- data/tasks/vanagon.rake +35 -0
- data/tasks/vendor_gems.rake +117 -0
- data/tasks/version.rake +33 -0
- data/tasks/z_data_dump.rake +65 -0
- data/templates/README +1 -0
- data/templates/downstream.xml.erb +47 -0
- data/templates/msi.xml.erb +197 -0
- data/templates/packaging.xml.erb +346 -0
- data/templates/repo.xml.erb +117 -0
- metadata +287 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Pkg::Util::OS do
|
|
4
|
+
def as_host_os(platform, &block)
|
|
5
|
+
old = RbConfig::CONFIG['host_os']
|
|
6
|
+
RbConfig::CONFIG['host_os'] = platform
|
|
7
|
+
begin
|
|
8
|
+
yield
|
|
9
|
+
ensure
|
|
10
|
+
RbConfig::CONFIG['host_os'] = old
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "detects windows when host_os contains mingw" do
|
|
15
|
+
as_host_os('mingw32') do
|
|
16
|
+
expect(Pkg::Util::OS).to be_windows
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "detects windows when host_os contains mswin60" do
|
|
21
|
+
as_host_os('mswin60') do
|
|
22
|
+
expect(Pkg::Util::OS).to be_windows
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "does not detect windows when host_os contains darwin" do
|
|
27
|
+
as_host_os('darwin12.5.0') do
|
|
28
|
+
expect(Pkg::Util::OS).to_not be_windows
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Pkg::Util::RakeUtils" do
|
|
4
|
+
let(:foo_defined?) { Rake::Task.task_defined?(:foo) }
|
|
5
|
+
let(:bar_defined?) { Rake::Task.task_defined?(:bar) }
|
|
6
|
+
let(:define_foo) { body = proc{}; Rake::Task.define_task(:foo, &body) }
|
|
7
|
+
let(:define_bar) { body = proc{}; Rake::Task.define_task(:bar, &body) }
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
if foo_defined?
|
|
11
|
+
Rake::Task[:foo].clear_prerequisites
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "#task_defined?" do
|
|
16
|
+
context "given a Rake::Task task name" do
|
|
17
|
+
it "should return true if the task exists" do
|
|
18
|
+
Rake::Task.stub(:task_defined?).with(:foo) {true}
|
|
19
|
+
expect(Pkg::Util::RakeUtils.task_defined?(:foo)).to be_true
|
|
20
|
+
end
|
|
21
|
+
it "should return false if the task does not exist" do
|
|
22
|
+
Rake::Task.stub(:task_defined?).with(:foo) {false}
|
|
23
|
+
expect(Pkg::Util::RakeUtils.task_defined?(:foo)).to be_false
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "#get_task" do
|
|
29
|
+
it "should return a task object for a named task" do
|
|
30
|
+
foo = nil
|
|
31
|
+
if !foo_defined?
|
|
32
|
+
foo = define_foo
|
|
33
|
+
else
|
|
34
|
+
foo = Rake::Task[:foo]
|
|
35
|
+
end
|
|
36
|
+
task = Pkg::Util::RakeUtils.get_task(:foo)
|
|
37
|
+
expect(task).to be_a(Rake::Task)
|
|
38
|
+
expect(task).to be(foo)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe "#add_dependency" do
|
|
43
|
+
it "should add a dependency to a given rake task" do
|
|
44
|
+
foo = nil
|
|
45
|
+
bar = nil
|
|
46
|
+
if !foo_defined?
|
|
47
|
+
foo = define_foo
|
|
48
|
+
else
|
|
49
|
+
foo = Rake::Task[:foo]
|
|
50
|
+
end
|
|
51
|
+
if !bar_defined?
|
|
52
|
+
bar = define_bar
|
|
53
|
+
else
|
|
54
|
+
bar = Rake::Task[:bar]
|
|
55
|
+
end
|
|
56
|
+
Pkg::Util::RakeUtils.add_dependency(foo, bar)
|
|
57
|
+
expect(Rake::Task["foo"].prerequisites).to include(bar)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe "#evaluate_pre_tasks" do
|
|
62
|
+
context "Given a data file with :pre_tasks defined" do
|
|
63
|
+
it "should, for each k=>v pair, add v as a dependency to k" do
|
|
64
|
+
Pkg::Config.config_from_yaml(File.join(FIXTURES, 'util', 'pre_tasks.yaml'))
|
|
65
|
+
expect(Pkg::Util::RakeUtils).to receive(:add_dependency)
|
|
66
|
+
Pkg::Util::RakeUtils.evaluate_pre_tasks
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe '#Pkg::Util::Ship' do
|
|
4
|
+
describe '#collect_packages' do
|
|
5
|
+
msi_packages = %w[
|
|
6
|
+
pkg/windows/puppet6/puppet-agent-6.19.0-x64.msi
|
|
7
|
+
pkg/windows/puppet6/puppet-agent-6.19.0-x86.msi
|
|
8
|
+
pkg/windowsfips/puppet6/puppet-agent-6.19.0-x64.msi
|
|
9
|
+
pkg/windows/puppet6/puppet-agent-x86.msi
|
|
10
|
+
pkg/windowsfips/puppet6/puppet-agent-x64.msi
|
|
11
|
+
]
|
|
12
|
+
solaris_packages = %w[
|
|
13
|
+
pkg/solaris/10/puppet6/puppet-agent-6.9.0-1.sparc.pkg.gz
|
|
14
|
+
pkg/solaris/10/puppet6/puppet-agent-6.9.0-1.sparc.pkg.gz.asc
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
it 'returns an array of packages found on the filesystem' do
|
|
18
|
+
allow(Dir).to receive(:glob).with('pkg/**/*.sparc*').and_return(solaris_packages)
|
|
19
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.sparc*'])).to eq(solaris_packages)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context 'excluding packages' do
|
|
23
|
+
before :each do
|
|
24
|
+
allow(Dir).to receive(:glob).with('pkg/**/*.msi').and_return(msi_packages)
|
|
25
|
+
end
|
|
26
|
+
it 'correctly excludes any packages that match a passed excludes argument' do
|
|
27
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi']))
|
|
28
|
+
.not_to include('pkg/windows/puppet6/puppet-agent-x86.msi')
|
|
29
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi']))
|
|
30
|
+
.not_to include('pkg/windows/puppet6/puppet-agent-x64.msi')
|
|
31
|
+
end
|
|
32
|
+
it 'correctly includes packages that do not match a passed excluded argument' do
|
|
33
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'],
|
|
34
|
+
['bogus-puppet-agent-x(86|64).msi']))
|
|
35
|
+
.to match_array(msi_packages)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'returns an empty array when it cannot find any packages' do
|
|
40
|
+
allow(Dir).to receive(:glob).with('pkg/**/*.html').and_return([])
|
|
41
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.html'])).to be_empty
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Sample data for #reorganize_packages and #ship_pkgs specs
|
|
46
|
+
retrieved_packages = %w[
|
|
47
|
+
pkg/deb/bionic/puppet6/puppet-agent_6.19.0-1bionic_amd64.deb
|
|
48
|
+
pkg/el/7/puppet6/aarch64/puppet-agent-6.19.0-1.el7.aarch64.rpm
|
|
49
|
+
pkg/el/7/puppet6/ppc64le/puppet-agent-6.19.0-1.el7.ppc64le.rpm
|
|
50
|
+
pkg/el/7/puppet6/x86_64/puppet-agent-6.19.0-1.el7.x86_64.rpm
|
|
51
|
+
pkg/sles/12/puppet6/ppc64le/puppet-agent-6.19.0-1.sles12.ppc64le.rpm
|
|
52
|
+
pkg/sles/12/puppet6/x86_64/puppet-agent-6.19.0-1.sles12.x86_64.rpm
|
|
53
|
+
pkg/sles/15/puppet6/x86_64/puppet-agent-6.19.0-1.sles15.x86_64.rpm
|
|
54
|
+
pkg/apple/10.14/puppet6/x86_64/puppet-agent-6.19.0-1.osx10.14.dmg
|
|
55
|
+
pkg/apple/10.15/puppet6/x86_64/puppet-agent-6.19.0-1.osx10.15.dmg
|
|
56
|
+
pkg/fedora/32/puppet6/x86_64/puppet-agent-6.19.0-1.fc32.x86_64.rpm
|
|
57
|
+
pkg/windows/puppet-agent-6.19.0-x64.msi
|
|
58
|
+
pkg/windows/puppet-agent-6.19.0-x86.msi
|
|
59
|
+
pkg/windowsfips/puppet-agent-6.19.0-x64.msi
|
|
60
|
+
pkg/windows/puppet6/puppet-agent-x86.msi
|
|
61
|
+
pkg/windowsfips/puppet6/puppet-agent-x64.msi
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
# After reorganization, the packages should look like this.
|
|
65
|
+
# Beware apple->mac transforms.
|
|
66
|
+
expected_reorganized_packages = %w[
|
|
67
|
+
pkg/bionic/puppet6/puppet-agent_6.19.0-1bionic_amd64.deb
|
|
68
|
+
pkg/puppet6/el/7/aarch64/puppet-agent-6.19.0-1.el7.aarch64.rpm
|
|
69
|
+
pkg/puppet6/el/7/ppc64le/puppet-agent-6.19.0-1.el7.ppc64le.rpm
|
|
70
|
+
pkg/puppet6/el/7/x86_64/puppet-agent-6.19.0-1.el7.x86_64.rpm
|
|
71
|
+
pkg/puppet6/sles/12/ppc64le/puppet-agent-6.19.0-1.sles12.ppc64le.rpm
|
|
72
|
+
pkg/puppet6/sles/12/x86_64/puppet-agent-6.19.0-1.sles12.x86_64.rpm
|
|
73
|
+
pkg/puppet6/sles/15/x86_64/puppet-agent-6.19.0-1.sles15.x86_64.rpm
|
|
74
|
+
pkg/mac/puppet6/10.14/x86_64/puppet-agent-6.19.0-1.osx10.14.dmg
|
|
75
|
+
pkg/mac/puppet6/10.15/x86_64/puppet-agent-6.19.0-1.osx10.15.dmg
|
|
76
|
+
pkg/puppet6/fedora/32/x86_64/puppet-agent-6.19.0-1.fc32.x86_64.rpm
|
|
77
|
+
pkg/windows/puppet6/puppet-agent-6.19.0-x64.msi
|
|
78
|
+
pkg/windows/puppet6/puppet-agent-6.19.0-x86.msi
|
|
79
|
+
pkg/windowsfips/puppet6/puppet-agent-6.19.0-x64.msi
|
|
80
|
+
pkg/windows/puppet6/puppet-agent-x86.msi
|
|
81
|
+
pkg/windowsfips/puppet6/puppet-agent-x64.msi
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
describe '#reorganize_packages' do
|
|
85
|
+
# This is a sampling of packages found on builds.delivery.puppetlabs.net in
|
|
86
|
+
# '/opt/jenkins-builds/puppet-agent/<version>/artifacts'
|
|
87
|
+
# pl:jenkins:retrieve replaces 'artifacts' with 'pkg', so we pick up the
|
|
88
|
+
# action from that point by pretending that we've scanned the directory and
|
|
89
|
+
# made this list:
|
|
90
|
+
|
|
91
|
+
scratch_directory = Dir.mktmpdir
|
|
92
|
+
|
|
93
|
+
before :each do
|
|
94
|
+
allow(Pkg::Config).to receive(:repo_name).and_return('puppet6')
|
|
95
|
+
expect(FileUtils).to receive(:cp).at_least(:once).and_return(true)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
original_packages = retrieved_packages
|
|
99
|
+
|
|
100
|
+
it 'leaves the old packages in place' do
|
|
101
|
+
reorganized_packages = Pkg::Util::Ship
|
|
102
|
+
.reorganize_packages(retrieved_packages, scratch_directory)
|
|
103
|
+
|
|
104
|
+
expect(retrieved_packages).to eq(original_packages)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'returns a list of properly reorganized packages' do
|
|
108
|
+
reorganized_packages = Pkg::Util::Ship
|
|
109
|
+
.reorganize_packages(retrieved_packages, scratch_directory)
|
|
110
|
+
expect(reorganized_packages).to eq(expected_reorganized_packages)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe '#ship_pkgs' do
|
|
115
|
+
test_staging_server = 'foo.delivery.puppetlabs.net'
|
|
116
|
+
test_remote_path = '/opt/repository/yum'
|
|
117
|
+
|
|
118
|
+
it 'ships the packages to the staging server' do
|
|
119
|
+
allow(Pkg::Util::Ship)
|
|
120
|
+
.to receive(:collect_packages)
|
|
121
|
+
.and_return(retrieved_packages)
|
|
122
|
+
allow(Pkg::Util::Ship)
|
|
123
|
+
.to receive(:reorganize_packages)
|
|
124
|
+
.and_return(expected_reorganized_packages)
|
|
125
|
+
allow(Pkg::Util).to receive(:ask_yes_or_no).and_return(true)
|
|
126
|
+
# All of these expects must be called in the same block in order for the
|
|
127
|
+
# tests to work without actually shipping anything
|
|
128
|
+
expect(Pkg::Util::Net)
|
|
129
|
+
.to receive(:remote_execute)
|
|
130
|
+
.with(test_staging_server, /#{test_remote_path}/)
|
|
131
|
+
.exactly(retrieved_packages.count).times
|
|
132
|
+
expect(Pkg::Util::Net)
|
|
133
|
+
.to receive(:rsync_to)
|
|
134
|
+
.with(anything, test_staging_server, /#{test_remote_path}/, anything)
|
|
135
|
+
.exactly(retrieved_packages.count).times
|
|
136
|
+
expect(Pkg::Util::Net)
|
|
137
|
+
.to receive(:remote_set_ownership)
|
|
138
|
+
.with(test_staging_server, 'root', 'release', anything)
|
|
139
|
+
.exactly(retrieved_packages.count).times
|
|
140
|
+
expect(Pkg::Util::Net)
|
|
141
|
+
.to receive(:remote_set_permissions)
|
|
142
|
+
.with(test_staging_server, '775', anything)
|
|
143
|
+
.exactly(retrieved_packages.count).times
|
|
144
|
+
expect(Pkg::Util::Net)
|
|
145
|
+
.to receive(:remote_set_permissions)
|
|
146
|
+
.with(test_staging_server, '0664', anything)
|
|
147
|
+
.exactly(retrieved_packages.count).times
|
|
148
|
+
expect(Pkg::Util::Net)
|
|
149
|
+
.to receive(:remote_set_immutable)
|
|
150
|
+
.with(test_staging_server, anything)
|
|
151
|
+
.exactly(retrieved_packages.count).times
|
|
152
|
+
expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server, test_remote_path))
|
|
153
|
+
.to eq(true)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it 'ships packages containing the string `pkg` to the right place' do
|
|
157
|
+
retrieved_package = 'pkg/el/7/puppet6/x86_64/puppet-agent-6.19.0-1.el7.x86_64.rpm'
|
|
158
|
+
reorganized_package = 'pkg/puppet6/el/7/x86_64/puppet-agent-6.19.0-1.el7.x86_64.rpm'
|
|
159
|
+
package_basename = File.basename(reorganized_package)
|
|
160
|
+
repository_base_path = '/opt/repository/yum/puppet6/el/7/x86_64'
|
|
161
|
+
|
|
162
|
+
allow(Pkg::Util::Ship).to receive(:collect_packages).and_return([retrieved_package])
|
|
163
|
+
allow(Pkg::Util::Ship).to receive(:reorganize_packages).and_return([reorganized_package])
|
|
164
|
+
allow(Pkg::Util).to receive(:ask_yes_or_no).and_return(true)
|
|
165
|
+
allow(Dir).to receive(:mktmpdir).and_return('/tmp/test')
|
|
166
|
+
|
|
167
|
+
# All of these expects must be called in the same block in order for the
|
|
168
|
+
# tests to work without actually shipping anything
|
|
169
|
+
expect(Pkg::Util::Net)
|
|
170
|
+
.to receive(:remote_execute)
|
|
171
|
+
.with(test_staging_server, /#{test_remote_path}/)
|
|
172
|
+
expect(Pkg::Util::Net)
|
|
173
|
+
.to receive(:rsync_to)
|
|
174
|
+
.with(anything, test_staging_server, /#{test_remote_path}/, anything)
|
|
175
|
+
expect(Pkg::Util::Net)
|
|
176
|
+
.to receive(:remote_set_ownership)
|
|
177
|
+
.with(test_staging_server, 'root', 'release',
|
|
178
|
+
[repository_base_path, "#{repository_base_path}/#{package_basename}"])
|
|
179
|
+
expect(Pkg::Util::Net)
|
|
180
|
+
.to receive(:remote_set_permissions)
|
|
181
|
+
.with(test_staging_server, '775', anything)
|
|
182
|
+
expect(Pkg::Util::Net)
|
|
183
|
+
.to receive(:remote_set_permissions)
|
|
184
|
+
.with(test_staging_server, '0664', anything)
|
|
185
|
+
expect(Pkg::Util::Net)
|
|
186
|
+
.to receive(:remote_set_immutable)
|
|
187
|
+
.with(test_staging_server, anything)
|
|
188
|
+
expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server,
|
|
189
|
+
test_remote_path, excludes: ['puppet-agent']))
|
|
190
|
+
.to eq(true)
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it 'returns false if there are no packages to ship' do
|
|
194
|
+
expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.msi'],
|
|
195
|
+
test_staging_server, test_remote_path))
|
|
196
|
+
.to eq(false)
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
# Spec tests for Pkg::Util::Version
|
|
5
|
+
#
|
|
6
|
+
# rubocop:disable Metrics/BlockLength
|
|
7
|
+
describe 'Pkg::Util::Version' do
|
|
8
|
+
context '#versionbump' do
|
|
9
|
+
let(:version_file) { 'thing.txt' }
|
|
10
|
+
let(:version) { '1.2.3' }
|
|
11
|
+
let(:orig_contents) { "abcd\nVERSION = @DEVELOPMENT_VERSION@\n" }
|
|
12
|
+
let(:updated_contents) { "abcd\nVERSION = #{version}\n" }
|
|
13
|
+
|
|
14
|
+
it 'should update the version file contents accordingly' do
|
|
15
|
+
Pkg::Config.config_from_hash(project: 'foo', version_file: version_file)
|
|
16
|
+
allow(IO).to receive(:read).with(version_file) { orig_contents }
|
|
17
|
+
allow(Pkg::Config).to receive(:version) { version }
|
|
18
|
+
version_file_to_write = double('file')
|
|
19
|
+
expect(File).to receive(:open).with(version_file, 'w').and_yield(version_file_to_write)
|
|
20
|
+
expect(version_file_to_write).to receive(:write).with(updated_contents)
|
|
21
|
+
Pkg::Util::Version.versionbump
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe '#base_pkg_version' do
|
|
26
|
+
version_hash = {
|
|
27
|
+
'5.6' => ['5.6', '1'],
|
|
28
|
+
'1.0.0' => ['1.0.0', '1'],
|
|
29
|
+
'2017.6.5.3' => ['2017.6.5.3', '1'],
|
|
30
|
+
'4.99.0-22' => ['4.99.0.22', '0.1'],
|
|
31
|
+
'1.0.0-658-gabc1234' => ['1.0.0.658.gabc1234', '0.1'],
|
|
32
|
+
'5.0.0.master.SNAPSHOT.2017.05.16T1357' => ['5.0.0.master', '0.1SNAPSHOT.2017.05.16T1357'],
|
|
33
|
+
'5.9.7-rc4' => ['5.9.7', '0.1rc4'],
|
|
34
|
+
'5.9.7-rc4-65-gabc1234' => ['5.9.7.65.gabc1234', '0.1rc4'],
|
|
35
|
+
'5.9.7-rc4-65-gabc1234-dirty' => ['5.9.7.65.gabc1234', '0.1rc4dirty'],
|
|
36
|
+
'4.99.0-dirty' => ['4.99.0', '0.1dirty'],
|
|
37
|
+
'4.99.0-56-gabc1234-dirty' => ['4.99.0.56.gabc1234', '0.1dirty']
|
|
38
|
+
}
|
|
39
|
+
version_hash.each do |pre, post|
|
|
40
|
+
before do
|
|
41
|
+
allow(Pkg::Config).to receive(:version) { pre }
|
|
42
|
+
allow(Pkg::Config).to receive(:release) { '1' }
|
|
43
|
+
allow(Pkg::Config).to receive(:vanagon_project) { false }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "transforms #{pre} to #{post}" do
|
|
47
|
+
expect(Pkg::Util::Version.base_pkg_version(pre)).to eq post
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe '#final?' do
|
|
53
|
+
final_versions = [
|
|
54
|
+
'1.0.0',
|
|
55
|
+
'2017.6.5.3',
|
|
56
|
+
'0.6.8',
|
|
57
|
+
'2068.532.6',
|
|
58
|
+
'96.5'
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
non_final_versions = [
|
|
62
|
+
'4.99.0-22',
|
|
63
|
+
'1.0.0-658-gabc1234',
|
|
64
|
+
'5.0.0.master.SNAPSHOT.2017.05.16T1357',
|
|
65
|
+
'5.9.7-rc4',
|
|
66
|
+
'4.99.0-56-dirty'
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
final_versions.each do |version|
|
|
70
|
+
it "returns true when given #{version}" do
|
|
71
|
+
allow(Pkg::Config).to receive(:version) { nil }
|
|
72
|
+
expect(Pkg::Util::Version.final?(version)).to be true
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
non_final_versions.each do |version|
|
|
77
|
+
it "returns false when given #{version}" do
|
|
78
|
+
allow(Pkg::Config).to receive(:version) { nil }
|
|
79
|
+
expect(Pkg::Util::Version.final?(version)).to be false
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'correctly reads a final version from Pkg::Config.version' do
|
|
84
|
+
allow(Pkg::Config).to receive(:version) { '1.0.0' }
|
|
85
|
+
expect(Pkg::Util::Version.final?).to be true
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'correctly reads a non-final version from Pkg::Config.version' do
|
|
89
|
+
allow(Pkg::Config).to receive(:version) { '4.99.0-56-dirty' }
|
|
90
|
+
expect(Pkg::Util::Version.final?).to be false
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'classifies dirty versions as final when allow_dirty_tree is set' do
|
|
94
|
+
allow(Pkg::Config).to receive(:allow_dirty_tree).and_return true
|
|
95
|
+
allow(Pkg::Config).to receive(:version) { '1.0.0-dirty' }
|
|
96
|
+
expect(Pkg::Util::Version.final?).to be true
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'classifies dirty nonfinal versions as not final even when allow_dirty_tree is set' do
|
|
100
|
+
allow(Pkg::Config).to receive(:allow_dirty_tree).and_return true
|
|
101
|
+
allow(Pkg::Config).to receive(:version) { '1.0.0-22-dirty' }
|
|
102
|
+
expect(Pkg::Util::Version.final?).to be false
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
context "#dash_version" do
|
|
107
|
+
versions = {
|
|
108
|
+
'5.3.0' => '5.3.0',
|
|
109
|
+
'5.3.0-18-gfbddc8f' => '5.3.0-18',
|
|
110
|
+
'5.3.0-18-gfbddc8f-dirty' => '5.3.0-18-dirty',
|
|
111
|
+
'0.7.0-rc1' => '0.7.0-rc1',
|
|
112
|
+
'0.7.0-rc1-63-g51ccc51' => '0.7.0-rc1-63',
|
|
113
|
+
'0.7.0-rc1-63-g51ccc51-dirty'=> '0.7.0-rc1-63-dirty',
|
|
114
|
+
}
|
|
115
|
+
versions.each do |describe, reformatted|
|
|
116
|
+
it "correctly returns #{reformatted} when #{describe} is the git describe version" do
|
|
117
|
+
allow(Pkg::Util::Git).to receive(:ref_type).and_return 'sha'
|
|
118
|
+
allow(Pkg::Util::Git).to receive(:describe).and_return describe
|
|
119
|
+
expect(Pkg::Util::Version.dash_version).to eq reformatted
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
# We load packaging.rb once, in spec_helper, to avoid reloading the library
|
|
4
|
+
# and issuing warnings about already defined constants.
|
|
5
|
+
describe "Pkg" do
|
|
6
|
+
it "should require the utilities module, Pkg::Util" do
|
|
7
|
+
Pkg::Util.should_not be_nil
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should require the configuration module, Pkg::Config" do
|
|
11
|
+
Pkg::Config.should_not be_nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should require the tar library, Pkg::Tar" do
|
|
15
|
+
Pkg::Tar.should_not be_nil
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rspec'
|
|
3
|
+
require 'pathname'
|
|
4
|
+
require 'rake'
|
|
5
|
+
|
|
6
|
+
SPECDIR = Pathname(__FILE__).dirname
|
|
7
|
+
PROJECT_ROOT = File.expand_path(File.join(Pathname(__FILE__).dirname, ".."))
|
|
8
|
+
FIXTURES = File.join(SPECDIR, 'fixtures')
|
|
9
|
+
|
|
10
|
+
require File.join(SPECDIR, '..', 'lib', 'packaging.rb')
|
|
11
|
+
|
|
12
|
+
def load_task(name)
|
|
13
|
+
return false if (@loaded ||= {})[name]
|
|
14
|
+
load File.join(SPECDIR, '..', 'tasks', name)
|
|
15
|
+
@loaded[name] = true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def reset_env(keys)
|
|
19
|
+
keys.each do |key|
|
|
20
|
+
ENV[key] = nil
|
|
21
|
+
end
|
|
22
|
+
end
|