ra10ke 1.0.0 → 2.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/.github/dependabot.yml +11 -0
- data/.github/workflows/release.yml +32 -0
- data/.github/workflows/test.yml +32 -0
- data/.gitignore +3 -0
- data/.ruby-version +1 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +72 -4
- data/Gemfile +9 -0
- data/HISTORY.md +118 -0
- data/README.md +34 -1
- data/Rakefile +13 -0
- data/lib/ra10ke/dependencies.rb +172 -49
- data/lib/ra10ke/deprecation.rb +72 -0
- data/lib/ra10ke/git_repo.rb +128 -0
- data/lib/ra10ke/puppetfile_parser.rb +9 -2
- data/lib/ra10ke/solve.rb +4 -0
- data/lib/ra10ke/validate.rb +19 -60
- data/lib/ra10ke/version.rb +1 -1
- data/lib/ra10ke.rb +6 -0
- data/ra10ke.gemspec +5 -2
- data/spec/fixtures/Puppetfile +2 -0
- data/spec/fixtures/Puppetfile_deprecation_issue +78 -0
- data/spec/fixtures/Puppetfile_git_conversion +28 -0
- data/spec/fixtures/Puppetfile_with_bad_refs +3 -0
- data/spec/fixtures/Puppetfile_with_commit +3 -0
- data/spec/fixtures/Puppetfile_with_control_branch +23 -0
- data/spec/fixtures/refs/debug.txt +0 -0
- data/spec/fixtures/refs/gitlab.txt +285 -0
- data/spec/fixtures/refs/r10k.txt +120 -0
- data/spec/fixtures/{reflist.txt → refs/reflist.txt} +0 -0
- data/spec/ra10ke/dependencies_spec.rb +108 -0
- data/spec/ra10ke/deprecation_spec.rb +48 -0
- data/spec/ra10ke/git_repo_spec.rb +92 -0
- data/spec/ra10ke/puppetfile_parser_spec.rb +3 -1
- data/spec/ra10ke/validate_spec.rb +96 -33
- data/spec/ra10ke_spec.rb +6 -4
- data/spec/spec_helper.rb +28 -0
- metadata +51 -8
@@ -9,7 +9,9 @@ RSpec.describe 'Ra10ke::PuppetfileParser' do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
let(:puppetfile_modules) do
|
12
|
-
[{:args=>{:version=>
|
12
|
+
[{:args=>{:version=>'0.26.2'}, :name=>'choria', :namespace=>nil},
|
13
|
+
{:args=>{:version=>"2.2.0"}, :name=>"inifile", :namespace=>"puppetlabs"},
|
14
|
+
{:args=>{:version=>"1.0.1"}, :name=>"ruby", :namespace=>"puppetlabs"},
|
13
15
|
{:args=>{:version=>"4.24.0"}, :name=>"stdlib", :namespace=>"puppetlabs"},
|
14
16
|
{:args=>{:version=>"4.0.0"}, :name=>"concat", :namespace=>"puppetlabs"},
|
15
17
|
{:args=>{:version=>"6.4.1"}, :name=>"ntp", :namespace=>"puppetlabs"},
|
@@ -9,40 +9,112 @@ RSpec.describe 'Ra10ke::Validate::Validation' do
|
|
9
9
|
Ra10ke::Validate::Validation.new(puppetfile)
|
10
10
|
end
|
11
11
|
|
12
|
-
let(:
|
13
|
-
|
12
|
+
let(:puppetfile) do
|
13
|
+
File.join(fixtures_dir, 'Puppetfile')
|
14
14
|
end
|
15
15
|
|
16
16
|
before(:each) do
|
17
|
-
|
18
|
-
|
19
|
-
allow($CHILD_STATUS).to receive(:success?).and_return(true)
|
20
|
-
allow(instance).to receive(:`).with(anything)
|
21
|
-
.and_return(File.read(File.join(fixtures_dir, 'reflist.txt')))
|
17
|
+
allow_any_instance_of(Ra10ke::GitRepo).to receive(:valid_ref?).and_return(true)
|
18
|
+
allow_any_instance_of(Ra10ke::GitRepo).to receive(:valid_url?).and_return(true)
|
22
19
|
end
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
describe 'with commit' do
|
22
|
+
let(:puppetfile) do
|
23
|
+
File.join(fixtures_dir, 'Puppetfile_with_commit')
|
24
|
+
end
|
27
25
|
|
28
|
-
|
29
|
-
|
26
|
+
it '#data is a hash with values' do
|
27
|
+
keys = instance.all_modules.first.values
|
28
|
+
expect(keys).to eq(["ntp", "https://github.com/puppetlabs/puppetlabs-ntp", "81b34c6", true, true, "👍"])
|
29
|
+
end
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
describe 'bad url' do
|
33
|
+
let(:instance) do
|
34
|
+
Ra10ke::Validate::Validation.new(puppetfile)
|
35
|
+
end
|
36
|
+
|
37
|
+
let(:puppetfile) do
|
38
|
+
File.join(fixtures_dir, 'Puppetfile_with_bad_refs')
|
39
|
+
end
|
40
|
+
|
41
|
+
before(:each) do
|
42
|
+
working = double('Ra1ke::GitRepo', url: 'https://github.com/vshn/puppet-gitlab')
|
43
|
+
expect(working).to receive(:valid_ref?).with('00397b86dfb3487d9df768cbd3698d362132b5bf').and_return(false)
|
44
|
+
expect(working).to receive(:valid_commit?).with('00397b86dfb3487d9df768cbd3698d362132b5bf').and_return(true)
|
45
|
+
expect(working).to receive(:valid_url?).and_return(true)
|
46
|
+
bad_tag = double('Ra1ke::GitRepo', url: 'https://github.com/acidprime/r10k')
|
47
|
+
expect(bad_tag).to receive(:valid_ref?).with('bad').and_return(false)
|
48
|
+
expect(bad_tag).to receive(:valid_commit?).with(nil).and_return(false)
|
49
|
+
expect(bad_tag).to receive(:valid_url?).and_return(true)
|
50
|
+
bad_url = double('Ra1ke::GitRepo', url: 'https://github.com/nwops/typo')
|
51
|
+
expect(bad_url).to receive(:valid_ref?).with(nil).and_return(false)
|
52
|
+
expect(bad_url).to receive(:valid_commit?).with(nil).and_return(false)
|
53
|
+
expect(bad_url).to receive(:valid_url?).and_return(false)
|
54
|
+
|
55
|
+
expect(Ra10ke::GitRepo).to receive(:new).and_return(working, bad_tag, bad_url)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'details mods that are bad' do
|
59
|
+
expect(instance.all_modules.find { |m| !m[:valid_url?] }).to be_a Hash
|
60
|
+
expect(instance.all_modules.find_all { |m| !m[:valid_ref?] }.count).to eq(2)
|
61
|
+
end
|
34
62
|
end
|
35
63
|
|
36
|
-
|
37
|
-
|
64
|
+
describe 'control_branch' do
|
65
|
+
before(:each) do
|
66
|
+
ENV.delete 'CONTROL_BRANCH'
|
67
|
+
ENV.delete 'CONTROL_BRANCH_FALLBACK'
|
68
|
+
end
|
69
|
+
|
70
|
+
let(:instance) do
|
71
|
+
Ra10ke::Validate::Validation.new(puppetfile)
|
72
|
+
end
|
73
|
+
|
74
|
+
let(:puppetfile) do
|
75
|
+
File.join(fixtures_dir, 'Puppetfile_with_control_branch')
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'correctly replaces control branch' do
|
79
|
+
ENV['CONTROL_BRANCH'] = 'env-control_branch'
|
80
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_control' }[:ref]).to eq('env-control_branch')
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'correctly detects current branch' do
|
84
|
+
allow(Ra10ke::GitRepo).to receive(:current_branch).and_return('current_branch-control_branch')
|
85
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_control' }[:ref]).to eq('current_branch-control_branch')
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'correctly falls back if no current branch' do
|
89
|
+
ENV['CONTROL_BRANCH_FALLBACK'] = 'env-control_branch_fallback'
|
90
|
+
allow(Ra10ke::GitRepo).to receive(:current_branch).and_return(nil)
|
91
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_control' }[:ref]).to eq('env-control_branch_fallback')
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'correctly falls back to default_branch if no current branch' do
|
95
|
+
allow(Ra10ke::GitRepo).to receive(:current_branch).and_return(nil)
|
96
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_controlwithdefault' }[:ref]).to eq('master')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'correctly falls back to fallback if no current branch but default branch' do
|
100
|
+
ENV['CONTROL_BRANCH_FALLBACK'] = 'env-control_branch_fallback'
|
101
|
+
allow(Ra10ke::GitRepo).to receive(:current_branch).and_return(nil)
|
102
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_controlwithdefault' }[:ref]).to eq('env-control_branch_fallback')
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'correctly falls back to default_branch if no current branch with override' do
|
106
|
+
allow(Ra10ke::GitRepo).to receive(:current_branch).and_return(nil)
|
107
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_controlwithdefaultoverride' }[:ref]).to eq('master')
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'correctly falls back to main if no current branch and no fallback' do
|
111
|
+
allow(Ra10ke::GitRepo).to receive(:current_branch).and_return(nil)
|
112
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_control' }[:ref]).to eq('main')
|
113
|
+
end
|
38
114
|
end
|
39
115
|
|
40
|
-
it '#
|
41
|
-
|
42
|
-
.and_return(File.read(File.join(fixtures_dir, 'reflist.txt')))
|
43
|
-
# because we can't test every single module we return the same result set
|
44
|
-
# which only passes for a single module, while others fail.
|
45
|
-
expect(instance.bad_mods?).to be true
|
116
|
+
it '#new' do
|
117
|
+
expect(instance).to be_a Ra10ke::Validate::Validation
|
46
118
|
end
|
47
119
|
|
48
120
|
it '#all_modules is an array' do
|
@@ -59,22 +131,13 @@ RSpec.describe 'Ra10ke::Validate::Validation' do
|
|
59
131
|
|
60
132
|
it '#data is a hash with keys' do
|
61
133
|
keys = instance.all_modules.first.keys
|
62
|
-
expect(keys).to eq(%i[name url ref valid_ref? status])
|
134
|
+
expect(keys).to eq(%i[name url ref valid_url? valid_ref? status])
|
63
135
|
end
|
64
136
|
|
65
137
|
it '#data is a hash with values' do
|
66
138
|
keys = instance.all_modules.first.values
|
67
139
|
|
68
140
|
expect(keys).to eq(['gitlab', 'https://github.com/vshn/puppet-gitlab',
|
69
|
-
'00397b86dfb3487d9df768cbd3698d362132b5bf', true, '👍'])
|
70
|
-
end
|
71
|
-
|
72
|
-
it '#all_refs' do
|
73
|
-
refs = instance.all_refs('https://www.example.com')
|
74
|
-
expect(refs).to be_a Array
|
75
|
-
expect(refs.first).to eq(
|
76
|
-
{:sha=>"0ec707e431367bbe2752966be8ab915b6f0da754",:name=>"74110ac", :ref=>"refs/heads/74110ac", :subtype=>nil, :type=>:branch}
|
77
|
-
)
|
78
|
-
|
141
|
+
'00397b86dfb3487d9df768cbd3698d362132b5bf', true, true, '👍'])
|
79
142
|
end
|
80
143
|
end
|
data/spec/ra10ke_spec.rb
CHANGED
@@ -6,7 +6,7 @@ require 'spec_helper'
|
|
6
6
|
RSpec.describe 'Ra10ke::RakeTask' do
|
7
7
|
let(:instance) do
|
8
8
|
Ra10ke::RakeTask.new do |t|
|
9
|
-
|
9
|
+
t.puppetfile_path = puppetfile
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -50,6 +50,9 @@ RSpec.describe 'Ra10ke::RakeTask' do
|
|
50
50
|
|
51
51
|
describe 'run tasks with good refs' do
|
52
52
|
it '#run_validate_task' do
|
53
|
+
allow_any_instance_of(Ra10ke::GitRepo).to receive(:valid_ref?).and_return(true)
|
54
|
+
allow_any_instance_of(Ra10ke::GitRepo).to receive(:valid_url?).and_return(true)
|
55
|
+
|
53
56
|
task = instance.define_task_validate(args)
|
54
57
|
expect(task.invoke).to be_a Array
|
55
58
|
end
|
@@ -59,14 +62,13 @@ RSpec.describe 'Ra10ke::RakeTask' do
|
|
59
62
|
let(:puppetfile) do
|
60
63
|
File.join(fixtures_dir, 'Puppetfile_with_bad_refs')
|
61
64
|
end
|
62
|
-
|
65
|
+
|
63
66
|
# I suspect rake is caching something here and the puppetfile is
|
64
67
|
# not being sent correctly as it is not using the file I specify.
|
65
68
|
# The output should be different.
|
66
69
|
# Testing this by itself works
|
67
70
|
it '#run_validate_task' do
|
68
|
-
|
69
|
-
task2 = t.define_task_validate(args)
|
71
|
+
task2 = instance.define_task_validate(args)
|
70
72
|
expect(task2.invoke).to be nil
|
71
73
|
end
|
72
74
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
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
|
+
require 'rspec/core'
|
28
|
+
|
1
29
|
def fixtures_dir
|
2
30
|
File.join(__dir__, 'fixtures')
|
3
31
|
end
|
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
|
+
version: 2.0.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:
|
12
|
+
date: 2022-05-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 2.6.5
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 2.6.5
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: git
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +123,34 @@ dependencies:
|
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '3.6'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: pry
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: simplecov
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
126
154
|
description: R10K and Puppetfile rake tasks
|
127
155
|
email:
|
128
156
|
- voxpupuli@groups.io
|
@@ -130,17 +158,23 @@ executables: []
|
|
130
158
|
extensions: []
|
131
159
|
extra_rdoc_files: []
|
132
160
|
files:
|
161
|
+
- ".github/dependabot.yml"
|
162
|
+
- ".github/workflows/release.yml"
|
163
|
+
- ".github/workflows/test.yml"
|
133
164
|
- ".gitignore"
|
134
165
|
- ".ruby-version"
|
135
166
|
- ".travis.yml"
|
136
167
|
- CHANGELOG.md
|
137
168
|
- Gemfile
|
169
|
+
- HISTORY.md
|
138
170
|
- LICENSE.txt
|
139
171
|
- README.md
|
140
172
|
- Rakefile
|
141
173
|
- lib/ra10ke.rb
|
142
174
|
- lib/ra10ke/dependencies.rb
|
175
|
+
- lib/ra10ke/deprecation.rb
|
143
176
|
- lib/ra10ke/duplicates.rb
|
177
|
+
- lib/ra10ke/git_repo.rb
|
144
178
|
- lib/ra10ke/install.rb
|
145
179
|
- lib/ra10ke/monkey_patches.rb
|
146
180
|
- lib/ra10ke/puppetfile_parser.rb
|
@@ -150,11 +184,21 @@ files:
|
|
150
184
|
- lib/ra10ke/version.rb
|
151
185
|
- ra10ke.gemspec
|
152
186
|
- spec/fixtures/Puppetfile
|
187
|
+
- spec/fixtures/Puppetfile_deprecation_issue
|
188
|
+
- spec/fixtures/Puppetfile_git_conversion
|
153
189
|
- spec/fixtures/Puppetfile_test
|
154
190
|
- spec/fixtures/Puppetfile_with_bad_refs
|
191
|
+
- spec/fixtures/Puppetfile_with_commit
|
192
|
+
- spec/fixtures/Puppetfile_with_control_branch
|
155
193
|
- spec/fixtures/Puppetfile_with_duplicates
|
156
|
-
- spec/fixtures/
|
194
|
+
- spec/fixtures/refs/debug.txt
|
195
|
+
- spec/fixtures/refs/gitlab.txt
|
196
|
+
- spec/fixtures/refs/r10k.txt
|
197
|
+
- spec/fixtures/refs/reflist.txt
|
198
|
+
- spec/ra10ke/dependencies_spec.rb
|
199
|
+
- spec/ra10ke/deprecation_spec.rb
|
157
200
|
- spec/ra10ke/duplicates_spec.rb
|
201
|
+
- spec/ra10ke/git_repo_spec.rb
|
158
202
|
- spec/ra10ke/puppetfile_parser_spec.rb
|
159
203
|
- spec/ra10ke/validate_spec.rb
|
160
204
|
- spec/ra10ke_spec.rb
|
@@ -171,15 +215,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
215
|
requirements:
|
172
216
|
- - ">="
|
173
217
|
- !ruby/object:Gem::Version
|
174
|
-
version: 2.
|
218
|
+
version: 2.6.0
|
175
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
220
|
requirements:
|
177
221
|
- - ">="
|
178
222
|
- !ruby/object:Gem::Version
|
179
223
|
version: '0'
|
180
224
|
requirements: []
|
181
|
-
|
182
|
-
rubygems_version: 2.7.7
|
225
|
+
rubygems_version: 3.2.33
|
183
226
|
signing_key:
|
184
227
|
specification_version: 4
|
185
228
|
summary: Syntax check for the Puppetfile, check for outdated installed puppet modules
|