simp-rake-helpers 5.25.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/CHANGELOG.md +26 -0
- data/Gemfile +13 -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 +37 -72
- 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
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'voxpupuli/test/rake'
|
|
4
|
+
require 'metadata-json-lint/rake_task'
|
|
2
5
|
require 'puppet/version'
|
|
3
6
|
require 'puppet-syntax/tasks/puppet-syntax'
|
|
4
7
|
require 'puppet-lint/tasks/puppet-lint'
|
|
5
|
-
require 'simp/rake/ci'
|
|
6
8
|
require 'simp/rake/pkg'
|
|
7
9
|
require 'simp/rake/beaker'
|
|
8
10
|
require 'parallel_tests/cli'
|
|
9
11
|
require 'simp/rake/fixtures'
|
|
10
12
|
|
|
11
13
|
if Puppet.version.to_f >= 4.9
|
|
12
|
-
|
|
14
|
+
require 'semantic_puppet'
|
|
13
15
|
elsif Puppet.version.to_f >= 3.6 && Puppet.version.to_f < 4.9
|
|
14
|
-
|
|
16
|
+
require 'puppet/vendor/semantic/lib/semantic'
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
module Simp; end
|
|
@@ -21,33 +23,32 @@ module Simp::Rake::Pupmod; end
|
|
|
21
23
|
# From http://dan.doezema.com/2012/04/recursively-sort-ruby-hash-by-key/
|
|
22
24
|
class Hash
|
|
23
25
|
def sort_by_key(recursive = false, &block)
|
|
24
|
-
|
|
26
|
+
keys.sort(&block).each_with_object({}) do |key, seed|
|
|
25
27
|
seed[key] = self[key]
|
|
26
28
|
if recursive && seed[key].is_a?(Hash)
|
|
27
29
|
seed[key] = seed[key].sort_by_key(true, &block)
|
|
28
30
|
end
|
|
29
|
-
seed
|
|
30
31
|
end
|
|
31
32
|
end
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
# Rake tasks for SIMP Puppet modules
|
|
35
|
-
class Simp::Rake::Pupmod::Helpers <
|
|
36
|
+
class Simp::Rake::Pupmod::Helpers < Rake::TaskLib
|
|
36
37
|
# See https://fedoraproject.org/wiki/Packaging:Guidelines?rd=Packaging/Guidelines#Changelogs
|
|
37
|
-
CHANGELOG_ENTRY_REGEX =
|
|
38
|
+
CHANGELOG_ENTRY_REGEX = %r{^\*\s+((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{1,2} \d{4})\s+(.+<.+>)(?:\s+|\s*-\s*)?(\d+\.\d+\.\d+)}.freeze
|
|
38
39
|
|
|
39
|
-
def initialize(
|
|
40
|
+
def initialize(base_dir = Dir.pwd)
|
|
40
41
|
@base_dir = base_dir
|
|
41
|
-
@temp_fixtures_path = File.join(base_dir,'spec','fixtures','simp_rspec')
|
|
42
|
+
@temp_fixtures_path = File.join(base_dir, 'spec', 'fixtures', 'simp_rspec')
|
|
42
43
|
|
|
43
44
|
FileUtils.mkdir_p(@temp_fixtures_path)
|
|
44
45
|
|
|
45
|
-
Dir[
|
|
46
|
+
Dir[File.join(File.dirname(__FILE__), '*.rb')].sort.each do |rake_file|
|
|
46
47
|
next if rake_file == __FILE__
|
|
48
|
+
|
|
47
49
|
require rake_file
|
|
48
50
|
end
|
|
49
51
|
define_tasks
|
|
50
|
-
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
def define_tasks
|
|
@@ -56,18 +57,18 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
56
57
|
begin
|
|
57
58
|
require 'puppet_blacksmith/rake_tasks'
|
|
58
59
|
Blacksmith::RakeTask.new do |t|
|
|
59
|
-
t.tag_pattern =
|
|
60
|
+
t.tag_pattern = '%s' # Use tag format "X.Y.Z" instead of "vX.Y.Z"
|
|
60
61
|
end
|
|
61
62
|
rescue LoadError
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
# Lint & Syntax exclusions
|
|
65
66
|
exclude_paths = [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
'bundle/**/*',
|
|
68
|
+
'pkg/**/*',
|
|
69
|
+
'dist/**/*',
|
|
70
|
+
'vendor/**/*',
|
|
71
|
+
'spec/**/*',
|
|
71
72
|
]
|
|
72
73
|
PuppetSyntax.exclude_paths = exclude_paths
|
|
73
74
|
|
|
@@ -78,18 +79,16 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
78
79
|
config.ignore_paths = PuppetLint.configuration.ignore_paths
|
|
79
80
|
end
|
|
80
81
|
|
|
81
|
-
Simp::Rake::Fixtures.new(
|
|
82
|
+
Simp::Rake::Fixtures.new(@base_dir)
|
|
82
83
|
|
|
83
|
-
Simp::Rake::Pkg.new(
|
|
84
|
+
Simp::Rake::Pkg.new(@base_dir) do |t|
|
|
84
85
|
t.clean_list << "#{t.base_dir}/spec/fixtures/hieradata/hiera.yaml"
|
|
85
86
|
t.clean_list << @temp_fixtures_path
|
|
86
87
|
end
|
|
87
88
|
|
|
88
|
-
Simp::Rake::Beaker.new(
|
|
89
|
+
Simp::Rake::Beaker.new(@base_dir)
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
desc "Run acceptance tests"
|
|
91
|
+
desc 'Run acceptance tests'
|
|
93
92
|
RSpec::Core::RakeTask.new(:acceptance) do |t|
|
|
94
93
|
t.pattern = 'spec/acceptance'
|
|
95
94
|
end
|
|
@@ -100,17 +99,17 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
100
99
|
end
|
|
101
100
|
|
|
102
101
|
desc 'lint metadata.json'
|
|
103
|
-
Rake::Task[:metadata].clear if Rake::Task.tasks.any?{ |x| x.name == 'metadata' }
|
|
102
|
+
Rake::Task[:metadata].clear if Rake::Task.tasks.any? { |x| x.name == 'metadata' }
|
|
104
103
|
task :metadata => :metadata_lint
|
|
105
104
|
|
|
106
105
|
# Read the metadata.json as a data structure
|
|
107
|
-
def metadata(
|
|
106
|
+
def metadata(file_path = nil)
|
|
108
107
|
require 'json'
|
|
109
108
|
_file = file_path || File.join(@base_dir, 'metadata.json')
|
|
110
|
-
|
|
111
|
-
@metadata ||= JSON.parse( File.read(_file) )
|
|
112
|
-
end
|
|
109
|
+
raise "ERROR: file not found: '#{_file}'" unless File.exist? _file
|
|
113
110
|
|
|
111
|
+
@metadata ||= JSON.parse(File.read(_file))
|
|
112
|
+
end
|
|
114
113
|
|
|
115
114
|
# Generate an appropriate annotated tag entry from the modules' CHANGELOG
|
|
116
115
|
#
|
|
@@ -121,23 +120,23 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
121
120
|
# 4.0.0-2
|
|
122
121
|
# - Improved test stubs.
|
|
123
122
|
#
|
|
124
|
-
def changelog_annotation(
|
|
125
|
-
result =
|
|
123
|
+
def changelog_annotation(quiet = false, file = nil)
|
|
124
|
+
result = ''
|
|
126
125
|
changelog_file = file || File.join(@base_dir, 'CHANGELOG')
|
|
127
126
|
module_version = metadata['version']
|
|
128
|
-
changelogs
|
|
127
|
+
changelogs = {}
|
|
129
128
|
|
|
130
129
|
_entry = {} # current log entry's metadata (empty unless valid entry)
|
|
131
130
|
File.read(changelog_file).each_line do |line|
|
|
132
|
-
if line =~
|
|
131
|
+
if line =~ %r{^\*}
|
|
133
132
|
if CHANGELOG_ENTRY_REGEX.match(line).nil?
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
warn %(WARNING: invalid changelogs entry: "#{line}") unless quiet
|
|
134
|
+
_entry = {}
|
|
136
135
|
else
|
|
137
136
|
_entry = {
|
|
138
|
-
:date
|
|
139
|
-
:user
|
|
140
|
-
:release =>
|
|
137
|
+
:date => ::Regexp.last_match(1),
|
|
138
|
+
:user => ::Regexp.last_match(2),
|
|
139
|
+
:release => ::Regexp.last_match(3)
|
|
141
140
|
}
|
|
142
141
|
changelogs[_entry[:release]] ||= []
|
|
143
142
|
changelogs[_entry[:release]] << line
|
|
@@ -149,29 +148,29 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
149
148
|
changelogs[_entry[:release]] << " #{line}" if _entry.fetch(:release, false)
|
|
150
149
|
end
|
|
151
150
|
|
|
152
|
-
|
|
151
|
+
raise "Did not find any changelogs entries for version #{module_version}" if changelogs[module_version].nil?
|
|
153
152
|
|
|
154
153
|
result += "\nRelease of #{module_version}\n\n"
|
|
155
|
-
result
|
|
154
|
+
result + changelogs[module_version].join
|
|
156
155
|
end
|
|
157
156
|
|
|
158
157
|
def custom_fixtures_hook(opts = {
|
|
159
|
-
:short_name
|
|
160
|
-
:puppetfile
|
|
161
|
-
:modulepath
|
|
162
|
-
:local_fixtures_mods => nil
|
|
158
|
+
:short_name => nil,
|
|
159
|
+
:puppetfile => nil,
|
|
160
|
+
:modulepath => nil,
|
|
161
|
+
:local_fixtures_mods => nil
|
|
163
162
|
})
|
|
164
163
|
short_name = opts[:short_name]
|
|
165
164
|
puppetfile = opts[:puppetfile]
|
|
166
165
|
modulepath = opts[:modulepath]
|
|
167
166
|
local_fixtures_mods = opts[:local_fixtures_mods] || []
|
|
168
167
|
|
|
169
|
-
|
|
168
|
+
raise('You must pass a short module name') unless short_name
|
|
170
169
|
|
|
171
170
|
fixtures_hash = {
|
|
172
171
|
'fixtures' => {
|
|
173
172
|
'symlinks' => {
|
|
174
|
-
short_name =>
|
|
173
|
+
short_name => source_dir.to_s
|
|
175
174
|
}
|
|
176
175
|
}
|
|
177
176
|
}
|
|
@@ -180,20 +179,20 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
180
179
|
|
|
181
180
|
if modulepath
|
|
182
181
|
unless File.directory?(modulepath)
|
|
183
|
-
|
|
182
|
+
raise("Could not find a module directory at #{modulepath}")
|
|
184
183
|
end
|
|
185
184
|
|
|
186
185
|
# Grab all of the local modules and convert them into something
|
|
187
186
|
# that can be turned into a Hash easily
|
|
188
|
-
local_modules =
|
|
187
|
+
local_modules = Dir.glob(File.join(modulepath, '*', 'metadata.json')).to_h do |m|
|
|
189
188
|
[File.basename(File.dirname(m)), File.absolute_path(File.dirname(m))]
|
|
190
|
-
end
|
|
189
|
+
end
|
|
191
190
|
|
|
192
191
|
local_modules.delete(short_name)
|
|
193
192
|
end
|
|
194
193
|
|
|
195
194
|
if puppetfile
|
|
196
|
-
|
|
195
|
+
raise("Could not find Puppetfile at #{puppetfile}") unless File.exist?(puppetfile)
|
|
197
196
|
|
|
198
197
|
require 'simp/rake/build/deps'
|
|
199
198
|
|
|
@@ -223,7 +222,7 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
223
222
|
|
|
224
223
|
fixtures_hash['fixtures']['repositories'][pupmod[:name]] = {
|
|
225
224
|
'repo' => pupmod[:remote],
|
|
226
|
-
'ref'
|
|
225
|
+
'ref' => pupmod[:desired_ref]
|
|
227
226
|
}
|
|
228
227
|
end
|
|
229
228
|
end
|
|
@@ -238,11 +237,11 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
238
237
|
end
|
|
239
238
|
end
|
|
240
239
|
|
|
241
|
-
if local_fixtures_mods.empty?
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
240
|
+
custom_fixtures_path = if local_fixtures_mods.empty?
|
|
241
|
+
File.join(@temp_fixtures_path, 'fixtures.yml')
|
|
242
|
+
else
|
|
243
|
+
File.join(@temp_fixtures_path, 'fixtures_tmp.yml')
|
|
244
|
+
end
|
|
246
245
|
|
|
247
246
|
if puppetfile || modulepath
|
|
248
247
|
File.open(custom_fixtures_path, 'w') do |fh|
|
|
@@ -254,15 +253,15 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
254
253
|
errmsg = [
|
|
255
254
|
'===',
|
|
256
255
|
'The following modules in .fixtures.yml were not found in the Puppetfile:',
|
|
257
|
-
%
|
|
258
|
-
%
|
|
259
|
-
'==='
|
|
256
|
+
%( * #{local_fixtures_mods.join("\n * ")}),
|
|
257
|
+
%(A temporary fixtures file has been written to #{custom_fixtures_path}),
|
|
258
|
+
'===',
|
|
260
259
|
]
|
|
261
260
|
|
|
262
|
-
|
|
261
|
+
raise(errmsg.join("\n"))
|
|
263
262
|
end
|
|
264
263
|
|
|
265
|
-
|
|
264
|
+
custom_fixtures_path
|
|
266
265
|
end
|
|
267
266
|
|
|
268
267
|
desc <<-EOM
|
|
@@ -289,10 +288,10 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
289
288
|
# `rpm -q --specfile dist/tmp/*.spec --changelog`
|
|
290
289
|
# That will give Travis a way of warning us if the changelog
|
|
291
290
|
# will prevent the rpm from building.
|
|
292
|
-
task :changelog_annotation, [:quiet] do |
|
|
291
|
+
task :changelog_annotation, [:quiet] do |_t, args|
|
|
293
292
|
warn('DEPRECATED: use pkg:create_tag_changelog')
|
|
294
293
|
quiet = true if args[:quiet].to_s == 'true'
|
|
295
|
-
puts changelog_annotation(
|
|
294
|
+
puts changelog_annotation(quiet)
|
|
296
295
|
end
|
|
297
296
|
|
|
298
297
|
desc <<-EOM
|
|
@@ -332,7 +331,7 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
332
331
|
- spec directory
|
|
333
332
|
- doc directory
|
|
334
333
|
EOM
|
|
335
|
-
task :compare_latest_tag, [:tags_source, :ignore_owner, :verbose] do |
|
|
334
|
+
task :compare_latest_tag, [:tags_source, :ignore_owner, :verbose] do |_t, args|
|
|
336
335
|
warn('DEPRECATED: use pkg:compare_latest_tag')
|
|
337
336
|
require 'json'
|
|
338
337
|
|
|
@@ -341,24 +340,24 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
341
340
|
verbose = true if args[:verbose].to_s == 'true'
|
|
342
341
|
|
|
343
342
|
module_version = metadata['version']
|
|
344
|
-
owner =
|
|
343
|
+
owner = metadata['name'].split('-')[0]
|
|
345
344
|
|
|
346
|
-
if (owner == 'simp')
|
|
345
|
+
if (owner == 'simp') || ignore_owner
|
|
347
346
|
# determine last tag
|
|
348
347
|
`git fetch -t #{tags_source} 2>/dev/null`
|
|
349
348
|
tags = `git tag -l`.split("\n")
|
|
350
349
|
puts "Available tags from #{tags_source} = #{tags}" if verbose
|
|
351
|
-
tags.delete_if { |tag| tag.include?('-') or (tag =~
|
|
350
|
+
tags.delete_if { |tag| tag.include?('-') or (tag =~ %r{^v}) }
|
|
352
351
|
|
|
353
352
|
if tags.empty?
|
|
354
353
|
puts "No tags exist from #{tags_source}"
|
|
355
354
|
else
|
|
356
|
-
last_tag =
|
|
355
|
+
last_tag = tags.max { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }
|
|
357
356
|
|
|
358
357
|
# determine mission-impacting files that have changed
|
|
359
358
|
files_changed = `git diff tags/#{last_tag} --name-only`.strip.split("\n")
|
|
360
359
|
files_changed.delete_if do |file|
|
|
361
|
-
file[0] == '.' || file =~
|
|
360
|
+
file[0] == '.' || file =~ %r{^Gemfile} || file == 'Rakefile' || file =~ %r{^spec/} || file =~ %r{^doc/} || file =~ %r{^rakelib/}
|
|
362
361
|
end
|
|
363
362
|
|
|
364
363
|
if files_changed.empty?
|
|
@@ -367,15 +366,15 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
367
366
|
unless ignore_owner
|
|
368
367
|
# determine latest version from CHANGELOG, which will present
|
|
369
368
|
# for all SIMP Puppet modules
|
|
370
|
-
line =
|
|
371
|
-
match = line.match(
|
|
369
|
+
line = File.readlines('CHANGELOG')[0]
|
|
370
|
+
match = line.match(%r{^\*\s+((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{2} \d{4})\s+(.+<.+>)(?:\s+|\s*-\s*)?(\d+\.\d+\.\d+)})
|
|
372
371
|
unless match
|
|
373
|
-
|
|
372
|
+
raise("ERROR: Invalid CHANGELOG entry. Unable to extract version from '#{line}'")
|
|
374
373
|
end
|
|
375
374
|
|
|
376
375
|
changelog_version = match[3]
|
|
377
376
|
unless module_version == changelog_version
|
|
378
|
-
|
|
377
|
+
raise("ERROR: Version mismatch. module version=#{module_version} changelog version=#{changelog_version}")
|
|
379
378
|
end
|
|
380
379
|
end
|
|
381
380
|
|
|
@@ -383,9 +382,9 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
383
382
|
last_tag_version = Gem::Version.new(last_tag)
|
|
384
383
|
|
|
385
384
|
if curr_module_version < last_tag_version
|
|
386
|
-
|
|
385
|
+
raise("ERROR: Version regression. '#{module_version}' < last tag '#{last_tag}'")
|
|
387
386
|
elsif curr_module_version == last_tag_version
|
|
388
|
-
|
|
387
|
+
raise("ERROR: Version update beyond last tag '#{last_tag}' is required for #{files_changed.count} changed files:\n * #{files_changed.join("\n * ")}")
|
|
389
388
|
else
|
|
390
389
|
puts "NOTICE: New tag of version '#{module_version}' is required for #{files_changed.count} changed files:\n * #{files_changed.join("\n * ")}"
|
|
391
390
|
end
|
|
@@ -396,7 +395,7 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
396
395
|
end
|
|
397
396
|
end
|
|
398
397
|
|
|
399
|
-
desc
|
|
398
|
+
desc 'Run syntax, lint, and spec tests.'
|
|
400
399
|
task :test => [
|
|
401
400
|
:syntax,
|
|
402
401
|
:lint,
|
|
@@ -414,14 +413,28 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
414
413
|
if ENV['SIMP_PARALLEL_TARGETS']
|
|
415
414
|
test_targets += ENV['SIMP_PARALLEL_TARGETS'].split
|
|
416
415
|
end
|
|
417
|
-
test_targets.delete_if{|dir| !File.directory?(dir)}
|
|
418
|
-
Rake::Task[:
|
|
416
|
+
test_targets.delete_if { |dir| !File.directory?(dir) }
|
|
417
|
+
Rake::Task['fixtures:prep'].invoke
|
|
419
418
|
ParallelTests::CLI.new.run('--type test -t rspec'.split + test_targets)
|
|
420
419
|
if ENV.fetch('SPEC_clean', 'no') == 'yes'
|
|
421
|
-
Rake::Task[:
|
|
420
|
+
Rake::Task['fixtures:clean'].invoke
|
|
422
421
|
end
|
|
423
422
|
end
|
|
424
423
|
|
|
424
|
+
# Backwards-compatible aliases for the task names that
|
|
425
|
+
# puppetlabs_spec_helper provided before the migration to voxpupuli-test.
|
|
426
|
+
# voxpupuli-test/puppet_fixtures namespace these under fixtures:/spec:.
|
|
427
|
+
{
|
|
428
|
+
'spec_prep' => 'fixtures:prep',
|
|
429
|
+
'spec_clean' => 'fixtures:clean',
|
|
430
|
+
'spec_standalone' => 'spec:standalone'
|
|
431
|
+
}.each do |old_name, new_name|
|
|
432
|
+
next if Rake::Task.task_defined?(old_name)
|
|
433
|
+
|
|
434
|
+
desc "Alias for #{new_name}"
|
|
435
|
+
task old_name => new_name
|
|
436
|
+
end
|
|
437
|
+
|
|
425
438
|
# This hidden task provides a way to create and use a fixtures.yml file
|
|
426
439
|
# based on an externally specified Puppetfile
|
|
427
440
|
#
|
|
@@ -453,8 +466,8 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
453
466
|
|
|
454
467
|
puppetfile_tgt = File.join(@temp_fixtures_path, 'Puppetfile')
|
|
455
468
|
|
|
456
|
-
if puppetfile
|
|
457
|
-
|
|
469
|
+
if puppetfile.include?('://')
|
|
470
|
+
`curl -k -s -o #{puppetfile_tgt} #{puppetfile}`
|
|
458
471
|
else
|
|
459
472
|
FileUtils.cp(File.absolute_path(puppetfile), puppetfile_tgt)
|
|
460
473
|
end
|
|
@@ -468,13 +481,13 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
468
481
|
|
|
469
482
|
if opts[:puppetfile] || opts[:modulepath]
|
|
470
483
|
unless @custom_fixtures_hook_override_fixtures
|
|
471
|
-
|
|
484
|
+
raise("Could not find '.fixtures.yml' at #{Dir.pwd}") unless File.exist?('.fixtures.yml')
|
|
472
485
|
|
|
473
486
|
opts[:local_fixtures_mods] = []
|
|
474
487
|
|
|
475
488
|
require 'yaml'
|
|
476
489
|
_fixtures = YAML.load_file('.fixtures.yml')['fixtures']
|
|
477
|
-
_fixtures.
|
|
490
|
+
_fixtures.each_key do |subset|
|
|
478
491
|
_fixtures[subset].each_pair do |_mod, _extra|
|
|
479
492
|
opts[:local_fixtures_mods] << _mod
|
|
480
493
|
end
|
|
@@ -490,10 +503,10 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
|
|
|
490
503
|
end
|
|
491
504
|
end
|
|
492
505
|
|
|
493
|
-
Rake::Task['
|
|
494
|
-
Dir.glob(File.join('spec','fixtures','modules','*')).each do |dir|
|
|
495
|
-
if @custom_fixtures_hook_override_fixtures
|
|
496
|
-
FileUtils.remove_entry_secure(dir)
|
|
506
|
+
Rake::Task['fixtures:prep'].enhance [:custom_fixtures_hook] do
|
|
507
|
+
Dir.glob(File.join('spec', 'fixtures', 'modules', '*')).each do |dir|
|
|
508
|
+
if @custom_fixtures_hook_override_fixtures && !File.exist?(File.join(dir, 'metadata.json'))
|
|
509
|
+
FileUtils.remove_entry_secure(dir)
|
|
497
510
|
end
|
|
498
511
|
end
|
|
499
512
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rake'
|
|
4
|
+
require 'puppet/modulebuilder'
|
|
5
|
+
|
|
6
|
+
module Simp
|
|
7
|
+
module Rake
|
|
8
|
+
module Pupmod
|
|
9
|
+
# Extends Puppet::Modulebuilder::Builder to honour .pdkignore files.
|
|
10
|
+
# puppet-modulebuilder 2.x dropped native .pdkignore support; this
|
|
11
|
+
# restores it so the published tarball matches what PDK produced.
|
|
12
|
+
class PdkCompatBuilder < Puppet::Modulebuilder::Builder
|
|
13
|
+
def ignored_files
|
|
14
|
+
spec = super
|
|
15
|
+
pdkignore = File.join(source, '.pdkignore')
|
|
16
|
+
return spec unless File.exist?(pdkignore)
|
|
17
|
+
|
|
18
|
+
ignore = PathSpec.from_filename(pdkignore)
|
|
19
|
+
ignore.add('.*') # Ignore dotfiles by default
|
|
20
|
+
ignore
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Make the Rake DSL (namespace/desc/task) available so this file can be required
|
|
28
|
+
# directly (e.g. from RSpec), not only from within a Rakefile where the DSL is
|
|
29
|
+
# already mixed into the top-level scope.
|
|
30
|
+
extend Rake::DSL
|
|
31
|
+
|
|
32
|
+
namespace :pupmod do
|
|
33
|
+
desc 'Build the Puppet module package into pkg/, honouring .pdkignore'
|
|
34
|
+
task :build do
|
|
35
|
+
builder = Simp::Rake::Pupmod::PdkCompatBuilder.new(Dir.pwd)
|
|
36
|
+
pkg = builder.build
|
|
37
|
+
puts "Built: #{pkg}"
|
|
38
|
+
end
|
|
39
|
+
end
|
data/lib/simp/rake/rubygem.rb
CHANGED
|
@@ -1,74 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Simp; end
|
|
2
|
-
module Simp::Rake
|
|
3
|
-
class Rubygem < ::Rake::TaskLib
|
|
4
|
-
def initialize( package, rakefile_dir = File.pwd )
|
|
5
|
-
@package = package
|
|
6
|
-
@rakefile_dir = rakefile_dir
|
|
7
|
-
define
|
|
8
|
-
end
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
class Simp::Rake::Rubygem < Rake::TaskLib
|
|
6
|
+
def initialize(package, rakefile_dir = File.pwd)
|
|
7
|
+
@package = package
|
|
8
|
+
@rakefile_dir = rakefile_dir
|
|
9
|
+
define
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def define_clean_paths
|
|
13
|
+
CLEAN.include "#{@package}-*.gem"
|
|
14
|
+
CLEAN.include 'pkg'
|
|
15
|
+
CLEAN.include 'dist'
|
|
16
|
+
CLEAN.include 'spec/acceptance/files/testpackage/dist'
|
|
17
|
+
Find.find(@rakefile_dir) do |path|
|
|
18
|
+
if File.directory? path
|
|
19
|
+
CLEAN.include path if File.basename(path) == 'tmp'
|
|
20
|
+
else
|
|
21
|
+
Find.prune
|
|
21
22
|
end
|
|
22
23
|
end
|
|
24
|
+
end
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
def define
|
|
27
|
+
define_clean_paths
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
end
|
|
29
|
+
desc 'Ensure gemspec-safe permissions on all files'
|
|
30
|
+
task :chmod do
|
|
31
|
+
gemspec = File.expand_path("#{@package}.gemspec", @rakefile_dir).strip
|
|
32
|
+
spec = Gem::Specification.load(gemspec)
|
|
33
|
+
spec.files.each do |file|
|
|
34
|
+
FileUtils.chmod 'go=r', file
|
|
34
35
|
end
|
|
36
|
+
end
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
end
|
|
38
|
+
namespace :pkg do
|
|
39
|
+
desc "build rubygem package for #{@package}"
|
|
40
|
+
task :gem => :chmod do
|
|
41
|
+
Dir.chdir @rakefile_dir
|
|
42
|
+
Dir['*.gemspec'].each do |spec_file|
|
|
43
|
+
cmd = %(SIMP_RPM_BUILD=#{ENV.fetch('SIMP_RPM_BUILD', 1)} bundle exec gem build "#{spec_file}")
|
|
44
|
+
sh cmd
|
|
45
|
+
FileUtils.mkdir_p 'dist'
|
|
46
|
+
FileUtils.mv Dir.glob("#{@package}*.gem"), 'dist/'
|
|
46
47
|
end
|
|
48
|
+
end
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
end
|
|
50
|
+
desc "build and install rubygem package for #{@package}"
|
|
51
|
+
task :install_gem => [:clean, :gem] do
|
|
52
|
+
Dir.chdir @rakefile_dir
|
|
53
|
+
Dir.glob("dist/#{@package}*.gem") do |pkg|
|
|
54
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6')
|
|
55
|
+
sh %(bundle exec gem install --no-document #{pkg})
|
|
56
|
+
else
|
|
57
|
+
sh %(bundle exec gem install --no-ri --no-rdoc #{pkg})
|
|
57
58
|
end
|
|
58
59
|
end
|
|
59
60
|
end
|
|
61
|
+
end
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
desc 'Run acceptance tests'
|
|
64
|
+
RSpec::Core::RakeTask.new(:acceptance) do |t|
|
|
65
|
+
t.pattern = 'spec/acceptance'
|
|
66
|
+
end
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
end
|
|
68
|
+
desc 'Run spec tests'
|
|
69
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
70
|
+
t.rspec_opts = ['--color']
|
|
71
|
+
t.exclude_pattern = '**/{acceptance,fixtures,files}/**/*_spec.rb'
|
|
72
|
+
t.pattern = 'spec/lib/simp/**/*_spec.rb'
|
|
72
73
|
end
|
|
73
74
|
end
|
|
74
75
|
end
|