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.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +20 -1
  3. data/CHANGELOG.md +33 -0
  4. data/Gemfile +14 -6
  5. data/lib/simp/command_utils.rb +6 -3
  6. data/lib/simp/componentinfo.rb +47 -33
  7. data/lib/simp/local_gpg_signing_key.rb +302 -303
  8. data/lib/simp/packer/iso_vars_json.rb +17 -15
  9. data/lib/simp/rake/build/auto.rb +415 -432
  10. data/lib/simp/rake/build/build.rb +119 -124
  11. data/lib/simp/rake/build/clean.rb +39 -39
  12. data/lib/simp/rake/build/code.rb +125 -128
  13. data/lib/simp/rake/build/constants.rb +7 -4
  14. data/lib/simp/rake/build/deps.rb +196 -207
  15. data/lib/simp/rake/build/helpers.rb +17 -13
  16. data/lib/simp/rake/build/iso.rb +404 -411
  17. data/lib/simp/rake/build/pkg.rb +752 -759
  18. data/lib/simp/rake/build/rpmdeps.rb +70 -70
  19. data/lib/simp/rake/build/spec.rb +44 -46
  20. data/lib/simp/rake/build/tar.rb +169 -173
  21. data/lib/simp/rake/build/unpack.rb +105 -107
  22. data/lib/simp/rake/build/upload.rb +93 -102
  23. data/lib/simp/rake/fixtures.rb +69 -66
  24. data/lib/simp/rake/helpers/rpm_spec.rb +10 -7
  25. data/lib/simp/rake/helpers/version.rb +3 -1
  26. data/lib/simp/rake/helpers.rb +12 -10
  27. data/lib/simp/rake/pkg.rb +417 -440
  28. data/lib/simp/rake/pupmod/helpers.rb +100 -87
  29. data/lib/simp/rake/pupmod/module_build.rb +39 -0
  30. data/lib/simp/rake/rubygem.rb +57 -56
  31. data/lib/simp/rake.rb +34 -29
  32. data/lib/simp/relchecks.rb +52 -43
  33. data/lib/simp/rpm.rb +123 -127
  34. data/lib/simp/rpm_signer.rb +57 -55
  35. data/lib/simp/yum.rb +54 -53
  36. data/spec/acceptance/nodesets/{default_ruby3_1.yml → almalinux10.yml} +4 -4
  37. data/spec/acceptance/nodesets/{default.yml → almalinux8.yml} +2 -2
  38. data/spec/acceptance/nodesets/almalinux9.yml +25 -0
  39. data/spec/acceptance/suites/default/00_pkg_rpm_custom_scriptlets_spec.rb +23 -28
  40. data/spec/acceptance/suites/default/10_pkg_rpm_spec.rb +54 -56
  41. data/spec/acceptance/suites/default/30_pkg_misc_spec.rb +17 -19
  42. data/spec/acceptance/suites/default/50_local_gpg_signing_key_spec.rb +5 -5
  43. data/spec/acceptance/suites/default/55_build_pkg_signing_spec.rb +109 -101
  44. data/spec/acceptance/suites/default/files/testpackage/spec/classes/init_spec.rb +1 -0
  45. data/spec/acceptance/suites/default/files/testpackage/spec/files/mock_something.rb +3 -1
  46. data/spec/acceptance/suites/default/files/testpackage/utils/convert_v1_to_v2.rb +2 -0
  47. data/spec/acceptance/suites/default/support/build_project_helpers.rb +20 -17
  48. data/spec/acceptance/suites/default/support/build_user_helpers.rb +4 -2
  49. data/spec/acceptance/suites/default/support/pkg_rpm_helpers.rb +30 -31
  50. data/spec/acceptance/support/simp_rake_helpers.rb +3 -1
  51. data/spec/lib/simp/command_utils_spec.rb +13 -10
  52. data/spec/lib/simp/componentinfo_changelog_regex_spec.rb +33 -33
  53. data/spec/lib/simp/componentinfo_spec.rb +99 -86
  54. data/spec/lib/simp/packer/iso_vars_json_spec.rb +16 -14
  55. data/spec/lib/simp/rake/build/helpers_spec.rb +7 -7
  56. data/spec/lib/simp/rake/build/rpmdeps_spec.rb +48 -46
  57. data/spec/lib/simp/rake/helpers_spec.rb +6 -5
  58. data/spec/lib/simp/rake/pkg_spec.rb +7 -5
  59. data/spec/lib/simp/rake/pupmod/fixtures/othermod/spec/classes/init_spec.rb +3 -1
  60. data/spec/lib/simp/rake/pupmod/fixtures/othermod/spec/spec_helper.rb +2 -0
  61. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/acceptance/suites/default/class_spec.rb +6 -5
  62. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/classes/init_spec.rb +51 -33
  63. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/spec_helper.rb +15 -16
  64. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/spec_helper_acceptance.rb +9 -9
  65. data/spec/lib/simp/rake/pupmod/helpers_spec.rb +20 -19
  66. data/spec/lib/simp/rake/pupmod/module_build_spec.rb +87 -0
  67. data/spec/lib/simp/rake_spec.rb +7 -6
  68. data/spec/lib/simp/relchecks_check_rpm_changelog_spec.rb +26 -31
  69. data/spec/lib/simp/relchecks_compare_latest_tag_spec.rb +32 -26
  70. data/spec/lib/simp/relchecks_create_tag_changelog_spec.rb +27 -19
  71. data/spec/lib/simp/rpm_signer_spec.rb +45 -39
  72. data/spec/lib/simp/rpm_spec.rb +190 -194
  73. data/spec/spec_helper.rb +4 -2
  74. data/spec/spec_helper_acceptance.rb +3 -5
  75. metadata +47 -76
  76. data/bin/simp_rake_helpers +0 -3
  77. data/lib/simp/ci/gitlab.rb +0 -226
  78. data/lib/simp/rake/ci.rb +0 -31
  79. data/spec/lib/simp/ci/files/global_nodesets_only/spec/acceptance/nodesets/default.yml +0 -41
  80. data/spec/lib/simp/ci/files/global_nodesets_only/spec/acceptance/nodesets/oel.yml +0 -41
  81. data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/nodesets/centos.yml +0 -41
  82. data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
  83. data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  84. data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/nodesets/default.yml +0 -41
  85. data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
  86. data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  87. data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/nodesets/default.yml +0 -41
  88. data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/nodesets/oel.yml +0 -41
  89. data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/suites/default/class_spec.rb +0 -0
  90. data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/nodesets/default.yml +0 -41
  91. data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
  92. data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  93. data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/nodesets/default.yml +0 -41
  94. data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
  95. data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  96. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/nodesets/default.yml +0 -41
  97. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/nodesets/oel.yml +0 -41
  98. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/default/class_spec.rb +0 -0
  99. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature-1/feature-1_spec.rb +0 -0
  100. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/feature_2_spec.rb +0 -0
  101. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/nodesets/default.yml +0 -35
  102. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/nodesets/oel.yml +0 -35
  103. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/nodesets/default.yml +0 -41
  104. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/nodesets/oel.yml +0 -41
  105. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/default/class_spec.rb +0 -0
  106. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature-1/feature-1_spec.rb +0 -0
  107. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/feature_2_spec.rb +0 -0
  108. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/nodesets/default.yml +0 -35
  109. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/nodesets/oel.yml +0 -35
  110. data/spec/lib/simp/ci/files/no_acceptance_tests/spec/spec_helper.rb +0 -0
  111. data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/nodesets/default.yml +0 -41
  112. data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/nodesets/oel.yml +0 -41
  113. data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/suites/default/class_spec.rb +0 -0
  114. data/spec/lib/simp/ci/files/no_gitlab_config_without_tests/spec/acceptance/nodesets/default.yml +0 -41
  115. data/spec/lib/simp/ci/files/no_gitlab_config_without_tests/spec/acceptance/nodesets/oel.yml +0 -41
  116. data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/centos.yml +0 -41
  117. data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/oel.yml +0 -41
  118. data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/nodesets/default.yml +0 -41
  119. data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
  120. data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  121. data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/nodesets/default.yml +0 -41
  122. data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/nodesets/oel.yml +0 -41
  123. data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/suites/default/class_spec.rb +0 -0
  124. data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/class_spec.rb +0 -0
  125. data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/centos.yml +0 -41
  126. data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/oel.yml +0 -41
  127. data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  128. data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/nodesets/default.yml +0 -41
  129. data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/nodesets/oel.yml +0 -41
  130. data/spec/lib/simp/ci/gitlab_spec.rb +0 -245
@@ -1,62 +1,60 @@
1
1
  #!/usr/bin/rake -T
2
+ # frozen_string_literal: true
2
3
 
4
+ require 'English'
3
5
  require 'yaml'
4
6
 
5
7
  class R10KHelper
6
- attr_accessor :puppetfile
7
- attr_accessor :modules
8
- attr_accessor :basedir
8
+ attr_accessor :puppetfile, :modules, :basedir
9
9
 
10
10
  require 'r10k/puppetfile'
11
11
 
12
12
  # Horrible, but we need to be able to manipulate the cache
13
13
  class R10K::Git::ShellGit::ThinRepository
14
- def cache_repo
15
- @cache_repo
16
- end
14
+ attr_reader :cache_repo
17
15
 
18
16
  # Return true if the repository has local modifications, false otherwise.
19
- def dirty?(exclude_spec=false)
17
+ def dirty?(_exclude_spec = false)
20
18
  repo_status = false
21
19
 
22
20
  return repo_status unless File.directory?(path)
23
21
 
24
22
  Dir.chdir(path) do
25
- %x(git update-index -q --ignore-submodules --refresh)
26
- repo_status = "Could not update git index for '#{path}'" unless $?.success?
23
+ `git update-index -q --ignore-submodules --refresh`
24
+ repo_status = "Could not update git index for '#{path}'" unless $CHILD_STATUS.success?
27
25
 
28
26
  unless repo_status
29
- %x(git diff-files --quiet --ignore-submodules --)
30
- repo_status = "'#{path}' has unstaged changes" unless $?.success?
27
+ `git diff-files --quiet --ignore-submodules --`
28
+ repo_status = "'#{path}' has unstaged changes" unless $CHILD_STATUS.success?
31
29
  end
32
30
 
33
31
  unless repo_status
34
- %x(git diff-index --cached --quiet HEAD --ignore-submodules --)
35
- repo_status = "'#{path}' has uncommitted changes" unless $?.success?
32
+ `git diff-index --cached --quiet HEAD --ignore-submodules --`
33
+ repo_status = "'#{path}' has uncommitted changes" unless $CHILD_STATUS.success?
36
34
  end
37
35
 
38
36
  unless repo_status
39
37
  # Things that may be out of date but which should stop the updating
40
38
  # of the git repo
41
- our_exclusions=[
39
+ our_exclusions = [
42
40
  'build/rpm_metadata',
43
- 'dist/'
41
+ 'dist/',
44
42
  ]
45
43
 
46
- untracked_files = %x(git ls-files -o -d --exclude-standard --exclude=#{our_exclusions.join(' --exclude=')})
44
+ untracked_files = `git ls-files -o -d --exclude-standard --exclude=#{our_exclusions.join(' --exclude=')}`
47
45
 
48
- if $?.success?
49
- unless untracked_files.empty?
50
- untracked_files.strip!
46
+ raise Error, "Failure running 'git ls-files -o -d --exclude-standard' at '#{path}'" unless $CHILD_STATUS.success?
51
47
 
52
- if untracked_files.lines.count > 0
53
- repo_status = "'#{path}' has untracked files"
54
- end
48
+ unless untracked_files.empty?
49
+ untracked_files.strip!
50
+
51
+ if untracked_files.lines.any?
52
+ repo_status = "'#{path}' has untracked files"
55
53
  end
56
- else
57
- # We should never get here
58
- raise Error, "Failure running 'git ls-files -o -d --exclude-standard' at '#{path}'"
59
54
  end
55
+
56
+ # We should never get here
57
+
60
58
  end
61
59
  end
62
60
 
@@ -69,8 +67,7 @@ class R10KHelper
69
67
  @basedir = File.dirname(File.expand_path(puppetfile))
70
68
 
71
69
  Dir.chdir(@basedir) do
72
-
73
- R10K::Git::Cache.settings[:cache_root] = File.join(@basedir,'.r10k_cache')
70
+ R10K::Git::Cache.settings[:cache_root] = File.join(@basedir, '.r10k_cache')
74
71
 
75
72
  unless File.directory?(R10K::Git::Cache.settings[:cache_root])
76
73
  FileUtils.mkdir_p(R10K::Git::Cache.settings[:cache_root])
@@ -79,26 +76,26 @@ class R10KHelper
79
76
  r10k = R10K::Puppetfile.new(Dir.pwd, nil, puppetfile)
80
77
  r10k.load!
81
78
 
82
- @modules = r10k.modules.collect do |mod|
79
+ @modules = r10k.modules.map do |mod|
83
80
  mod_status = mod.repo.repo.dirty?
84
81
 
85
- mod = {
86
- :name => mod.name,
87
- :path => mod.path.to_s,
88
- :remote => mod.repo.instance_variable_get('@remote'),
82
+ {
83
+ :name => mod.name,
84
+ :path => mod.path.to_s,
85
+ :remote => mod.repo.instance_variable_get(:@remote),
89
86
  :desired_ref => mod.desired_ref,
90
- :git_source => mod.repo.repo.origin,
91
- :git_ref => mod.repo.head,
92
- :module_dir => mod.basedir,
93
- :status => mod_status ? mod_status : :known,
87
+ :git_source => mod.repo.repo.origin,
88
+ :git_ref => mod.repo.head,
89
+ :module_dir => mod.basedir,
90
+ :status => mod_status || :known,
94
91
  :r10k_module => mod,
95
- :r10k_cache => mod.repo.repo.cache_repo
92
+ :r10k_cache => mod.repo.repo.cache_repo
96
93
  }
97
94
  end
98
95
  end
99
96
 
100
- module_dirs = @modules.collect do |mod|
101
- mod = mod[:module_dir]
97
+ module_dirs = @modules.map do |mod|
98
+ mod[:module_dir]
102
99
  end
103
100
 
104
101
  module_dirs.uniq!
@@ -109,30 +106,30 @@ class R10KHelper
109
106
  end
110
107
 
111
108
  known_modules.map! do |mod|
112
- mod = mod[:name]
109
+ mod[:name]
113
110
  end
114
111
 
115
- current_modules = Dir.glob(File.join(module_dir,'*')).map do |mod|
116
- mod = File.basename(mod)
112
+ current_modules = Dir.glob(File.join(module_dir, '*')).map do |mod|
113
+ File.basename(mod)
117
114
  end
118
115
 
119
116
  (current_modules - known_modules).each do |mod|
120
117
  # Did we find random git repos in our module spaces?
121
- if File.exist?(File.join(module_dir, mod, '.git'))
122
- @modules << {
123
- :name => mod,
124
- :path => File.join(module_dir, mod),
125
- :module_dir => module_dir,
126
- :status => :unknown,
127
- }
128
- end
118
+ next unless File.exist?(File.join(module_dir, mod, '.git'))
119
+
120
+ @modules << {
121
+ :name => mod,
122
+ :path => File.join(module_dir, mod),
123
+ :module_dir => module_dir,
124
+ :status => :unknown
125
+ }
129
126
  end
130
127
  end
131
128
  end
132
129
 
133
130
  def puppetfile
134
131
  last_module_dir = nil
135
- pupfile = Array.new
132
+ pupfile = []
136
133
 
137
134
  @modules.each do |mod|
138
135
  module_dir = mod[:path].split(@basedir.to_s).last.split('/')[1..-2].join('/')
@@ -156,40 +153,35 @@ class R10KHelper
156
153
 
157
154
  def each_module(&block)
158
155
  Dir.chdir(@basedir) do
159
- @modules.each do |mod|
160
- # This works for Puppet Modules
161
-
162
- block.call(mod)
163
- end
156
+ @modules.each(&block)
164
157
  end
165
158
  end
166
159
 
167
160
  def unknown_modules
168
- @modules.select do |mod|
161
+ @modules.select { |mod|
169
162
  mod[:status] == :unknown
170
- end.map do |mod|
171
- mod = mod[:name]
163
+ }.map do |mod|
164
+ mod[:name]
172
165
  end
173
166
  end
174
167
  end
175
168
 
176
169
  module Simp; end
177
170
  module Simp::Rake; end
178
- module Simp::Rake::Build
179
171
 
180
- class Deps < ::Rake::TaskLib
181
- require 'pager'
182
- include Pager
172
+ class Simp::Rake::Build::Deps < Rake::TaskLib
173
+ require 'pager'
174
+ include Pager
183
175
 
184
- def initialize( base_dir )
185
- @base_dir = base_dir
186
- @verbose = ENV.fetch('SIMP_PKG_verbose','no') == 'yes'
187
- define_tasks
188
- end
176
+ def initialize(base_dir)
177
+ @base_dir = base_dir
178
+ @verbose = ENV.fetch('SIMP_PKG_verbose', 'no') == 'yes'
179
+ define_tasks
180
+ end
189
181
 
190
- def define_tasks
191
- namespace :deps do
192
- desc <<-EOM
182
+ def define_tasks
183
+ namespace :deps do
184
+ desc <<-EOM
193
185
  Checks out all dependency repos.
194
186
 
195
187
  This task used R10k to update all dependencies.
@@ -198,196 +190,193 @@ module Simp::Rake::Build
198
190
  * :method => The update method to use (Default => 'tracking')
199
191
  tracking => checks out each dep (by branch) according to Puppetfile.tracking
200
192
  stable => checks out each dep (by ref) according to in Puppetfile.stable
201
- EOM
202
- task :checkout, [:method] do |t,args|
203
- args.with_defaults(:method => 'tracking')
204
-
205
- r10k_helper = R10KHelper.new("Puppetfile.#{args[:method]}")
206
-
207
- r10k_issues = Parallel.map(
208
- Array(r10k_helper.modules),
209
- :in_processes => get_cpu_limit,
210
- :progress => 'Submodule Checkout'
211
- ) do |mod|
212
- issues = []
213
-
214
- Dir.chdir(@base_dir) do
215
- unless File.directory?(mod[:path])
216
- FileUtils.mkdir_p(mod[:path])
217
- end
193
+ EOM
194
+ task :checkout, [:method] do |_t, args|
195
+ args.with_defaults(:method => 'tracking')
196
+
197
+ r10k_helper = R10KHelper.new("Puppetfile.#{args[:method]}")
218
198
 
219
- # Only for known modules...
220
- unless mod[:status] == :unknown
221
- # Since r10k is destructive, we're enumerating all valid states
222
- if [
223
- :absent,
224
- :mismatched,
225
- :outdated,
226
- :insync,
227
- :dirty
228
- ].include?(mod[:r10k_module].status)
229
- unless mod[:r10k_cache].synced?
230
- mod[:r10k_cache].sync
231
- end
232
-
233
- if mod[:status] == :known
234
- mod[:r10k_module].sync
235
- else
236
- # If we get here, the module was dirty and should be skipped
237
- issues << "#{mod[:name]}: Skipped - #{mod[:status]}"
238
- next
239
- end
199
+ r10k_issues = Parallel.map(
200
+ Array(r10k_helper.modules),
201
+ :in_processes => get_cpu_limit,
202
+ :progress => 'Submodule Checkout',
203
+ ) do |mod|
204
+ issues = []
205
+
206
+ Dir.chdir(@base_dir) do
207
+ unless File.directory?(mod[:path])
208
+ FileUtils.mkdir_p(mod[:path])
209
+ end
210
+
211
+ # Only for known modules...
212
+ unless mod[:status] == :unknown
213
+ # Since r10k is destructive, we're enumerating all valid states
214
+ if [
215
+ :absent,
216
+ :mismatched,
217
+ :outdated,
218
+ :insync,
219
+ :dirty,
220
+ ].include?(mod[:r10k_module].status)
221
+ unless mod[:r10k_cache].synced?
222
+ mod[:r10k_cache].sync
223
+ end
224
+
225
+ if mod[:status] == :known
226
+ mod[:r10k_module].sync
240
227
  else
241
- issues << "#{mod[:name]}: Skipped - Unknown status type #{mod[:r10k_module].status}"
228
+ # If we get here, the module was dirty and should be skipped
229
+ issues << "#{mod[:name]}: Skipped - #{mod[:status]}"
230
+ next
242
231
  end
232
+ else
233
+ issues << "#{mod[:name]}: Skipped - Unknown status type #{mod[:r10k_module].status}"
243
234
  end
244
235
  end
245
-
246
- issues
247
236
  end
248
237
 
249
- r10k_issues.flatten!
238
+ issues
239
+ end
240
+
241
+ r10k_issues.flatten!
250
242
 
251
- unless r10k_issues.empty?
252
- $stderr.puts('='*80)
243
+ unless r10k_issues.empty?
244
+ warn('=' * 80)
253
245
 
254
- unless @verbose
255
- $stderr.puts('Warning: Some repositories were skipped!')
256
- $stderr.puts(' * If this is a fresh build, this could be an issue')
257
- $stderr.puts(' * This is expected if re-running a build')
258
- $stderr.puts(' * Run with SIMP_PKG_verbose=yes for full details')
259
- else
260
- $stderr.puts("R10k Checkout Issues:")
261
- r10k_issues.each do |issue|
262
- $stderr.puts(" * #{issue}")
263
- end
246
+ if @verbose
247
+ warn('R10k Checkout Issues:')
248
+ r10k_issues.each do |issue|
249
+ warn(" * #{issue}")
264
250
  end
265
-
266
- $stderr.puts('='*80)
251
+ else
252
+ warn('Warning: Some repositories were skipped!')
253
+ warn(' * If this is a fresh build, this could be an issue')
254
+ warn(' * This is expected if re-running a build')
255
+ warn(' * Run with SIMP_PKG_verbose=yes for full details')
267
256
  end
257
+
258
+ warn('=' * 80)
268
259
  end
260
+ end
269
261
 
270
- desc <<-EOM
262
+ desc <<-EOM
271
263
  Get the status of the project Git repositories
272
264
 
273
265
  Arguments:
274
266
  * :method => The update method to use (Default => 'tracking')
275
267
  tracking => checks out each dep (by branch) according to Puppetfile.tracking
276
268
  stable => checks out each dep (by ref) according to in Puppetfile.stable
277
- EOM
278
- task :status, [:method] do |t,args|
279
- args.with_defaults(:method => 'tracking')
280
- @dirty_repos = nil
269
+ EOM
270
+ task :status, [:method] do |_t, args|
271
+ args.with_defaults(:method => 'tracking')
272
+ @dirty_repos = nil
281
273
 
282
- r10k_helper = R10KHelper.new("Puppetfile.#{args[:method]}")
274
+ r10k_helper = R10KHelper.new("Puppetfile.#{args[:method]}")
283
275
 
284
- mods_with_changes = {}
276
+ mods_with_changes = {}
285
277
 
286
- r10k_helper.each_module do |mod|
287
- unless File.directory?(mod[:path])
288
- $stderr.puts("Warning: '#{mod[:path]}' is not a module...skipping") if File.exist?(mod[:path])
289
- next
290
- end
278
+ r10k_helper.each_module do |mod|
279
+ unless File.directory?(mod[:path])
280
+ warn("Warning: '#{mod[:path]}' is not a module...skipping") if File.exist?(mod[:path])
281
+ next
282
+ end
291
283
 
292
- if mod[:status] != :known
293
- # Clean up the path a bit for printing
294
- dirty_path = mod[:path].split(r10k_helper.basedir.to_s).last
295
- if dirty_path[0].chr == File::SEPARATOR
296
- dirty_path[0] = ''
297
- end
284
+ next unless mod[:status] != :known
298
285
 
299
- mods_with_changes[mod[:name]] = dirty_path
300
- end
286
+ # Clean up the path a bit for printing
287
+ dirty_path = mod[:path].split(r10k_helper.basedir.to_s).last
288
+ if dirty_path[0].chr == File::SEPARATOR
289
+ dirty_path[0] = ''
301
290
  end
302
291
 
303
- if mods_with_changes.empty?
304
- puts "No repositories have changes."
305
- @dirty_repos = false
306
- else
307
- puts "The following repositories have changes:"
308
- puts mods_with_changes.map{|k,v| " + #{k} => #{v}"}.join("\n")
292
+ mods_with_changes[mod[:name]] = dirty_path
293
+ end
309
294
 
310
- @dirty_repos = true
311
- end
295
+ if mods_with_changes.empty?
296
+ puts 'No repositories have changes.'
297
+ @dirty_repos = false
298
+ else
299
+ puts 'The following repositories have changes:'
300
+ puts mods_with_changes.map { |k, v| " + #{k} => #{v}" }.join("\n")
312
301
 
313
- unknown_mods = r10k_helper.unknown_modules
314
- unless unknown_mods.empty?
315
- puts "The following modules were unknown:"
316
- puts unknown_mods.map{|k,v| " ? #{k}"}.join("\n")
317
- end
302
+ @dirty_repos = true
318
303
  end
319
304
 
320
- desc <<-EOM
305
+ unknown_mods = r10k_helper.unknown_modules
306
+ unless unknown_mods.empty?
307
+ puts 'The following modules were unknown:'
308
+ puts unknown_mods.map { |k, _v| " ? #{k}" }.join("\n")
309
+ end
310
+ end
311
+
312
+ desc <<-EOM
321
313
  Records the current dependencies into Puppetfile.stable.
322
314
 
323
315
  Arguments:
324
316
  * :method => Save to Puppetfile.[method] (Default => 'stable')
325
317
  * :reference => Use Puppetfile.[reference] to reference which repos
326
318
  should be recorded (Default => 'tracking')
327
- EOM
328
- task :record, [:method,:reference] do |t,args|
329
- args.with_defaults(:method => 'stable')
330
- args.with_defaults(:reference => 'tracking')
319
+ EOM
320
+ task :record, [:method, :reference] do |_t, args|
321
+ args.with_defaults(:method => 'stable')
322
+ args.with_defaults(:reference => 'tracking')
331
323
 
332
- r10k_helper = R10KHelper.new("Puppetfile.#{args[:reference]}")
333
- File.open("Puppetfile.#{args[:method]}",'w'){|f| f.puts r10k_helper.puppetfile }
334
- end
324
+ r10k_helper = R10KHelper.new("Puppetfile.#{args[:reference]}")
325
+ File.open("Puppetfile.#{args[:method]}", 'w') { |f| f.puts r10k_helper.puppetfile }
326
+ end
335
327
 
336
- desc <<-EOM
328
+ desc <<-EOM
337
329
  Provide a log of changes to all modules from the given top level Git reference.
338
330
 
339
331
  Arguments:
340
332
  * :ref => The top level git ref to use as the oldest point for all logs.
341
333
  * :source => The source Puppetfile to use (Default => 'tracking')
342
- EOM
343
- task :changelog, [:ref] do |t,args|
344
- args.with_defaults(:source => 'tracking')
345
-
346
- r10k_helper = R10KHelper.new("Puppetfile.#{args[:source]}")
347
-
348
- git_logs = Hash.new
349
-
350
- Dir.chdir(r10k_helper.basedir) do
351
- ref = args[:ref]
352
- refdate = nil
353
- begin
354
- refdate = %x(git log -1 --format=%ai '#{ref}')
355
- refdate = nil unless $?.success?
356
- rescue Exception
357
- #noop
358
- end
334
+ EOM
335
+ task :changelog, [:ref] do |_t, args|
336
+ args.with_defaults(:source => 'tracking')
337
+
338
+ r10k_helper = R10KHelper.new("Puppetfile.#{args[:source]}")
339
+
340
+ git_logs = {}
341
+
342
+ Dir.chdir(r10k_helper.basedir) do
343
+ ref = args[:ref]
344
+ refdate = nil
345
+ begin
346
+ refdate = `git log -1 --format=%ai '#{ref}'`
347
+ refdate = nil unless $CHILD_STATUS.success?
348
+ rescue Exception
349
+ # noop
350
+ end
359
351
 
360
- fail("You must specify a valid reference") unless ref
361
- fail("Could not find a Git log for #{ref}") unless refdate
352
+ raise('You must specify a valid reference') unless ref
353
+ raise("Could not find a Git log for #{ref}") unless refdate
362
354
 
363
- mods_with_changes = {}
355
+ log_output = `git log --since='#{refdate}' --stat --reverse`.chomp
356
+ git_logs['__SIMP CORE__'] = log_output unless log_output.strip.empty?
364
357
 
365
- log_output = %x(git log --since='#{refdate}' --stat --reverse).chomp
366
- git_logs['__SIMP CORE__'] = log_output unless log_output.strip.empty?
358
+ r10k_helper.each_module do |mod|
359
+ next unless File.directory?(mod[:path])
367
360
 
368
- r10k_helper.each_module do |mod|
369
- if File.directory?(mod[:path])
370
- Dir.chdir(mod[:path]) do
371
- log_output = %x(git log --since='#{refdate}' --stat --reverse).chomp
372
- git_logs[mod[:name]] = log_output unless log_output.strip.empty?
373
- end
374
- end
361
+ Dir.chdir(mod[:path]) do
362
+ log_output = `git log --since='#{refdate}' --stat --reverse`.chomp
363
+ git_logs[mod[:name]] = log_output unless log_output.strip.empty?
375
364
  end
365
+ end
376
366
 
377
- if git_logs.empty?
378
- puts( "No changes found for any components since #{refdate}")
379
- else
380
- page
367
+ if git_logs.empty?
368
+ puts("No changes found for any components since #{refdate}")
369
+ else
370
+ page
381
371
 
382
- git_logs.keys.sort.each do |mod_name|
383
- puts <<-EOM
372
+ git_logs.keys.sort.each do |mod_name|
373
+ puts <<-EOM
384
374
  ========
385
375
  #{mod_name}:
386
376
 
387
- #{git_logs[mod_name].gsub(/^/,' ')}
377
+ #{git_logs[mod_name].gsub(%r{^}, ' ')}
388
378
 
389
- EOM
390
- end
379
+ EOM
391
380
  end
392
381
  end
393
382
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake/tasklib'
2
4
  require 'ruby-progressbar'
3
5
  require 'rake/clean'
@@ -5,22 +7,24 @@ require 'rake/clean'
5
7
  module Simp; end
6
8
  module Simp::Rake; end
7
9
  module Simp::Rake::Build; end
10
+
8
11
  class Simp::Rake::Build::Helpers
9
- def initialize( dir = Dir.pwd )
10
- Dir[ File.join(File.dirname(__FILE__),'*.rb') ].each do |rake_file|
12
+ def initialize(dir = Dir.pwd)
13
+ Dir[File.join(File.dirname(__FILE__), '*.rb')].sort.each do |rake_file|
11
14
  next if rake_file == __FILE__
15
+
12
16
  require rake_file
13
17
  end
14
- Simp::Rake::Build::Auto.new( dir )
15
- Simp::Rake::Build::Build.new( dir )
16
- Simp::Rake::Build::Code.new( dir )
17
- Simp::Rake::Build::Deps.new( dir )
18
- Simp::Rake::Build::Iso.new( dir )
19
- Simp::Rake::Build::Pkg.new( dir )
20
- Simp::Rake::Build::Spec.new( dir )
21
- Simp::Rake::Build::Tar.new( dir )
22
- Simp::Rake::Build::Upload.new( dir )
23
- Simp::Rake::Build::Unpack.new( dir )
24
- Simp::Rake::Build::Clean.new( dir )
18
+ Simp::Rake::Build::Auto.new(dir)
19
+ Simp::Rake::Build::Build.new(dir)
20
+ Simp::Rake::Build::Code.new(dir)
21
+ Simp::Rake::Build::Deps.new(dir)
22
+ Simp::Rake::Build::Iso.new(dir)
23
+ Simp::Rake::Build::Pkg.new(dir)
24
+ Simp::Rake::Build::Spec.new(dir)
25
+ Simp::Rake::Build::Tar.new(dir)
26
+ Simp::Rake::Build::Upload.new(dir)
27
+ Simp::Rake::Build::Unpack.new(dir)
28
+ Simp::Rake::Build::Clean.new(dir)
25
29
  end
26
30
  end