ra10ke 4.2.0 → 4.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cfd0253d86a27c086c42f5f177bfd344af02d4cdb041950e3d48c6fdb8cc633f
4
- data.tar.gz: 8bbb1b973495bef1095b233269ca21d092aa852f91f7bbc563f36fb11a0996a3
3
+ metadata.gz: 491a77b0c52058543f622d2c52d8954909d5c295040de7fc286c44448086ba34
4
+ data.tar.gz: b6839c56aed1cd7961a8003406dbaf6c29ddbb5561928160ee6519f5d777a08a
5
5
  SHA512:
6
- metadata.gz: edf4a75aea7f43baa01ffe4596c8cc517a9dd1905096f929e3984e4cd75b6acfff56d7aef33ad1af035cbd3f2b33e000fed29bc193d1a4ffc148d29f090f7251
7
- data.tar.gz: 0a4254ced1b553b2e683c3024f2000c1b4759f3b9a3bec46986032965e59cabf31cdd09fcb9bfaa293c6f24a5cc253ce6554ccdc246287d9838a830cfd502ddc
6
+ metadata.gz: c38aa105a739f4abd4f6924e9b0223569d5daa2821bf830276d2bbd51576436d2a45dcf30b041fc23abd02f8e1fff75ccd5c995ddfab7c00a48a9ca9023340f0
7
+ data.tar.gz: f3412aba6d1eb7980c5ce30f3755136644594a660c1e133eadd94d6e18ea19bd1120f70cd7d0bc4698d869e111744da9c21f6b7a998773b7881bfe67461b13c4
@@ -10,30 +10,28 @@ env:
10
10
  BUNDLE_WITHOUT: release
11
11
 
12
12
  jobs:
13
- rubocop:
13
+ rubocop_and_matrix:
14
14
  runs-on: ubuntu-latest
15
+ outputs:
16
+ ruby: ${{ steps.ruby.outputs.versions }}
15
17
  steps:
16
18
  - uses: actions/checkout@v4
17
19
  - name: Install Ruby ${{ matrix.ruby }}
18
20
  uses: ruby/setup-ruby@v1
19
21
  with:
20
- ruby-version: "3.2"
22
+ ruby-version: "3.4"
21
23
  bundler-cache: true
22
24
  - name: Run Rubocop
23
25
  run: bundle exec rake rubocop
26
+ - id: ruby
27
+ uses: voxpupuli/ruby-version@v1
24
28
  test:
25
29
  runs-on: ubuntu-latest
30
+ needs: rubocop_and_matrix
26
31
  strategy:
27
32
  fail-fast: false
28
33
  matrix:
29
- include:
30
- - ruby: "3.1"
31
- coverage: "yes"
32
- - ruby: "3.2"
33
- - ruby: "3.3"
34
- - ruby: "3.4"
35
- env:
36
- COVERAGE: ${{ matrix.coverage }}
34
+ ruby: ${{ fromJSON(needs.rubocop_and_matrix.outputs.ruby) }}
37
35
  name: Ruby ${{ matrix.ruby }}
38
36
  steps:
39
37
  - uses: actions/checkout@v4
@@ -49,7 +47,7 @@ jobs:
49
47
 
50
48
  tests:
51
49
  needs:
52
- - rubocop
50
+ - rubocop_and_matrix
53
51
  - test
54
52
  runs-on: ubuntu-latest
55
53
  name: Test suite
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2024-03-13 18:23:33 UTC using RuboCop version 1.62.1.
3
+ # on 2025-05-09 13:01:13 UTC using RuboCop version 1.75.5.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -23,18 +23,19 @@ Lint/SuppressedException:
23
23
  Exclude:
24
24
  - 'Rakefile'
25
25
 
26
- # Offense count: 5
27
- # This cop supports unsafe autocorrection (--autocorrect-all).
26
+ # Offense count: 4
27
+ # This cop supports safe autocorrection (--autocorrect).
28
28
  # Configuration parameters: AutoCorrect.
29
29
  Lint/UselessAssignment:
30
30
  Exclude:
31
31
  - 'lib/ra10ke/dependencies.rb'
32
32
  - 'lib/ra10ke/solve.rb'
33
33
 
34
- # Offense count: 1
34
+ # Offense count: 2
35
35
  Naming/AccessorMethodName:
36
36
  Exclude:
37
37
  - 'lib/ra10ke.rb'
38
+ - 'lib/ra10ke/diff.rb'
38
39
 
39
40
  # Offense count: 1
40
41
  # Configuration parameters: ForbiddenDelimiters.
@@ -83,7 +84,7 @@ RSpec/ContextWording:
83
84
  Exclude:
84
85
  - 'spec/ra10ke/dependencies_spec.rb'
85
86
 
86
- # Offense count: 5
87
+ # Offense count: 6
87
88
  # Configuration parameters: CountAsOne.
88
89
  RSpec/ExampleLength:
89
90
  Max: 31
@@ -93,7 +94,7 @@ RSpec/ExpectInHook:
93
94
  Exclude:
94
95
  - 'spec/ra10ke/validate_spec.rb'
95
96
 
96
- # Offense count: 15
97
+ # Offense count: 16
97
98
  # Configuration parameters: .
98
99
  # SupportedStyles: have_received, receive
99
100
  RSpec/MessageSpies:
@@ -110,17 +111,26 @@ RSpec/NoExpectationExample:
110
111
  Exclude:
111
112
  - 'spec/ra10ke/dependencies_spec.rb'
112
113
 
114
+ # Offense count: 1
115
+ # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
116
+ # Include: **/*_spec.rb
117
+ RSpec/SpecFilePathFormat:
118
+ Exclude:
119
+ - '**/spec/routing/**/*'
120
+ - 'spec/ra10ke/diff_spec.rb'
121
+
113
122
  # Offense count: 12
114
123
  RSpec/StubbedMock:
115
124
  Exclude:
116
125
  - 'spec/ra10ke/deprecation_spec.rb'
117
126
  - 'spec/ra10ke/validate_spec.rb'
118
127
 
119
- # Offense count: 7
128
+ # Offense count: 12
120
129
  # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
121
130
  RSpec/VerifiedDoubles:
122
131
  Exclude:
123
132
  - 'spec/ra10ke/deprecation_spec.rb'
133
+ - 'spec/ra10ke/diff_spec.rb'
124
134
  - 'spec/ra10ke/validate_spec.rb'
125
135
 
126
136
  # Offense count: 1
@@ -130,8 +140,10 @@ RSpec/VoidExpect:
130
140
 
131
141
  # Offense count: 6
132
142
  # This cop supports unsafe autocorrection (--autocorrect-all).
133
- # Configuration parameters: EnforcedStyle.
143
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules.
134
144
  # SupportedStyles: nested, compact
145
+ # SupportedStylesForClasses: , nested, compact
146
+ # SupportedStylesForModules: , nested, compact
135
147
  Style/ClassAndModuleChildren:
136
148
  Exclude:
137
149
  - 'lib/ra10ke/dependencies.rb'
@@ -148,7 +160,7 @@ Style/CollectionCompact:
148
160
  Exclude:
149
161
  - 'lib/ra10ke/dependencies.rb'
150
162
 
151
- # Offense count: 15
163
+ # Offense count: 17
152
164
  # Configuration parameters: AllowedConstants.
153
165
  Style/Documentation:
154
166
  Exclude:
@@ -157,6 +169,7 @@ Style/Documentation:
157
169
  - 'lib/ra10ke.rb'
158
170
  - 'lib/ra10ke/dependencies.rb'
159
171
  - 'lib/ra10ke/deprecation.rb'
172
+ - 'lib/ra10ke/diff.rb'
160
173
  - 'lib/ra10ke/duplicates.rb'
161
174
  - 'lib/ra10ke/git_repo.rb'
162
175
  - 'lib/ra10ke/install.rb'
@@ -168,7 +181,7 @@ Style/Documentation:
168
181
 
169
182
  # Offense count: 5
170
183
  # This cop supports safe autocorrection (--autocorrect).
171
- # Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
184
+ # Configuration parameters: MaxUnannotatedPlaceholdersAllowed, Mode, AllowedMethods, AllowedPatterns.
172
185
  # SupportedStyles: annotated, template, unannotated
173
186
  Style/FormatStringToken:
174
187
  EnforcedStyle: unannotated
@@ -179,6 +192,7 @@ Style/FormatStringToken:
179
192
  # SupportedStyles: always, always_true, never
180
193
  Style/FrozenStringLiteralComment:
181
194
  Exclude:
195
+ - '**/*.arb'
182
196
  - 'Gemfile'
183
197
  - 'Rakefile'
184
198
  - 'lib/ra10ke.rb'
@@ -203,6 +217,13 @@ Style/MultilineBlockChain:
203
217
  Exclude:
204
218
  - 'lib/ra10ke/dependencies.rb'
205
219
 
220
+ # Offense count: 1
221
+ # This cop supports safe autocorrection (--autocorrect).
222
+ # Configuration parameters: AllowMethodComparison, ComparisonsThreshold.
223
+ Style/MultipleComparison:
224
+ Exclude:
225
+ - 'lib/ra10ke/git_repo.rb'
226
+
206
227
  # Offense count: 1
207
228
  # This cop supports unsafe autocorrection (--autocorrect-all).
208
229
  # Configuration parameters: EnforcedStyle.
@@ -226,12 +247,6 @@ Style/RedundantInterpolation:
226
247
  Exclude:
227
248
  - 'lib/ra10ke/duplicates.rb'
228
249
 
229
- # Offense count: 1
230
- # This cop supports safe autocorrection (--autocorrect).
231
- Style/RedundantLineContinuation:
232
- Exclude:
233
- - 'lib/ra10ke/validate.rb'
234
-
235
250
  # Offense count: 1
236
251
  # This cop supports unsafe autocorrection (--autocorrect-all).
237
252
  Style/RedundantSort:
@@ -263,7 +278,7 @@ Style/SymbolProc:
263
278
 
264
279
  # Offense count: 6
265
280
  # This cop supports safe autocorrection (--autocorrect).
266
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
281
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
267
282
  # URISchemes: http, https
268
283
  Layout/LineLength:
269
284
  Max: 137
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [v4.3.0](https://github.com/voxpupuli/ra10ke/tree/v4.3.0) (2025-05-13)
6
+
7
+ [Full Changelog](https://github.com/voxpupuli/ra10ke/compare/v4.2.0...v4.3.0)
8
+
9
+ **Implemented enhancements:**
10
+
11
+ - Add diff task to compare module differences between two branches [\#123](https://github.com/voxpupuli/ra10ke/pull/123) ([rwaffen](https://github.com/rwaffen))
12
+
5
13
  ## [v4.2.0](https://github.com/voxpupuli/ra10ke/tree/v4.2.0) (2025-02-28)
6
14
 
7
15
  [Full Changelog](https://github.com/voxpupuli/ra10ke/compare/v4.1.0...v4.2.0)
data/Gemfile CHANGED
@@ -7,8 +7,3 @@ group :release do
7
7
  gem 'faraday-retry', '~> 2.1', require: false
8
8
  gem 'github_changelog_generator', '~> 1.16.4', require: false
9
9
  end
10
-
11
- group :coverage, optional: ENV['COVERAGE'] != 'yes' do
12
- gem 'codecov', require: false
13
- gem 'simplecov-console', require: false
14
- end
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- ra10ke
2
- ======
1
+ # ra10ke
3
2
 
4
3
  [![License](https://img.shields.io/github/license/voxpupuli/ra10ke.svg)](https://github.com/voxpupuli/ra10ke/blob/master/LICENSE.txt)
5
4
  [![Test](https://github.com/voxpupuli/ra10ke/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/ra10ke/actions/workflows/test.yml)
@@ -14,6 +13,7 @@ Rake tasks related to [R10K](https://github.com/puppetlabs/r10k) and
14
13
  ## Usage
15
14
 
16
15
  Add the following line to your `Gemfile`:
16
+
17
17
  ```ruby
18
18
  gem 'ra10ke'
19
19
  ```
@@ -60,8 +60,9 @@ This rake task goes through the modules that are declared in the Puppetfile,
60
60
  and prints outdated modules.
61
61
 
62
62
  Supports:
63
- - Puppet Forge
64
- - Git (SHA-ref and Tagging)
63
+
64
+ - Puppet Forge
65
+ - Git (SHA-ref and Tagging)
65
66
 
66
67
  Ignoring specific modules:
67
68
 
@@ -69,12 +70,13 @@ Under specific conditions you may not wish to report on specific modules being o
69
70
  to ignore a module create `.r10kignore` file in the same directory as your Puppetfile.
70
71
 
71
72
  ### r10k::print_git_conversion
73
+
72
74
  This rake task will go through the puppetfile and convert forge based modules into git based modules using
73
75
  the modules't source repository and version tag.
74
76
 
75
77
  This feature is useful when you want to bring all the forge modules into git source control. This assumes every module
76
78
  tags the release or provides a valid repo url. We recommend to manually review
77
- the output provided by this task before replacing the forge based content in your puppetfile as not every module author
79
+ the output provided by this task before replacing the forge based content in your puppetfile as not every module author
78
80
  tagged a release or provided a working url.
79
81
 
80
82
  ### r10k:solve_dependencies
@@ -95,34 +97,34 @@ Reads the Puppetfile in the current directory and installs them under the `path`
95
97
 
96
98
  #### Limitations
97
99
 
98
- * It works only with modules from the [Forge](https://forge.puppetlabs.com), and Git.
99
- SVN modules will be ignored.
100
- * Git support is explicitly SHA Ref and Tag supported. If tag is used it must follow
101
- `v0.0.0` convention, other wise it will be ignored.
102
- * The version has to be specified explicitly. If it is omitted, or it is
103
- `:latest`, the module will be ignored.
104
-
100
+ - It works only with modules from the [Forge](https://forge.puppetlabs.com), and Git.
101
+ SVN modules will be ignored.
102
+ - Git support is explicitly SHA Ref and Tag supported. If tag is used it must follow
103
+ `v0.0.0` convention, other wise it will be ignored.
104
+ - The version has to be specified explicitly. If it is omitted, or it is
105
+ `:latest`, the module will be ignored.
106
+
105
107
  ### r10k:validate[path]
106
- The validate rake task will determine if the url is a valid url by connecting
108
+
109
+ The validate rake task will determine if the url is a valid url by connecting
107
110
  to the repository and verififying it actually exists and can be accessed.
108
111
  Additional if a branch, tag, or ref is specified in the Puppetfile the validate
109
112
  task will also verify that that branch/tag/ref exists in the remote repository.
110
113
 
111
114
  If you have ever deployed r10k to production only to find out a tag or branch is
112
- missing this validate task will catch that issue.
115
+ missing this validate task will catch that issue.
113
116
 
114
117
  A exit status of 0 is returned if there are no faults, while a 1 is returned if
115
- any module has a bad status.
118
+ any module has a bad status.
116
119
 
117
120
  Status emojis can be customized by setting the following environment variables.
118
121
 
119
122
  Example
120
123
 
121
- * `GOOD_EMOJI='👍'`
122
- * `BAD_EMOJI='😨'`
123
-
124
+ - `GOOD_EMOJI='👍'`
125
+ - `BAD_EMOJI='😨'`
124
126
 
125
- ```
127
+ ```text
126
128
  NAME | URL | REF | STATUS
127
129
  ---------|-----------------------------------------------|--------------------------------|-------
128
130
  splunk | https://github.com/cudgel/splunk.git | dev | 👍
@@ -147,7 +149,7 @@ All found duplicates are reported along with their source and their version
147
149
 
148
150
  Example
149
151
 
150
- ```
152
+ ```text
151
153
  puppet:
152
154
  - abstractit/puppet from the forge at version 2.4.1
153
155
  - theforeman/puppet from the forge at version 12.0.1
@@ -167,14 +169,34 @@ for modules that are marked as deprecated on the Forge.
167
169
 
168
170
  Example
169
171
 
170
- ```
171
- NAME | DEPRECATED_AT
172
+ ```text
173
+ NAME | DEPRECATED_AT
172
174
  ------------------------|--------------------------
173
- kemra102-auditd | 2021-07-22 12:11:46
174
- puppet-staging | 2018-12-18 11:11:29
175
- puppetlabs-resource_api | 2021-03-31 12:53:24
176
- puppetlabs-ruby | 2021-04-22 10:29:42
177
- puppetlabs-translate | 2021-03-19 10:11:51
175
+ kemra102-auditd | 2021-07-22 12:11:46
176
+ puppet-staging | 2018-12-18 11:11:29
177
+ puppetlabs-resource_api | 2021-03-31 12:53:24
178
+ puppetlabs-ruby | 2021-04-22 10:29:42
179
+ puppetlabs-translate | 2021-03-19 10:11:51
178
180
 
179
181
  Error: Puppetfile contains deprecated modules.
180
182
  ```
183
+
184
+ ### r10k:diff[production,development]
185
+
186
+ This rake task will compare the modules in two branches and show the differences between them.
187
+ This is useful to see what modules have been changed, added or removed between two branches.
188
+ To pass the branches you may have to quote the arguments to prevent the shell from interpreting the `[]`.
189
+ For example `rake "r10k:diff[production,development]"`
190
+
191
+ Example
192
+
193
+ ```text
194
+ NAME | VERSION_A | VERSION_B | TYPE_A | TYPE_B | STATUS
195
+ --------|--------------------------------|--------------------------------|--------|--------|--------
196
+ inifile | 5.0.1 | 6.2.0 | forge | forge | changed
197
+ stdlib | 7.0.1 | 1b6f89afdde0df7f9433a163d5c... | forge | vcs | changed
198
+ systemd | 1.2.3 | | forge | | removed
199
+ apache | 1b6f89afdde0df7f9433a163d5c... | | vcs | | removed
200
+ rwaffen | v1.0.0 | v1.0.3 | vcs | vcs | changed
201
+ haproxy | | 1.0.0 | | forge | added
202
+ ```
@@ -0,0 +1,131 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git'
4
+ require 'r10k/puppetfile'
5
+
6
+ module Ra10ke
7
+ module Diff
8
+ class Task
9
+ attr_reader :repo, :puppetfile
10
+
11
+ def initialize
12
+ @repo = Git.open('.')
13
+ @original_branch = repo.current_branch
14
+ end
15
+
16
+ def run(branch_a:, branch_b:)
17
+ validate_clean_repo
18
+ validate_branches(branch_a, branch_b)
19
+
20
+ modules_a = load_modules(branch_a)
21
+ modules_b = load_modules(branch_b)
22
+
23
+ differences = calculate_differences(modules_a, modules_b)
24
+ print_differences(differences)
25
+ ensure
26
+ restore_original_branch
27
+ end
28
+
29
+ private
30
+
31
+ def validate_clean_repo
32
+ return if repo.status.changed.empty? && repo.status.untracked.empty?
33
+
34
+ abort('Git repository is not clean. Please commit or stash your changes before running this task.')
35
+ end
36
+
37
+ def validate_branches(branch_a, branch_b)
38
+ return if repo.is_branch?(branch_a) && repo.is_branch?(branch_b)
39
+
40
+ abort("One of the branches #{branch_a} or #{branch_b} does not exist.")
41
+ end
42
+
43
+ def load_modules(branch)
44
+ repo.checkout(branch)
45
+ puppetfile = get_puppetfile
46
+ puppetfile.load!
47
+
48
+ modules = {}
49
+ puppetfile.modules.each do |mod|
50
+ # Determine the type and version based on whether it responds to `v3_module`
51
+ if mod.respond_to?(:v3_module)
52
+ type = 'forge'
53
+ version = mod.expected_version
54
+ else
55
+ type = 'vcs'
56
+ version = mod.desired_ref
57
+ end
58
+
59
+ modules[mod.name] = { version: version, type: type }
60
+ end
61
+
62
+ modules
63
+ end
64
+
65
+ def calculate_differences(modules_a, modules_b)
66
+ all_modules = (modules_a.keys + modules_b.keys).uniq
67
+
68
+ differences = []
69
+ all_modules.each do |module_name|
70
+ module_a = modules_a[module_name]
71
+ module_b = modules_b[module_name]
72
+
73
+ version_a = module_a&.dig(:version)
74
+ version_b = module_b&.dig(:version)
75
+ type_a = module_a&.dig(:type)
76
+ type_b = module_b&.dig(:type)
77
+
78
+ if version_a && version_b && (version_a != version_b || type_a != type_b)
79
+ differences << {
80
+ name: module_name,
81
+ version_a: version_a,
82
+ version_b: version_b,
83
+ type_a: type_a,
84
+ type_b: type_b,
85
+ status: 'changed',
86
+ }
87
+ elsif version_a && !version_b
88
+ differences << {
89
+ name: module_name,
90
+ version_a: version_a,
91
+ version_b: nil,
92
+ type_a: type_a,
93
+ type_b: nil,
94
+ status: 'removed',
95
+ }
96
+ elsif !version_a && version_b
97
+ differences << {
98
+ name: module_name,
99
+ version_a: nil,
100
+ version_b: version_b,
101
+ type_a: nil,
102
+ type_b: type_b,
103
+ status: 'added',
104
+ }
105
+ end
106
+ end
107
+
108
+ differences
109
+ end
110
+
111
+ def print_differences(differences)
112
+ tp differences, :name, :version_a, :version_b, :type_a, :type_b, :status
113
+ end
114
+
115
+ def restore_original_branch
116
+ repo.checkout(@original_branch)
117
+ end
118
+
119
+ def get_puppetfile
120
+ R10K::Puppetfile.new(Dir.pwd)
121
+ end
122
+ end
123
+
124
+ def define_task_diff(*_args)
125
+ desc 'Check for module differences between two branches of a Puppetfile'
126
+ task :diff, [:branch_a, :branch_b] do |_task, args|
127
+ Task.new.run(branch_a: args[:branch_a], branch_b: args[:branch_b])
128
+ end
129
+ end
130
+ end
131
+ end
@@ -1,3 +1,3 @@
1
1
  module Ra10ke
2
- VERSION = '4.2.0'
2
+ VERSION = '4.3.0'
3
3
  end
data/lib/ra10ke.rb CHANGED
@@ -8,9 +8,11 @@ require 'ra10ke/deprecation'
8
8
  require 'ra10ke/duplicates'
9
9
  require 'ra10ke/install'
10
10
  require 'ra10ke/validate'
11
+ require 'ra10ke/diff'
11
12
  require 'git'
12
13
  require 'semverse'
13
14
  require 'r10k/puppetfile'
15
+
14
16
  module Ra10ke
15
17
  class RakeTask < ::Rake::TaskLib
16
18
  include Ra10ke::Solve
@@ -20,6 +22,7 @@ module Ra10ke
20
22
  include Ra10ke::Duplicates
21
23
  include Ra10ke::Install
22
24
  include Ra10ke::Validate
25
+ include Ra10ke::Diff
23
26
 
24
27
  attr_accessor :basedir, :moduledir, :puppetfile_path, :puppetfile_name, :force, :purge
25
28
 
@@ -42,6 +45,7 @@ module Ra10ke
42
45
  define_task_install(*args)
43
46
  define_task_validate(*args)
44
47
  define_task_print_git_conversion(*args)
48
+ define_task_diff(*args)
45
49
  end
46
50
  end
47
51
 
data/ra10ke.gemspec CHANGED
@@ -23,8 +23,6 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'semverse', '>= 2.0', '< 4'
24
24
  spec.add_dependency 'solve', '~> 4.0', '>= 4.0.4'
25
25
  spec.add_dependency 'table_print', '~> 1.5.6'
26
- spec.add_development_dependency 'pry', '~> 0.15.2'
27
26
  spec.add_development_dependency 'rspec', '~> 3.6'
28
- spec.add_development_dependency 'simplecov', '~> 0.22.0'
29
- spec.add_development_dependency 'voxpupuli-rubocop', '~> 3.0.0'
27
+ spec.add_development_dependency 'voxpupuli-rubocop', '~> 4.0.0'
30
28
  end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'ra10ke/diff'
5
+ require 'git'
6
+ require 'table_print'
7
+
8
+ RSpec.describe Ra10ke::Diff::Task do
9
+ let(:repo) { instance_double(Git::Base) }
10
+ let(:puppetfile) { instance_double(R10K::Puppetfile) }
11
+ let(:task) { described_class.new }
12
+
13
+ before do
14
+ allow(Git).to receive(:open).and_return(repo)
15
+ allow(repo).to receive_messages(current_branch: 'main', status: double(changed: {}, untracked: {}))
16
+ allow(repo).to receive(:is_branch?).with('branch_a').and_return(true)
17
+ allow(repo).to receive(:is_branch?).with('branch_b').and_return(true)
18
+ allow(repo).to receive(:checkout)
19
+ allow(task).to receive(:get_puppetfile).and_return(puppetfile)
20
+ allow(puppetfile).to receive(:load!) # Mock the load! method
21
+ end
22
+
23
+ describe '#run' do
24
+ it 'checks for a clean repository' do
25
+ allow(repo.status).to receive(:changed).and_return({ 'file1' => 'modified' })
26
+ expect { task.run(branch_a: 'branch_a', branch_b: 'branch_b') }.to raise_error(SystemExit)
27
+ end
28
+
29
+ it 'validates branch existence' do
30
+ allow(repo).to receive(:is_branch?).with('branch_a').and_return(false)
31
+ expect { task.run(branch_a: 'branch_a', branch_b: 'branch_b') }.to raise_error(SystemExit)
32
+ end
33
+
34
+ it 'detects added, removed, and changed modules with correct types and versions' do
35
+ # Mock the modules for branch_a and branch_b
36
+ forge_module1 = double('ForgeModule1', name: 'module1', expected_version: '1.0.0')
37
+ allow(forge_module1).to receive(:respond_to?).with(:v3_module).and_return(true)
38
+
39
+ vcs_module2 = double('VCSModule2', name: 'module2', desired_ref: '2.0.0')
40
+ allow(vcs_module2).to receive(:respond_to?).with(:v3_module).and_return(false)
41
+
42
+ forge_module1_updated = double('ForgeModule1Updated', name: 'module1', expected_version: '1.0.1')
43
+ allow(forge_module1_updated).to receive(:respond_to?).with(:v3_module).and_return(true)
44
+
45
+ vcs_module3 = double('VCSModule3', name: 'module3', desired_ref: '3.0.0')
46
+ allow(vcs_module3).to receive(:respond_to?).with(:v3_module).and_return(false)
47
+
48
+ # Mock the `modules` method on the puppetfile
49
+ allow(puppetfile).to receive(:modules).and_return(
50
+ [forge_module1, vcs_module2], # branch_a modules
51
+ [forge_module1_updated, vcs_module3], # branch_b modules
52
+ )
53
+
54
+ # Run the task
55
+ expect { task.run(branch_a: 'branch_a', branch_b: 'branch_b') }.not_to raise_error
56
+
57
+ # Add assertions for the output differences if needed
58
+ end
59
+
60
+ it 'restores the original branch after execution' do
61
+ expect(repo).to receive(:checkout).with('main')
62
+ allow(puppetfile).to receive(:modules).and_return([]) # Mock empty modules to avoid errors
63
+ task.run(branch_a: 'branch_a', branch_b: 'branch_b')
64
+ end
65
+ end
66
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,29 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- begin
4
- require 'simplecov'
5
- require 'simplecov-console'
6
- require 'codecov'
7
- rescue LoadError
8
- else
9
- SimpleCov.start do
10
- track_files 'lib/**/*.rb'
11
-
12
- add_filter '/spec'
13
-
14
- enable_coverage :branch
15
-
16
- # do not track vendored files
17
- add_filter '/vendor'
18
- add_filter '/.vendor'
19
- end
20
-
21
- SimpleCov.formatters = [
22
- SimpleCov::Formatter::Console,
23
- SimpleCov::Formatter::Codecov,
24
- ]
25
- end
26
-
27
3
  require 'rspec/core'
28
4
 
29
5
  def fixtures_dir
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ra10ke
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo Chatzimichos
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-02-28 00:00:00.000000000 Z
12
+ date: 2025-05-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: git
@@ -133,20 +133,6 @@ dependencies:
133
133
  - - "~>"
134
134
  - !ruby/object:Gem::Version
135
135
  version: 1.5.6
136
- - !ruby/object:Gem::Dependency
137
- name: pry
138
- requirement: !ruby/object:Gem::Requirement
139
- requirements:
140
- - - "~>"
141
- - !ruby/object:Gem::Version
142
- version: 0.15.2
143
- type: :development
144
- prerelease: false
145
- version_requirements: !ruby/object:Gem::Requirement
146
- requirements:
147
- - - "~>"
148
- - !ruby/object:Gem::Version
149
- version: 0.15.2
150
136
  - !ruby/object:Gem::Dependency
151
137
  name: rspec
152
138
  requirement: !ruby/object:Gem::Requirement
@@ -161,34 +147,20 @@ dependencies:
161
147
  - - "~>"
162
148
  - !ruby/object:Gem::Version
163
149
  version: '3.6'
164
- - !ruby/object:Gem::Dependency
165
- name: simplecov
166
- requirement: !ruby/object:Gem::Requirement
167
- requirements:
168
- - - "~>"
169
- - !ruby/object:Gem::Version
170
- version: 0.22.0
171
- type: :development
172
- prerelease: false
173
- version_requirements: !ruby/object:Gem::Requirement
174
- requirements:
175
- - - "~>"
176
- - !ruby/object:Gem::Version
177
- version: 0.22.0
178
150
  - !ruby/object:Gem::Dependency
179
151
  name: voxpupuli-rubocop
180
152
  requirement: !ruby/object:Gem::Requirement
181
153
  requirements:
182
154
  - - "~>"
183
155
  - !ruby/object:Gem::Version
184
- version: 3.0.0
156
+ version: 4.0.0
185
157
  type: :development
186
158
  prerelease: false
187
159
  version_requirements: !ruby/object:Gem::Requirement
188
160
  requirements:
189
161
  - - "~>"
190
162
  - !ruby/object:Gem::Version
191
- version: 3.0.0
163
+ version: 4.0.0
192
164
  description: R10K and Puppetfile rake tasks
193
165
  email:
194
166
  - voxpupuli@groups.io
@@ -212,6 +184,7 @@ files:
212
184
  - lib/ra10ke.rb
213
185
  - lib/ra10ke/dependencies.rb
214
186
  - lib/ra10ke/deprecation.rb
187
+ - lib/ra10ke/diff.rb
215
188
  - lib/ra10ke/duplicates.rb
216
189
  - lib/ra10ke/git_repo.rb
217
190
  - lib/ra10ke/install.rb
@@ -236,6 +209,7 @@ files:
236
209
  - spec/fixtures/refs/reflist.txt
237
210
  - spec/ra10ke/dependencies_spec.rb
238
211
  - spec/ra10ke/deprecation_spec.rb
212
+ - spec/ra10ke/diff_spec.rb
239
213
  - spec/ra10ke/duplicates_spec.rb
240
214
  - spec/ra10ke/git_repo_spec.rb
241
215
  - spec/ra10ke/puppetfile_parser_spec.rb