simp-rake-helpers 5.24.0 → 6.0.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.
- checksums.yaml +4 -4
- data/.gitignore +20 -1
- data/CHANGELOG.md +33 -0
- data/Gemfile +14 -6
- data/lib/simp/command_utils.rb +6 -3
- data/lib/simp/componentinfo.rb +47 -33
- data/lib/simp/local_gpg_signing_key.rb +302 -303
- data/lib/simp/packer/iso_vars_json.rb +17 -15
- data/lib/simp/rake/build/auto.rb +415 -432
- data/lib/simp/rake/build/build.rb +119 -124
- data/lib/simp/rake/build/clean.rb +39 -39
- data/lib/simp/rake/build/code.rb +125 -128
- data/lib/simp/rake/build/constants.rb +7 -4
- data/lib/simp/rake/build/deps.rb +196 -207
- data/lib/simp/rake/build/helpers.rb +17 -13
- data/lib/simp/rake/build/iso.rb +404 -411
- data/lib/simp/rake/build/pkg.rb +752 -759
- data/lib/simp/rake/build/rpmdeps.rb +70 -70
- data/lib/simp/rake/build/spec.rb +44 -46
- data/lib/simp/rake/build/tar.rb +169 -173
- data/lib/simp/rake/build/unpack.rb +105 -107
- data/lib/simp/rake/build/upload.rb +93 -102
- data/lib/simp/rake/fixtures.rb +69 -66
- data/lib/simp/rake/helpers/rpm_spec.rb +10 -7
- data/lib/simp/rake/helpers/version.rb +3 -1
- data/lib/simp/rake/helpers.rb +12 -10
- data/lib/simp/rake/pkg.rb +417 -440
- data/lib/simp/rake/pupmod/helpers.rb +100 -87
- data/lib/simp/rake/pupmod/module_build.rb +39 -0
- data/lib/simp/rake/rubygem.rb +57 -56
- data/lib/simp/rake.rb +34 -29
- data/lib/simp/relchecks.rb +52 -43
- data/lib/simp/rpm.rb +123 -127
- data/lib/simp/rpm_signer.rb +57 -55
- data/lib/simp/yum.rb +54 -53
- data/spec/acceptance/nodesets/{default_ruby3_1.yml → almalinux10.yml} +4 -4
- data/spec/acceptance/nodesets/{default.yml → almalinux8.yml} +2 -2
- data/spec/acceptance/nodesets/almalinux9.yml +25 -0
- data/spec/acceptance/suites/default/00_pkg_rpm_custom_scriptlets_spec.rb +23 -28
- data/spec/acceptance/suites/default/10_pkg_rpm_spec.rb +54 -56
- data/spec/acceptance/suites/default/30_pkg_misc_spec.rb +17 -19
- data/spec/acceptance/suites/default/50_local_gpg_signing_key_spec.rb +5 -5
- data/spec/acceptance/suites/default/55_build_pkg_signing_spec.rb +109 -101
- data/spec/acceptance/suites/default/files/testpackage/spec/classes/init_spec.rb +1 -0
- data/spec/acceptance/suites/default/files/testpackage/spec/files/mock_something.rb +3 -1
- data/spec/acceptance/suites/default/files/testpackage/utils/convert_v1_to_v2.rb +2 -0
- data/spec/acceptance/suites/default/support/build_project_helpers.rb +20 -17
- data/spec/acceptance/suites/default/support/build_user_helpers.rb +4 -2
- data/spec/acceptance/suites/default/support/pkg_rpm_helpers.rb +30 -31
- data/spec/acceptance/support/simp_rake_helpers.rb +3 -1
- data/spec/lib/simp/command_utils_spec.rb +13 -10
- data/spec/lib/simp/componentinfo_changelog_regex_spec.rb +33 -33
- data/spec/lib/simp/componentinfo_spec.rb +99 -86
- data/spec/lib/simp/packer/iso_vars_json_spec.rb +16 -14
- data/spec/lib/simp/rake/build/helpers_spec.rb +7 -7
- data/spec/lib/simp/rake/build/rpmdeps_spec.rb +48 -46
- data/spec/lib/simp/rake/helpers_spec.rb +6 -5
- data/spec/lib/simp/rake/pkg_spec.rb +7 -5
- data/spec/lib/simp/rake/pupmod/fixtures/othermod/spec/classes/init_spec.rb +3 -1
- data/spec/lib/simp/rake/pupmod/fixtures/othermod/spec/spec_helper.rb +2 -0
- data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/acceptance/suites/default/class_spec.rb +6 -5
- data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/classes/init_spec.rb +51 -33
- data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/spec_helper.rb +15 -16
- data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/spec_helper_acceptance.rb +9 -9
- data/spec/lib/simp/rake/pupmod/helpers_spec.rb +20 -19
- data/spec/lib/simp/rake/pupmod/module_build_spec.rb +87 -0
- data/spec/lib/simp/rake_spec.rb +7 -6
- data/spec/lib/simp/relchecks_check_rpm_changelog_spec.rb +26 -31
- data/spec/lib/simp/relchecks_compare_latest_tag_spec.rb +32 -26
- data/spec/lib/simp/relchecks_create_tag_changelog_spec.rb +27 -19
- data/spec/lib/simp/rpm_signer_spec.rb +45 -39
- data/spec/lib/simp/rpm_spec.rb +190 -194
- data/spec/spec_helper.rb +4 -2
- data/spec/spec_helper_acceptance.rb +3 -5
- metadata +47 -76
- data/bin/simp_rake_helpers +0 -3
- data/lib/simp/ci/gitlab.rb +0 -226
- data/lib/simp/rake/ci.rb +0 -31
- data/spec/lib/simp/ci/files/global_nodesets_only/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/global_nodesets_only/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/nodesets/centos.yml +0 -41
- data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature-1/feature-1_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/feature_2_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/nodesets/default.yml +0 -35
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/nodesets/oel.yml +0 -35
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature-1/feature-1_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/feature_2_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/nodesets/default.yml +0 -35
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/nodesets/oel.yml +0 -35
- data/spec/lib/simp/ci/files/no_acceptance_tests/spec/spec_helper.rb +0 -0
- data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/no_gitlab_config_without_tests/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/no_gitlab_config_without_tests/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/centos.yml +0 -41
- data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/centos.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/gitlab_spec.rb +0 -245
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
require 'rake'
|
|
7
|
+
# The library defines `namespace :pupmod` at the top level, which requires
|
|
8
|
+
# Rake::DSL to be available. In a Rakefile this is implicit; here we make
|
|
9
|
+
# it explicit before loading the file under test. record_task_metadata must
|
|
10
|
+
# also be enabled before load, otherwise task descriptions are discarded.
|
|
11
|
+
extend Rake::DSL
|
|
12
|
+
|
|
13
|
+
Rake::TaskManager.record_task_metadata = true
|
|
14
|
+
|
|
15
|
+
require 'simp/rake/pupmod/module_build'
|
|
16
|
+
require 'spec_helper'
|
|
17
|
+
|
|
18
|
+
describe Simp::Rake::Pupmod::PdkCompatBuilder do
|
|
19
|
+
around(:each) do |example|
|
|
20
|
+
Dir.mktmpdir('module_build_spec') do |dir|
|
|
21
|
+
@source = dir
|
|
22
|
+
File.write(File.join(dir, 'metadata.json'), '{"name":"simp-test","version":"0.0.1"}')
|
|
23
|
+
example.run
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
let(:builder) { described_class.new(@source) }
|
|
28
|
+
|
|
29
|
+
describe '#ignored_files' do
|
|
30
|
+
context 'when no .pdkignore is present' do
|
|
31
|
+
it "delegates to the parent class's default ignore list" do
|
|
32
|
+
spec = builder.ignored_files
|
|
33
|
+
expect(spec).to be_a(PathSpec)
|
|
34
|
+
# Parent's IGNORED list includes /pkg/ and metadata.json is explicitly NOT ignored
|
|
35
|
+
expect(spec.match('pkg/')).to be true
|
|
36
|
+
expect(spec.match('metadata.json')).to be false
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context 'when a .pdkignore is present' do
|
|
41
|
+
before(:each) do
|
|
42
|
+
File.write(File.join(@source, '.pdkignore'), "/spec/\ncustom_excluded_dir/\n")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'returns a PathSpec built from the .pdkignore patterns' do
|
|
46
|
+
spec = builder.ignored_files
|
|
47
|
+
expect(spec).to be_a(PathSpec)
|
|
48
|
+
expect(spec.match('spec/')).to be true
|
|
49
|
+
expect(spec.match('custom_excluded_dir/')).to be true
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'ignores dotfiles in addition to patterns from .pdkignore' do
|
|
53
|
+
spec = builder.ignored_files
|
|
54
|
+
expect(spec.match('.git')).to be true
|
|
55
|
+
expect(spec.match('.travis.yml')).to be true
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'does not ignore files that are not listed' do
|
|
59
|
+
spec = builder.ignored_files
|
|
60
|
+
expect(spec.match('manifests/init.pp')).to be false
|
|
61
|
+
expect(spec.match('metadata.json')).to be false
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe 'pupmod:build rake task' do
|
|
68
|
+
before(:all) do
|
|
69
|
+
require 'rake'
|
|
70
|
+
# The task is registered at file load time; ensure it's defined.
|
|
71
|
+
require 'simp/rake/pupmod/module_build'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'is defined' do
|
|
75
|
+
expect(Rake::Task.task_defined?('pupmod:build')).to be true
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'has a description' do
|
|
79
|
+
expect(Rake::Task['pupmod:build'].comment).to match(%r{build the puppet module package}i)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'has a single action defined in module_build.rb' do
|
|
83
|
+
actions = Rake::Task['pupmod:build'].actions
|
|
84
|
+
expect(actions.size).to eq 1
|
|
85
|
+
expect(actions.first.source_location.first).to end_with('module_build.rb')
|
|
86
|
+
end
|
|
87
|
+
end
|
data/spec/lib/simp/rake_spec.rb
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'simp/rake'
|
|
2
4
|
require 'spec_helper'
|
|
3
5
|
|
|
4
6
|
describe Simp::Rake do
|
|
5
7
|
RSpec.configure do |c|
|
|
6
|
-
c.include
|
|
8
|
+
c.include described_class
|
|
7
9
|
end
|
|
8
10
|
|
|
9
|
-
describe
|
|
10
|
-
it
|
|
11
|
+
describe '.get_cpu_limit' do
|
|
12
|
+
it 'detects number of CPUs' do
|
|
11
13
|
expect(Parallel).to receive(:processor_count).and_return(3)
|
|
12
|
-
expect(
|
|
14
|
+
expect(get_cpu_limit).to eq 2
|
|
13
15
|
end
|
|
14
16
|
end
|
|
15
17
|
|
|
16
|
-
|
|
17
18
|
describe 'tests are missing' do
|
|
18
|
-
it '
|
|
19
|
+
it 'has more tests' do
|
|
19
20
|
skip 'TODO: write more tests'
|
|
20
21
|
end
|
|
21
22
|
end
|
|
@@ -1,59 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'simp/relchecks'
|
|
2
4
|
require 'spec_helper'
|
|
3
5
|
|
|
4
|
-
rpm_version = Simp::RPM.version
|
|
5
|
-
|
|
6
6
|
describe 'Simp::RelChecks.check_rpm_changelog' do
|
|
7
|
-
let(:files_dir)
|
|
8
|
-
File.join(
|
|
9
|
-
|
|
7
|
+
let(:files_dir) do
|
|
8
|
+
File.join(File.dirname(__FILE__), 'files', File.basename(__FILE__, '.rb'))
|
|
9
|
+
end
|
|
10
10
|
|
|
11
|
-
let(:templates_dir)
|
|
12
|
-
File.join(
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
let(:templates_dir) do
|
|
12
|
+
File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'simp', 'rake',
|
|
13
|
+
'helpers', 'assets', 'rpm_spec')
|
|
14
|
+
end
|
|
15
15
|
|
|
16
16
|
context 'with no project changelog errors' do
|
|
17
17
|
it 'succeeds for a Puppet module' do
|
|
18
18
|
component_dir = File.join(files_dir, 'module')
|
|
19
19
|
component_spec = File.join(templates_dir, 'simpdefault.spec')
|
|
20
20
|
|
|
21
|
-
expect{ Simp::RelChecks.check_rpm_changelog(component_dir, component_spec) }
|
|
22
|
-
|
|
21
|
+
expect { Simp::RelChecks.check_rpm_changelog(component_dir, component_spec) }
|
|
22
|
+
.not_to raise_error
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it 'succeeds for a non-Puppet asset' do
|
|
26
26
|
component_dir = File.join(files_dir, 'asset')
|
|
27
27
|
component_spec = File.join(component_dir, 'build', 'asset.spec')
|
|
28
28
|
|
|
29
|
-
expect{ Simp::RelChecks.check_rpm_changelog(component_dir, component_spec) }
|
|
30
|
-
|
|
29
|
+
expect { Simp::RelChecks.check_rpm_changelog(component_dir, component_spec) }
|
|
30
|
+
.not_to raise_error
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
context 'with changelog errors' do
|
|
35
|
+
# rpm >= 4.16 (EL9+) reports misordered changelog entries on stderr but
|
|
36
|
+
# exits 0; check_rpm_changelog detects the reported message, so these are
|
|
37
|
+
# expected to fail on every supported rpm version.
|
|
35
38
|
it 'fails for a Puppet module' do
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
expect{ Simp::RelChecks.check_rpm_changelog(component_dir, component_spec) }.
|
|
43
|
-
to raise_error(/ERROR: Invalid changelog for module_with_misordered_entries/)
|
|
44
|
-
end
|
|
39
|
+
component_dir = File.join(files_dir, 'module_with_misordered_entries')
|
|
40
|
+
component_spec = File.join(templates_dir, 'simpdefault.spec')
|
|
41
|
+
|
|
42
|
+
expect { Simp::RelChecks.check_rpm_changelog(component_dir, component_spec) }
|
|
43
|
+
.to raise_error(%r{ERROR: Invalid changelog for module_with_misordered_entries})
|
|
45
44
|
end
|
|
46
45
|
|
|
47
46
|
it 'fails for a non-Puppet asset' do
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
expect{ Simp::RelChecks.check_rpm_changelog(component_dir, component_spec) }.
|
|
55
|
-
to raise_error(/ERROR: Invalid changelog for asset_with_misordered_entries/)
|
|
56
|
-
end
|
|
47
|
+
component_dir = File.join(files_dir, 'asset_with_misordered_entries')
|
|
48
|
+
component_spec = File.join(component_dir, 'build', 'asset_with_misordered_entries.spec')
|
|
49
|
+
|
|
50
|
+
expect { Simp::RelChecks.check_rpm_changelog(component_dir, component_spec) }
|
|
51
|
+
.to raise_error(%r{ERROR: Invalid changelog for asset_with_misordered_entries})
|
|
57
52
|
end
|
|
58
53
|
end
|
|
59
54
|
end
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'simp/relchecks'
|
|
2
4
|
require 'spec_helper'
|
|
3
5
|
|
|
4
6
|
describe 'Simp::RelChecks.compare_latest_tag' do
|
|
5
|
-
let(:files_dir)
|
|
6
|
-
File.join(
|
|
7
|
-
|
|
7
|
+
let(:files_dir) do
|
|
8
|
+
File.join(File.dirname(__FILE__), 'files', File.basename(__FILE__, '.rb'))
|
|
9
|
+
end
|
|
8
10
|
|
|
9
|
-
let(:component_dir) {
|
|
11
|
+
let(:component_dir) { File.join(files_dir, 'module') }
|
|
10
12
|
|
|
11
13
|
context 'with no project errors' do
|
|
12
14
|
it 'reports no tags for a project with no tags' do
|
|
13
15
|
expect(Simp::RelChecks).to receive(:`).with('git fetch -t origin 2>/dev/null').and_return("\n")
|
|
14
16
|
expect(Simp::RelChecks).to receive(:`).with('git tag -l').and_return("\n")
|
|
15
17
|
|
|
16
|
-
expect{ Simp::RelChecks.compare_latest_tag(component_dir) }
|
|
17
|
-
to output(" No tags exist from origin\n").to_stdout
|
|
18
|
+
expect { Simp::RelChecks.compare_latest_tag(component_dir) }
|
|
19
|
+
.to output(" No tags exist from origin\n").to_stdout
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
it 'reports no new tag required when no files have changed' do
|
|
@@ -23,26 +25,28 @@ describe 'Simp::RelChecks.compare_latest_tag' do
|
|
|
23
25
|
expect(Simp::RelChecks).to receive(:`).with('git diff tags/1.1.0 --name-only').and_return("\n")
|
|
24
26
|
|
|
25
27
|
msg = " No new tag required: No significant files have changed since '1.1.0' tag\n"
|
|
26
|
-
expect{ Simp::RelChecks.compare_latest_tag(component_dir) }
|
|
27
|
-
to output(msg).to_stdout
|
|
28
|
+
expect { Simp::RelChecks.compare_latest_tag(component_dir) }
|
|
29
|
+
.to output(msg).to_stdout
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
it 'reports no new tag required when no significant files have changed' do
|
|
31
33
|
expect(Simp::RelChecks).to receive(:`).with('git fetch -t origin 2>/dev/null').and_return("\n")
|
|
32
34
|
expect(Simp::RelChecks).to receive(:`).with('git tag -l').and_return("1.0.0\nv1.0.1\n1.1.0\n")
|
|
33
35
|
expect(Simp::RelChecks).to receive(:`).with('git diff tags/1.1.0 --name-only').and_return(
|
|
34
|
-
".travis.yml\nRakefile\nREFERENCE.md\nGemfile.lock\nspec/some_spec.rb\ndoc/index.html\nrakelib/mytasks.rake\nrenovate.json\n"
|
|
36
|
+
".travis.yml\nRakefile\nREFERENCE.md\nGemfile.lock\nspec/some_spec.rb\ndoc/index.html\nrakelib/mytasks.rake\nrenovate.json\n",
|
|
37
|
+
)
|
|
35
38
|
|
|
36
39
|
msg = " No new tag required: No significant files have changed since '1.1.0' tag\n"
|
|
37
|
-
expect{ Simp::RelChecks.compare_latest_tag(component_dir) }
|
|
38
|
-
to output(msg).to_stdout
|
|
40
|
+
expect { Simp::RelChecks.compare_latest_tag(component_dir) }
|
|
41
|
+
.to output(msg).to_stdout
|
|
39
42
|
end
|
|
40
43
|
|
|
41
44
|
it 'reports a new tag is required for significant changes with bumped version' do
|
|
42
45
|
expect(Simp::RelChecks).to receive(:`).with('git fetch -t origin 2>/dev/null').and_return("\n")
|
|
43
46
|
expect(Simp::RelChecks).to receive(:`).with('git tag -l').and_return("1.0.0\n1.1.0-RC01\n")
|
|
44
47
|
expect(Simp::RelChecks).to receive(:`).with('git diff tags/1.0.0 --name-only').and_return(
|
|
45
|
-
|
|
48
|
+
"CHANGELOG\nmetadata.json\nmanifest/init.pp\n",
|
|
49
|
+
)
|
|
46
50
|
|
|
47
51
|
msg = <<-EOM
|
|
48
52
|
NOTICE: New tag of version '1.1.0' is required for 3 changed files:
|
|
@@ -51,8 +55,8 @@ NOTICE: New tag of version '1.1.0' is required for 3 changed files:
|
|
|
51
55
|
* manifest/init.pp
|
|
52
56
|
EOM
|
|
53
57
|
|
|
54
|
-
expect{ Simp::RelChecks.compare_latest_tag(component_dir) }
|
|
55
|
-
to output(msg).to_stdout
|
|
58
|
+
expect { Simp::RelChecks.compare_latest_tag(component_dir) }
|
|
59
|
+
.to output(msg).to_stdout
|
|
56
60
|
end
|
|
57
61
|
end
|
|
58
62
|
|
|
@@ -61,20 +65,22 @@ NOTICE: New tag of version '1.1.0' is required for 3 changed files:
|
|
|
61
65
|
expect(Simp::RelChecks).to receive(:`).with('git fetch -t origin 2>/dev/null').and_return("\n")
|
|
62
66
|
expect(Simp::RelChecks).to receive(:`).with('git tag -l').and_return("1.0.0\n1.2.0\n")
|
|
63
67
|
expect(Simp::RelChecks).to receive(:`).with('git diff tags/1.2.0 --name-only').and_return(
|
|
64
|
-
|
|
68
|
+
"CHANGELOG\nmetadata.json\nmanifest/init.pp\n",
|
|
69
|
+
)
|
|
65
70
|
|
|
66
|
-
expect{ Simp::RelChecks.compare_latest_tag(component_dir) }
|
|
67
|
-
to raise_error(
|
|
71
|
+
expect { Simp::RelChecks.compare_latest_tag(component_dir) }
|
|
72
|
+
.to raise_error(%r{ERROR: Version regression. '1\.1\.0' < last tag '1\.2\.0'})
|
|
68
73
|
end
|
|
69
74
|
|
|
70
75
|
it 'fails when significant file changes need a version bump' do
|
|
71
76
|
expect(Simp::RelChecks).to receive(:`).with('git fetch -t origin 2>/dev/null').and_return("\n")
|
|
72
77
|
expect(Simp::RelChecks).to receive(:`).with('git tag -l').and_return("1.0.0\n1.1.0\n")
|
|
73
78
|
expect(Simp::RelChecks).to receive(:`).with('git diff tags/1.1.0 --name-only').and_return(
|
|
74
|
-
|
|
79
|
+
"manifest/init.pp\n",
|
|
80
|
+
)
|
|
75
81
|
|
|
76
|
-
expect{ Simp::RelChecks.compare_latest_tag(component_dir) }
|
|
77
|
-
to raise_error(
|
|
82
|
+
expect { Simp::RelChecks.compare_latest_tag(component_dir) }
|
|
83
|
+
.to raise_error(%r{ERROR: Version update beyond last tag '1.1.0' is required for 1 changed files:})
|
|
78
84
|
end
|
|
79
85
|
|
|
80
86
|
# spot check just one of many failures handled by
|
|
@@ -82,8 +88,8 @@ NOTICE: New tag of version '1.1.0' is required for 3 changed files:
|
|
|
82
88
|
# extensively tested elsewhere.
|
|
83
89
|
it 'fails when module info cannot be loaded' do
|
|
84
90
|
comp_dir = File.join(files_dir, 'module_without_changelog')
|
|
85
|
-
expect{ Simp::RelChecks.compare_latest_tag(comp_dir) }
|
|
86
|
-
to raise_error(
|
|
91
|
+
expect { Simp::RelChecks.compare_latest_tag(comp_dir) }
|
|
92
|
+
.to raise_error(%r{No CHANGELOG file found in})
|
|
87
93
|
end
|
|
88
94
|
end
|
|
89
95
|
|
|
@@ -91,13 +97,13 @@ NOTICE: New tag of version '1.1.0' is required for 3 changed files:
|
|
|
91
97
|
# test to see if will be considered a valid CHANGELOG (useful for debugging)
|
|
92
98
|
context 'with custom CHANGELOG at $SIMP_SPEC_changelog' do
|
|
93
99
|
_changelog_file = ENV['SIMP_SPEC_changelog'].to_s
|
|
94
|
-
if File.file?(
|
|
100
|
+
if File.file?(_changelog_file)
|
|
95
101
|
it "validates the CHANGELOG file at '#{_changelog_file}'" do
|
|
96
|
-
comp_dir = File.dirname(
|
|
97
|
-
expect{ Simp::RelChecks.load_and_validate_changelog(comp_dir, true) }.not_to raise_error
|
|
102
|
+
comp_dir = File.dirname(_changelog_file)
|
|
103
|
+
expect { Simp::RelChecks.load_and_validate_changelog(comp_dir, true) }.not_to raise_error
|
|
98
104
|
end
|
|
99
105
|
else
|
|
100
|
-
|
|
106
|
+
skip 'This test is disabled by default.'
|
|
101
107
|
end
|
|
102
108
|
end
|
|
103
109
|
end
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'simp/relchecks'
|
|
2
4
|
require 'spec_helper'
|
|
3
5
|
|
|
4
6
|
describe 'Simp::RelChecks.create_tag_changelog' do
|
|
5
|
-
let(:files_dir)
|
|
6
|
-
File.join(
|
|
7
|
-
|
|
7
|
+
let(:files_dir) do
|
|
8
|
+
File.join(File.dirname(__FILE__), 'files', File.basename(__FILE__, '.rb'))
|
|
9
|
+
end
|
|
8
10
|
|
|
9
11
|
describe '.create_tag_changelog' do
|
|
10
12
|
context 'with valid module input' do
|
|
@@ -45,26 +47,30 @@ EOM
|
|
|
45
47
|
context 'with invalid module input' do
|
|
46
48
|
it 'fails when module info cannot be loaded' do
|
|
47
49
|
component_dir = File.join(files_dir, 'module_without_changelog')
|
|
48
|
-
expect{ Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
49
|
-
|
|
50
|
+
expect { Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
51
|
+
%r{No CHANGELOG file found in .*module_without_changelog},
|
|
52
|
+
)
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
it 'fails if no valid entry for the version can be found' do
|
|
53
56
|
component_dir = File.join(files_dir, 'module_with_no_entry_for_version')
|
|
54
|
-
expect{ Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
55
|
-
|
|
57
|
+
expect { Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
58
|
+
%r{No valid changelog entry for version 4.0.0 found},
|
|
59
|
+
)
|
|
56
60
|
end
|
|
57
61
|
|
|
58
62
|
it 'fails if entry with newer version than metadata.json is found' do
|
|
59
63
|
component_dir = File.join(files_dir, 'module_with_newer_changelog_entry')
|
|
60
|
-
expect{ Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
61
|
-
|
|
64
|
+
expect { Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
65
|
+
%r{Changelog entry for version > 3.8.0 found:},
|
|
66
|
+
)
|
|
62
67
|
end
|
|
63
68
|
|
|
64
69
|
it "fails if dates are out of order for the version's changelog entries" do
|
|
65
70
|
component_dir = File.join(files_dir, 'module_with_misordered_entries')
|
|
66
|
-
expect{ Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
67
|
-
|
|
71
|
+
expect { Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
72
|
+
%r{ERROR: Changelog entries are not properly date ordered},
|
|
73
|
+
)
|
|
68
74
|
end
|
|
69
75
|
end
|
|
70
76
|
|
|
@@ -117,26 +123,28 @@ EOM
|
|
|
117
123
|
end
|
|
118
124
|
|
|
119
125
|
context 'with invalid asset input' do
|
|
120
|
-
|
|
121
126
|
it 'fails when asset info cannot be loaded' do
|
|
122
127
|
component_dir = File.join(files_dir, 'asset_without_spec_file')
|
|
123
|
-
expect{ Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
124
|
-
|
|
128
|
+
expect { Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
129
|
+
%r{No RPM spec file found in .*asset_without_spec_file/build},
|
|
130
|
+
)
|
|
125
131
|
end
|
|
126
132
|
|
|
127
133
|
it 'fails when changelog is missing from asset RPM spec file' do
|
|
128
|
-
#NOTE: %changelog is optional in a spec file. So this error
|
|
134
|
+
# NOTE: %changelog is optional in a spec file. So this error
|
|
129
135
|
# is not found when the changelog is read from the spec
|
|
130
136
|
# file, but, instead, during post-validation
|
|
131
137
|
component_dir = File.join(files_dir, 'asset_missing_changelog')
|
|
132
|
-
expect{ Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
133
|
-
|
|
138
|
+
expect { Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
139
|
+
%r{No valid changelog entry for version 1.0.0 found},
|
|
140
|
+
)
|
|
134
141
|
end
|
|
135
142
|
|
|
136
143
|
it 'fails when release tag and release in changelog from asset RPM spec file are mismatched' do
|
|
137
144
|
component_dir = File.join(files_dir, 'asset_mismatched_release')
|
|
138
|
-
expect{ Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
139
|
-
|
|
145
|
+
expect { Simp::RelChecks.create_tag_changelog(component_dir) }.to raise_error(
|
|
146
|
+
%r{Version release does not match},
|
|
147
|
+
)
|
|
140
148
|
end
|
|
141
149
|
end
|
|
142
150
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'simp/rpm_signer'
|
|
2
4
|
require 'spec_helper'
|
|
3
5
|
require 'fileutils'
|
|
4
6
|
require 'tmpdir'
|
|
5
7
|
|
|
6
|
-
|
|
7
8
|
describe Simp::RpmSigner do
|
|
8
|
-
|
|
9
9
|
before :all do
|
|
10
10
|
@tmp_dir = Dir.mktmpdir('spec_test__rpm_signer')
|
|
11
11
|
@gpg_keydir = File.join(@tmp_dir, 'dev')
|
|
@@ -15,83 +15,89 @@ describe Simp::RpmSigner do
|
|
|
15
15
|
FileUtils.remove_entry_secure(@tmp_dir)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
let(:verbose) { ENV['VERBOSE'].to_s =~
|
|
18
|
+
let(:verbose) { ENV['VERBOSE'].to_s =~ %r{^(yes|true)$} }
|
|
19
19
|
let(:gpg_email_name) { 'gatekeeper@simp.development.key' }
|
|
20
20
|
let(:passphrase) { 'dev_passphrase' }
|
|
21
21
|
let(:key_id) { '722B97A808E7DAEA' }
|
|
22
22
|
let(:key_size) { 4096 }
|
|
23
|
-
let(:key_info)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
let(:key_info) do
|
|
24
|
+
{
|
|
25
|
+
:dir => @gpg_keydir,
|
|
26
|
+
:name => gpg_email_name,
|
|
27
|
+
:key_id => key_id,
|
|
28
|
+
:key_size => key_size,
|
|
29
|
+
:password => passphrase
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
let(:gpg_cmd) { "gpg --with-colons --homedir=#{@gpg_keydir} --list-keys '<#{gpg_email_name}>' 2>&1" }
|
|
34
|
+
let(:key_list_output) do
|
|
35
|
+
<<~EOM
|
|
33
36
|
tru::1:1521838828:0:3:1:5
|
|
34
37
|
pub:e:4096:1:722B97A808E7DAEA:1521838554:1523048154::-:::sc::::::23::0:
|
|
35
38
|
fpr:::::::::5DD3E8D45C99780DCA7D0B83722B97A808E7DAEA:
|
|
36
39
|
uid:e::::1521838554::773C55CA511CCE31244D86D4AB70F6499024695F::SIMP Development (Development key 1521838554) <gatekeeper@simp.development.key>::::::::::0:
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
EOM
|
|
41
|
+
end
|
|
39
42
|
|
|
40
43
|
# The bulk of load_key is tested in the acceptance test. These tests are
|
|
41
44
|
# a few edge cases.
|
|
42
|
-
|
|
45
|
+
describe '.load_key' do
|
|
43
46
|
context 'key info missing from files' do
|
|
44
47
|
before :each do
|
|
45
|
-
allow(
|
|
48
|
+
allow(described_class).to receive(:which).with('gpg').and_return('/usr/bin/gpg')
|
|
46
49
|
FileUtils.mkdir_p(@gpg_keydir)
|
|
47
50
|
end
|
|
48
51
|
|
|
49
52
|
after :each do
|
|
50
53
|
FileUtils.rm_rf(@gpg_keydir)
|
|
51
|
-
|
|
54
|
+
described_class.clear_gpg_keys_cache
|
|
52
55
|
end
|
|
53
56
|
|
|
54
|
-
it '
|
|
57
|
+
it 'prompts user for key email and passphrase when not in files' do
|
|
55
58
|
expect($stdin).to receive(:gets).and_return(gpg_email_name, passphrase)
|
|
56
|
-
expect(
|
|
59
|
+
expect(described_class).to receive(:`).with(gpg_cmd).and_return(key_list_output)
|
|
57
60
|
|
|
58
|
-
expect(
|
|
61
|
+
expect(described_class.load_key(@gpg_keydir, verbose)).to eq(key_info)
|
|
59
62
|
|
|
60
63
|
# verifies returning info from the cache, otherwise user would be prompted again
|
|
61
64
|
# and expectation on $stdin would fail
|
|
62
|
-
expect(
|
|
65
|
+
expect(described_class.load_key(@gpg_keydir, verbose)).to eq(key_info)
|
|
63
66
|
end
|
|
64
67
|
|
|
65
|
-
it "
|
|
66
|
-
File.open(File.join(@gpg_keydir, 'password'),'w') { |file| file.puts passphrase }
|
|
68
|
+
it "reads the passphrase from the 'password' file" do
|
|
69
|
+
File.open(File.join(@gpg_keydir, 'password'), 'w') { |file| file.puts passphrase }
|
|
67
70
|
expect($stdin).to receive(:gets).and_return(gpg_email_name)
|
|
68
|
-
expect(
|
|
71
|
+
expect(described_class).to receive(:`).with(gpg_cmd).and_return(key_list_output)
|
|
69
72
|
|
|
70
|
-
expect(
|
|
73
|
+
expect(described_class.load_key(@gpg_keydir, verbose)).to eq(key_info)
|
|
71
74
|
end
|
|
72
75
|
end
|
|
73
76
|
|
|
74
77
|
context 'errors' do
|
|
75
|
-
it '
|
|
76
|
-
expect(
|
|
77
|
-
expect {
|
|
78
|
-
|
|
78
|
+
it 'fails when gpg does not exist' do
|
|
79
|
+
expect(described_class).to receive(:which).with('gpg').and_return(nil)
|
|
80
|
+
expect { described_class.load_key(@gpg_keydir, verbose) }.to raise_error(
|
|
81
|
+
%r{Cannot sign RPMs without 'gpg'},
|
|
82
|
+
)
|
|
79
83
|
end
|
|
80
84
|
|
|
81
|
-
it '
|
|
82
|
-
expect(
|
|
83
|
-
expect {
|
|
84
|
-
|
|
85
|
+
it 'fails when keydir does not exist' do
|
|
86
|
+
expect(described_class).to receive(:which).with('gpg').and_return('/usr/bin/gpg')
|
|
87
|
+
expect { described_class.load_key(@gpg_keydir, verbose) }.to raise_error(
|
|
88
|
+
%r{Could not find GPG keydir},
|
|
89
|
+
)
|
|
85
90
|
end
|
|
86
91
|
|
|
87
|
-
it '
|
|
92
|
+
it 'fails when key info cannot be retrieved via gpg' do
|
|
88
93
|
FileUtils.mkdir_p(@gpg_keydir)
|
|
89
|
-
expect(
|
|
94
|
+
expect(described_class).to receive(:which).with('gpg').and_return('/usr/bin/gpg')
|
|
90
95
|
expect($stdin).to receive(:gets).and_return(gpg_email_name, passphrase)
|
|
91
|
-
expect(
|
|
96
|
+
expect(described_class).to receive(:`).with(gpg_cmd).and_return('')
|
|
92
97
|
|
|
93
|
-
expect {
|
|
94
|
-
|
|
98
|
+
expect { described_class.load_key(@gpg_keydir, verbose) }.to raise_error(
|
|
99
|
+
%r{Error getting GPG key ID or Key size metadata},
|
|
100
|
+
)
|
|
95
101
|
end
|
|
96
102
|
end
|
|
97
103
|
end
|