ra10ke 0.6.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/release.yml +32 -0
- data/.github/workflows/test.yml +35 -0
- data/.gitignore +3 -0
- data/.ruby-version +1 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +74 -2
- data/Gemfile +9 -0
- data/HISTORY.md +118 -0
- data/README.md +56 -9
- data/Rakefile +13 -0
- data/lib/ra10ke/dependencies.rb +34 -12
- data/lib/ra10ke/deprecation.rb +72 -0
- data/lib/ra10ke/duplicates.rb +79 -0
- data/lib/ra10ke/git_repo.rb +116 -0
- data/lib/ra10ke/puppetfile_parser.rb +9 -2
- data/lib/ra10ke/validate.rb +18 -60
- data/lib/ra10ke/version.rb +1 -1
- data/lib/ra10ke.rb +8 -0
- data/ra10ke.gemspec +7 -4
- data/spec/fixtures/Puppetfile +7 -1
- data/spec/fixtures/Puppetfile_with_bad_refs +3 -0
- data/spec/fixtures/Puppetfile_with_control_branch +23 -0
- data/spec/fixtures/Puppetfile_with_duplicates +50 -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} +1 -0
- data/spec/ra10ke/dependencies_spec.rb +72 -0
- data/spec/ra10ke/deprecation_spec.rb +37 -0
- data/spec/ra10ke/duplicates_spec.rb +31 -0
- data/spec/ra10ke/git_repo_spec.rb +88 -0
- data/spec/ra10ke/puppetfile_parser_spec.rb +11 -3
- data/spec/ra10ke/validate_spec.rb +87 -36
- data/spec/ra10ke_spec.rb +6 -4
- data/spec/spec_helper.rb +28 -0
- metadata +53 -9
@@ -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"},
|
@@ -43,8 +45,11 @@ RSpec.describe 'Ra10ke::PuppetfileParser' do
|
|
43
45
|
{:branch=>"master", :git=>"https://github.com/cudgel/puppet-dotfiles.git"},
|
44
46
|
:name=>"dotfiles",
|
45
47
|
:namespace=>nil},
|
46
|
-
{:args=>{:branch=>"
|
48
|
+
{:args=>{:branch=>"dev", :git=>"https://github.com/cudgel/splunk.git"},
|
47
49
|
:name=>"splunk",
|
50
|
+
:namespace=>nil},
|
51
|
+
{:args=>{:branch=>"master", :git=>"https://github.com/voxpupuli/puppet-module.git"},
|
52
|
+
:name=>"puppet",
|
48
53
|
:namespace=>nil}]
|
49
54
|
end
|
50
55
|
|
@@ -83,8 +88,11 @@ RSpec.describe 'Ra10ke::PuppetfileParser' do
|
|
83
88
|
{:branch=>"master", :git=>"https://github.com/cudgel/puppet-dotfiles.git"},
|
84
89
|
:name=>"dotfiles",
|
85
90
|
:namespace=>nil},
|
86
|
-
{:args=>{:branch=>"
|
91
|
+
{:args=>{:branch=>"dev", :git=>"https://github.com/cudgel/splunk.git"},
|
87
92
|
:name=>"splunk",
|
93
|
+
:namespace=>nil},
|
94
|
+
{:args=>{:branch=>"master", :git=>"https://github.com/voxpupuli/puppet-module.git"},
|
95
|
+
:name=>"puppet",
|
88
96
|
:namespace=>nil}]
|
89
97
|
expect(git_modules(puppetfile)).to eq(expected)
|
90
98
|
end
|
@@ -9,40 +9,101 @@ RSpec.describe 'Ra10ke::Validate::Validation' do
|
|
9
9
|
Ra10ke::Validate::Validation.new(puppetfile)
|
10
10
|
end
|
11
11
|
|
12
|
-
let(:result) do
|
13
|
-
double
|
14
|
-
end
|
15
|
-
|
16
|
-
before(:each) do
|
17
|
-
allow(result).to receive(:success?).and_return(true)
|
18
|
-
# allow(instance).to receive(:`).with(anything).and_return(result)
|
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')))
|
22
|
-
end
|
23
|
-
|
24
12
|
let(:puppetfile) do
|
25
13
|
File.join(fixtures_dir, 'Puppetfile')
|
26
14
|
end
|
27
15
|
|
28
|
-
|
29
|
-
|
16
|
+
before(:each) do
|
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)
|
30
19
|
end
|
31
20
|
|
32
|
-
|
33
|
-
|
21
|
+
describe 'bad url' do
|
22
|
+
let(:instance) do
|
23
|
+
Ra10ke::Validate::Validation.new(puppetfile)
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:puppetfile) do
|
27
|
+
File.join(fixtures_dir, 'Puppetfile_with_bad_refs')
|
28
|
+
end
|
29
|
+
|
30
|
+
before(:each) do
|
31
|
+
working = double('Ra1ke::GitRepo', url: 'https://github.com/vshn/puppet-gitlab')
|
32
|
+
expect(working).to receive(:valid_ref?).with('00397b86dfb3487d9df768cbd3698d362132b5bf').and_return(false)
|
33
|
+
expect(working).to receive(:valid_commit?).with('00397b86dfb3487d9df768cbd3698d362132b5bf').and_return(true)
|
34
|
+
expect(working).to receive(:valid_url?).and_return(true)
|
35
|
+
bad_tag = double('Ra1ke::GitRepo', url: 'https://github.com/acidprime/r10k')
|
36
|
+
expect(bad_tag).to receive(:valid_ref?).with('bad').and_return(false)
|
37
|
+
expect(bad_tag).to receive(:valid_commit?).with(nil).and_return(false)
|
38
|
+
expect(bad_tag).to receive(:valid_url?).and_return(true)
|
39
|
+
bad_url = double('Ra1ke::GitRepo', url: 'https://github.com/nwops/typo')
|
40
|
+
expect(bad_url).to receive(:valid_ref?).with(nil).and_return(false)
|
41
|
+
expect(bad_url).to receive(:valid_commit?).with(nil).and_return(false)
|
42
|
+
expect(bad_url).to receive(:valid_url?).and_return(false)
|
43
|
+
|
44
|
+
expect(Ra10ke::GitRepo).to receive(:new).and_return(working, bad_tag, bad_url)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'details mods that are bad' do
|
48
|
+
expect(instance.all_modules.find { |m| !m[:valid_url?] }).to be_a Hash
|
49
|
+
expect(instance.all_modules.find_all { |m| !m[:valid_ref?] }.count).to eq(2)
|
50
|
+
end
|
34
51
|
end
|
35
52
|
|
36
|
-
|
37
|
-
|
53
|
+
describe 'control_branch' do
|
54
|
+
before(:each) do
|
55
|
+
ENV.delete 'CONTROL_BRANCH'
|
56
|
+
ENV.delete 'CONTROL_BRANCH_FALLBACK'
|
57
|
+
end
|
58
|
+
|
59
|
+
let(:instance) do
|
60
|
+
Ra10ke::Validate::Validation.new(puppetfile)
|
61
|
+
end
|
62
|
+
|
63
|
+
let(:puppetfile) do
|
64
|
+
File.join(fixtures_dir, 'Puppetfile_with_control_branch')
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'correctly replaces control branch' do
|
68
|
+
ENV['CONTROL_BRANCH'] = 'env-control_branch'
|
69
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_control' }[:ref]).to eq('env-control_branch')
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'correctly detects current branch' do
|
73
|
+
allow(Ra10ke::GitRepo).to receive(:current_branch).and_return('current_branch-control_branch')
|
74
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_control' }[:ref]).to eq('current_branch-control_branch')
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'correctly falls back if no current branch' do
|
78
|
+
ENV['CONTROL_BRANCH_FALLBACK'] = 'env-control_branch_fallback'
|
79
|
+
allow(Ra10ke::GitRepo).to receive(:current_branch).and_return(nil)
|
80
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_control' }[:ref]).to eq('env-control_branch_fallback')
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'correctly falls back to default_branch if no current branch' do
|
84
|
+
allow(Ra10ke::GitRepo).to receive(:current_branch).and_return(nil)
|
85
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_controlwithdefault' }[:ref]).to eq('master')
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'correctly falls back to fallback if no current branch but default 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_controlwithdefault' }[:ref]).to eq('env-control_branch_fallback')
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'correctly falls back to default_branch if no current branch with override' do
|
95
|
+
allow(Ra10ke::GitRepo).to receive(:current_branch).and_return(nil)
|
96
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_controlwithdefaultoverride' }[:ref]).to eq('master')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'correctly falls back to main if no current branch and no fallback' do
|
100
|
+
allow(Ra10ke::GitRepo).to receive(:current_branch).and_return(nil)
|
101
|
+
expect(instance.all_modules.find { |m| m[:name] == 'hiera_control' }[:ref]).to eq('main')
|
102
|
+
end
|
38
103
|
end
|
39
104
|
|
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
|
105
|
+
it '#new' do
|
106
|
+
expect(instance).to be_a Ra10ke::Validate::Validation
|
46
107
|
end
|
47
108
|
|
48
109
|
it '#all_modules is an array' do
|
@@ -59,23 +120,13 @@ RSpec.describe 'Ra10ke::Validate::Validation' do
|
|
59
120
|
|
60
121
|
it '#data is a hash with keys' do
|
61
122
|
keys = instance.all_modules.first.keys
|
62
|
-
expect(keys).to eq(%i[name url ref valid_ref? status])
|
123
|
+
expect(keys).to eq(%i[name url ref valid_url? valid_ref? status])
|
63
124
|
end
|
64
125
|
|
65
126
|
it '#data is a hash with values' do
|
66
127
|
keys = instance.all_modules.first.values
|
67
128
|
|
68
129
|
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 Hash
|
75
|
-
expect(refs.first).to eq(
|
76
|
-
["0ec707e431367bbe2752966be8ab915b6f0da754",
|
77
|
-
{:name=>"74110ac", :ref=>"refs/heads/74110ac", :subtype=>nil, :type=>:branch}]
|
78
|
-
)
|
79
|
-
|
130
|
+
'00397b86dfb3487d9df768cbd3698d362132b5bf', true, true, '👍'])
|
80
131
|
end
|
81
132
|
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,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ra10ke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Theo Chatzimichos
|
8
|
+
- Vox Pupuli
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2021-10-26 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rake
|
@@ -84,14 +85,14 @@ dependencies:
|
|
84
85
|
name: semverse
|
85
86
|
requirement: !ruby/object:Gem::Requirement
|
86
87
|
requirements:
|
87
|
-
- - "
|
88
|
+
- - ">="
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: '2.0'
|
90
91
|
type: :runtime
|
91
92
|
prerelease: false
|
92
93
|
version_requirements: !ruby/object:Gem::Requirement
|
93
94
|
requirements:
|
94
|
-
- - "
|
95
|
+
- - ">="
|
95
96
|
- !ruby/object:Gem::Version
|
96
97
|
version: '2.0'
|
97
98
|
- !ruby/object:Gem::Dependency
|
@@ -122,23 +123,58 @@ dependencies:
|
|
122
123
|
- - "~>"
|
123
124
|
- !ruby/object:Gem::Version
|
124
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'
|
125
154
|
description: R10K and Puppetfile rake tasks
|
126
155
|
email:
|
127
|
-
-
|
156
|
+
- voxpupuli@groups.io
|
128
157
|
executables: []
|
129
158
|
extensions: []
|
130
159
|
extra_rdoc_files: []
|
131
160
|
files:
|
161
|
+
- ".github/dependabot.yml"
|
162
|
+
- ".github/workflows/release.yml"
|
163
|
+
- ".github/workflows/test.yml"
|
132
164
|
- ".gitignore"
|
133
165
|
- ".ruby-version"
|
134
166
|
- ".travis.yml"
|
135
167
|
- CHANGELOG.md
|
136
168
|
- Gemfile
|
169
|
+
- HISTORY.md
|
137
170
|
- LICENSE.txt
|
138
171
|
- README.md
|
139
172
|
- Rakefile
|
140
173
|
- lib/ra10ke.rb
|
141
174
|
- lib/ra10ke/dependencies.rb
|
175
|
+
- lib/ra10ke/deprecation.rb
|
176
|
+
- lib/ra10ke/duplicates.rb
|
177
|
+
- lib/ra10ke/git_repo.rb
|
142
178
|
- lib/ra10ke/install.rb
|
143
179
|
- lib/ra10ke/monkey_patches.rb
|
144
180
|
- lib/ra10ke/puppetfile_parser.rb
|
@@ -150,7 +186,16 @@ files:
|
|
150
186
|
- spec/fixtures/Puppetfile
|
151
187
|
- spec/fixtures/Puppetfile_test
|
152
188
|
- spec/fixtures/Puppetfile_with_bad_refs
|
153
|
-
- spec/fixtures/
|
189
|
+
- spec/fixtures/Puppetfile_with_control_branch
|
190
|
+
- spec/fixtures/Puppetfile_with_duplicates
|
191
|
+
- spec/fixtures/refs/debug.txt
|
192
|
+
- spec/fixtures/refs/gitlab.txt
|
193
|
+
- spec/fixtures/refs/r10k.txt
|
194
|
+
- spec/fixtures/refs/reflist.txt
|
195
|
+
- spec/ra10ke/dependencies_spec.rb
|
196
|
+
- spec/ra10ke/deprecation_spec.rb
|
197
|
+
- spec/ra10ke/duplicates_spec.rb
|
198
|
+
- spec/ra10ke/git_repo_spec.rb
|
154
199
|
- spec/ra10ke/puppetfile_parser_spec.rb
|
155
200
|
- spec/ra10ke/validate_spec.rb
|
156
201
|
- spec/ra10ke_spec.rb
|
@@ -167,15 +212,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
167
212
|
requirements:
|
168
213
|
- - ">="
|
169
214
|
- !ruby/object:Gem::Version
|
170
|
-
version: 2.
|
215
|
+
version: 2.4.0
|
171
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
217
|
requirements:
|
173
218
|
- - ">="
|
174
219
|
- !ruby/object:Gem::Version
|
175
220
|
version: '0'
|
176
221
|
requirements: []
|
177
|
-
|
178
|
-
rubygems_version: 2.7.7
|
222
|
+
rubygems_version: 3.2.22
|
179
223
|
signing_key:
|
180
224
|
specification_version: 4
|
181
225
|
summary: Syntax check for the Puppetfile, check for outdated installed puppet modules
|