voxpupuli-test 13.1.0 → 14.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/README.md +23 -0
- data/lib/voxpupuli/test/rake/check.rb +44 -0
- data/lib/voxpupuli/test/rake/rubocop.rb +9 -0
- data/lib/voxpupuli/test/rubocop_formatters/codeclimate.rb +73 -0
- data/rubocop.yml +18 -8
- metadata +22 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2dcdc2312c0db968dcddca73a0eaf60ad5539c0379b2b2eefb002be318d0cb30
|
|
4
|
+
data.tar.gz: beb9801b4df1e885457200039cc349e57051daa338a650017c34fb749e8bc2e0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '029d81551fb4428b08a9d0c82e17a04b95e14770e34fc1893a245a2cb7f77f2dd7497cada13203d172ad09fd2dbaf7538b9e701c40c08804ec408e07c989f45f'
|
|
7
|
+
data.tar.gz: 59542f5c3ea5340aeb0202591aed64738672a5e72d5052320054b1e01ce8a1df790f3386e1f3f287c887dbf2e283d5d39ae605f47b0ce79d6be738dd343f85c9
|
data/README.md
CHANGED
|
@@ -84,6 +84,29 @@ It has an exclude pattern for: `%r{^((modules|acceptance|\.?vendor|spec/fixtures
|
|
|
84
84
|
We recommend using the GitHub style guide for markdown files, which includes no trailing whitespace.
|
|
85
85
|
See [GitHub Markdown Style Guide](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax)
|
|
86
86
|
|
|
87
|
+
### `check:misplaced_files`
|
|
88
|
+
|
|
89
|
+
The rake task `check:misplaced_files` checks for misplaced files in the repository.
|
|
90
|
+
|
|
91
|
+
Files are considered misplaced if they don't belong in the directory tree they are under.
|
|
92
|
+
I.e. `functions/`, `manifests/`, and `types/` may only contain `.pp` files, `templates/` may only contain `.erb` and `.epp`, `data/` may only contain `.yml` and `.yaml`, and `lib/` may only contain `.rb`.
|
|
93
|
+
|
|
94
|
+
### `check:utf8`
|
|
95
|
+
|
|
96
|
+
The rake task `check:utf8` checks that all files that will be parsed by Puppet are encoded in valid UTF-8 without a BOM.
|
|
97
|
+
|
|
98
|
+
The task validates all files under `data/`, `functions/`, `lib/`, `manifests/`, `templates/`, and `types/`.
|
|
99
|
+
|
|
100
|
+
## Environment variables
|
|
101
|
+
|
|
102
|
+
### `CODECLIMATE_REPORT_FILE`
|
|
103
|
+
|
|
104
|
+
Setting `CODECLIMATE_REPORT_FILE` to a file path will configure tasks that support it to output CodeClimate-style JSON reports into the given file.
|
|
105
|
+
|
|
106
|
+
The tasks that currently support this feature include `lint` and `rubocop`.
|
|
107
|
+
|
|
108
|
+
Note that if multiple tasks all attempt to output CodeClimate reports in a single rake call, then only the final task will be able store its report.
|
|
109
|
+
|
|
87
110
|
## Fact handling
|
|
88
111
|
|
|
89
112
|
The recommended method is using [rspec-puppet-facts](https://github.com/mcanevet/rspec-puppet-facts) and is set up by default. This means the tests are writting as follows:
|
|
@@ -49,6 +49,50 @@ namespace :check do
|
|
|
49
49
|
exit 1
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
|
+
|
|
53
|
+
desc 'Check that no misplaced files exist in module code/data'
|
|
54
|
+
task :misplaced_files do
|
|
55
|
+
misplaced = []
|
|
56
|
+
misplaced += Dir['data/**/*'].reject { |fn| !File.file?(fn) || fn.end_with?('.yaml') || fn.end_with?('.yml') }
|
|
57
|
+
misplaced += Dir['lib/**/*'].reject { |fn| !File.file?(fn) || fn.end_with?('.rb') }
|
|
58
|
+
misplaced += Dir['{functions,manifests,types}/**/*'].reject { |fn| !File.file?(fn) || fn.end_with?('.pp') }
|
|
59
|
+
misplaced += Dir['templates/**/*'].reject { |fn| !File.file?(fn) || fn.end_with?('.epp') || fn.end_with?('.erb') }
|
|
60
|
+
|
|
61
|
+
if misplaced.any?
|
|
62
|
+
misplaced.each { |filename| puts "#{filename} is misplaced" }
|
|
63
|
+
exit 1
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
desc 'Check that all module code and data are valid UTF-8 without BOM'
|
|
68
|
+
task :utf8 do
|
|
69
|
+
errors = []
|
|
70
|
+
|
|
71
|
+
Dir['{data,functions,lib,manifests,templates,types}/**/*'].each do |filename|
|
|
72
|
+
next unless File.file? filename
|
|
73
|
+
|
|
74
|
+
File.open(filename, 'r:utf-8') do |file|
|
|
75
|
+
data = file.readline
|
|
76
|
+
|
|
77
|
+
if !data.valid_encoding?
|
|
78
|
+
errors << "#{filename} can't be parsed as UTF-8"
|
|
79
|
+
elsif data.bytes[0..2] == [0xef, 0xbb, 0xbf]
|
|
80
|
+
errors << "#{filename} contains BOM"
|
|
81
|
+
elsif data.include? "\x00" # UTF-16 without BOM is technically valid UTF-8, but contains null-bytes
|
|
82
|
+
errors << "#{filename} contains null bytes"
|
|
83
|
+
elsif !file.eof?
|
|
84
|
+
redo
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
rescue StandardError => e
|
|
88
|
+
errors << "#{filename} failed to parse, #{e.class}: #{e}"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
if errors.any?
|
|
92
|
+
errors.each { |error| puts error }
|
|
93
|
+
exit 1
|
|
94
|
+
end
|
|
95
|
+
end
|
|
52
96
|
end
|
|
53
97
|
|
|
54
98
|
desc 'Run static pre release checks'
|
|
@@ -9,4 +9,13 @@ RuboCop::RakeTask.new(:rubocop) do |task|
|
|
|
9
9
|
if ENV['GITHUB_ACTIONS'] == 'true'
|
|
10
10
|
task.formatters << 'github'
|
|
11
11
|
end
|
|
12
|
+
|
|
13
|
+
if ENV['CODECLIMATE_REPORT_FILE']
|
|
14
|
+
# Ensure the default rubocop formatter still runs even when producing codeclimate report
|
|
15
|
+
require 'rubocop'
|
|
16
|
+
task.formatters << (RuboCop::ConfigStore.new.for_pwd.for_all_cops['DefaultFormatter'] || 'progress') if task.formatters.empty?
|
|
17
|
+
|
|
18
|
+
task.requires << File.join(__dir__, '../rubocop_formatters/codeclimate.rb')
|
|
19
|
+
task.options += ['--format', 'CodeclimateFormatter', '--out', ENV['CODECLIMATE_REPORT_FILE']]
|
|
20
|
+
end
|
|
12
21
|
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'digest'
|
|
4
|
+
|
|
5
|
+
# Simple codeclimate-style JSON formatter for RuboCop
|
|
6
|
+
class CodeclimateFormatter < RuboCop::Formatter::BaseFormatter
|
|
7
|
+
include RuboCop::PathUtil
|
|
8
|
+
|
|
9
|
+
SEVERITY_MAP = {
|
|
10
|
+
info: 'info',
|
|
11
|
+
refactor: 'minor',
|
|
12
|
+
convention: 'minor',
|
|
13
|
+
warning: 'major',
|
|
14
|
+
error: 'critical',
|
|
15
|
+
fatal: 'blocker',
|
|
16
|
+
}.freeze
|
|
17
|
+
|
|
18
|
+
attr_reader :output_array
|
|
19
|
+
|
|
20
|
+
def initialize(output, options = {})
|
|
21
|
+
super
|
|
22
|
+
@output_array = []
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def file_finished(file, offenses)
|
|
26
|
+
@output_array += hashes_for_file(file, offenses)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def finished(_inspected_files)
|
|
30
|
+
output.write output_array.to_json
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def hashes_for_file(file, offenses)
|
|
36
|
+
offenses.map do |offense|
|
|
37
|
+
category, name = offense.cop_name.split('/')
|
|
38
|
+
name, category = category, name if name.nil?
|
|
39
|
+
|
|
40
|
+
message = offense.message.dup
|
|
41
|
+
message.delete_prefix! offense.cop_name
|
|
42
|
+
message.delete_prefix! ':'
|
|
43
|
+
message.strip!
|
|
44
|
+
|
|
45
|
+
hash = {
|
|
46
|
+
type: :issue,
|
|
47
|
+
check_name: name,
|
|
48
|
+
description: message,
|
|
49
|
+
categories: [category || 'General'],
|
|
50
|
+
location: hash_for_location(file, offense),
|
|
51
|
+
severity: SEVERITY_MAP[offense.severity.name],
|
|
52
|
+
}
|
|
53
|
+
hash[:fingerprint] = Digest::SHA2.hexdigest([file, offense.cop_name, offense.line, offense.column].to_json)
|
|
54
|
+
hash
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def hash_for_location(file, offense)
|
|
59
|
+
{
|
|
60
|
+
path: smart_path(file),
|
|
61
|
+
positions: {
|
|
62
|
+
begin: {
|
|
63
|
+
line: offense.line,
|
|
64
|
+
column: offense.real_column,
|
|
65
|
+
},
|
|
66
|
+
end: {
|
|
67
|
+
line: offense.last_line,
|
|
68
|
+
column: offense.last_column.zero? ? 1 : offense.last_column,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
end
|
|
73
|
+
end
|
data/rubocop.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This is a shared config for easy consumption in other modules, without having
|
|
2
2
|
# to sync over a large file
|
|
3
|
-
|
|
3
|
+
plugins:
|
|
4
4
|
- rubocop-rspec
|
|
5
5
|
- rubocop-rake
|
|
6
6
|
|
|
@@ -280,7 +280,7 @@ Style/PreferredHashMethods:
|
|
|
280
280
|
Enabled: True
|
|
281
281
|
|
|
282
282
|
Layout/DotPosition:
|
|
283
|
-
EnforcedStyle:
|
|
283
|
+
EnforcedStyle: leading
|
|
284
284
|
|
|
285
285
|
Style/DoubleNegation:
|
|
286
286
|
Enabled: True
|
|
@@ -333,12 +333,14 @@ Style/StringLiterals:
|
|
|
333
333
|
|
|
334
334
|
Style/TrailingCommaInArguments:
|
|
335
335
|
Enabled: True
|
|
336
|
+
EnforcedStyleForMultiline: comma
|
|
336
337
|
|
|
337
338
|
Style/TrailingCommaInArrayLiteral:
|
|
338
|
-
Enabled:
|
|
339
|
+
Enabled: True
|
|
340
|
+
EnforcedStyleForMultiline: consistent_comma
|
|
339
341
|
|
|
340
342
|
Style/TrailingCommaInHashLiteral:
|
|
341
|
-
|
|
343
|
+
EnforcedStyleForMultiline: consistent_comma
|
|
342
344
|
|
|
343
345
|
Style/GlobalVars:
|
|
344
346
|
Enabled: True
|
|
@@ -445,10 +447,13 @@ Style/PercentLiteralDelimiters:
|
|
|
445
447
|
Style/PerlBackrefs:
|
|
446
448
|
Enabled: True
|
|
447
449
|
|
|
448
|
-
Naming/
|
|
450
|
+
Naming/PredicatePrefix:
|
|
449
451
|
Enabled: True
|
|
450
452
|
AllowedMethods: ['is_a?', 'is_to_s']
|
|
451
453
|
|
|
454
|
+
Naming/PredicateMethod:
|
|
455
|
+
Enabled: false
|
|
456
|
+
|
|
452
457
|
Style/RedundantException:
|
|
453
458
|
Enabled: True
|
|
454
459
|
|
|
@@ -496,6 +501,9 @@ Style/Encoding:
|
|
|
496
501
|
Style/BlockDelimiters:
|
|
497
502
|
Enabled: True
|
|
498
503
|
|
|
504
|
+
Style/TernaryParentheses:
|
|
505
|
+
EnforcedStyle: require_parentheses_when_complex
|
|
506
|
+
|
|
499
507
|
Layout/MultilineBlockLayout:
|
|
500
508
|
Enabled: True
|
|
501
509
|
|
|
@@ -557,9 +565,13 @@ Style/FormatStringToken:
|
|
|
557
565
|
|
|
558
566
|
# This is useful, but sometimes a little too picky about where unit tests files
|
|
559
567
|
# are located.
|
|
560
|
-
RSpec/FilePath
|
|
568
|
+
# old cop: RSpec/FilePath
|
|
569
|
+
RSpec/SpecFilePathFormat:
|
|
561
570
|
Enabled: false
|
|
562
571
|
|
|
572
|
+
RSpec/SpecFilePathSuffix:
|
|
573
|
+
Enabled: true
|
|
574
|
+
|
|
563
575
|
# Leaving these enabled creates too much busy work
|
|
564
576
|
RSpec/ContextWording:
|
|
565
577
|
Enabled: false
|
|
@@ -662,8 +674,6 @@ RSpec/IdenticalEqualityAssertion: # new in 2.4
|
|
|
662
674
|
Enabled: true
|
|
663
675
|
RSpec/SubjectDeclaration: # new in 2.5
|
|
664
676
|
Enabled: true
|
|
665
|
-
RSpec/Rails/AvoidSetupHook: # new in 2.4
|
|
666
|
-
Enabled: true
|
|
667
677
|
RSpec/ImplicitSubject:
|
|
668
678
|
Enabled: false
|
|
669
679
|
# new configurations since rubocop 1.50.0
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: voxpupuli-test
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 14.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vox Pupuli
|
|
@@ -78,7 +78,7 @@ dependencies:
|
|
|
78
78
|
version: '5.0'
|
|
79
79
|
- - "<"
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
81
|
+
version: '8'
|
|
82
82
|
type: :runtime
|
|
83
83
|
prerelease: false
|
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -88,7 +88,7 @@ dependencies:
|
|
|
88
88
|
version: '5.0'
|
|
89
89
|
- - "<"
|
|
90
90
|
- !ruby/object:Gem::Version
|
|
91
|
-
version: '
|
|
91
|
+
version: '8'
|
|
92
92
|
- !ruby/object:Gem::Dependency
|
|
93
93
|
name: parallel_tests
|
|
94
94
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -207,58 +207,64 @@ dependencies:
|
|
|
207
207
|
name: syslog
|
|
208
208
|
requirement: !ruby/object:Gem::Requirement
|
|
209
209
|
requirements:
|
|
210
|
-
- - "
|
|
210
|
+
- - ">="
|
|
211
211
|
- !ruby/object:Gem::Version
|
|
212
|
-
version: 0.3
|
|
212
|
+
version: '0.3'
|
|
213
|
+
- - "<"
|
|
214
|
+
- !ruby/object:Gem::Version
|
|
215
|
+
version: '0.5'
|
|
213
216
|
type: :runtime
|
|
214
217
|
prerelease: false
|
|
215
218
|
version_requirements: !ruby/object:Gem::Requirement
|
|
216
219
|
requirements:
|
|
217
|
-
- - "
|
|
220
|
+
- - ">="
|
|
221
|
+
- !ruby/object:Gem::Version
|
|
222
|
+
version: '0.3'
|
|
223
|
+
- - "<"
|
|
218
224
|
- !ruby/object:Gem::Version
|
|
219
|
-
version: 0.
|
|
225
|
+
version: '0.5'
|
|
220
226
|
- !ruby/object:Gem::Dependency
|
|
221
227
|
name: rubocop
|
|
222
228
|
requirement: !ruby/object:Gem::Requirement
|
|
223
229
|
requirements:
|
|
224
230
|
- - "~>"
|
|
225
231
|
- !ruby/object:Gem::Version
|
|
226
|
-
version: 1.
|
|
232
|
+
version: 1.85.1
|
|
227
233
|
type: :runtime
|
|
228
234
|
prerelease: false
|
|
229
235
|
version_requirements: !ruby/object:Gem::Requirement
|
|
230
236
|
requirements:
|
|
231
237
|
- - "~>"
|
|
232
238
|
- !ruby/object:Gem::Version
|
|
233
|
-
version: 1.
|
|
239
|
+
version: 1.85.1
|
|
234
240
|
- !ruby/object:Gem::Dependency
|
|
235
241
|
name: rubocop-rake
|
|
236
242
|
requirement: !ruby/object:Gem::Requirement
|
|
237
243
|
requirements:
|
|
238
244
|
- - "~>"
|
|
239
245
|
- !ruby/object:Gem::Version
|
|
240
|
-
version: 0.
|
|
246
|
+
version: 0.7.1
|
|
241
247
|
type: :runtime
|
|
242
248
|
prerelease: false
|
|
243
249
|
version_requirements: !ruby/object:Gem::Requirement
|
|
244
250
|
requirements:
|
|
245
251
|
- - "~>"
|
|
246
252
|
- !ruby/object:Gem::Version
|
|
247
|
-
version: 0.
|
|
253
|
+
version: 0.7.1
|
|
248
254
|
- !ruby/object:Gem::Dependency
|
|
249
255
|
name: rubocop-rspec
|
|
250
256
|
requirement: !ruby/object:Gem::Requirement
|
|
251
257
|
requirements:
|
|
252
258
|
- - "~>"
|
|
253
259
|
- !ruby/object:Gem::Version
|
|
254
|
-
version:
|
|
260
|
+
version: 3.9.0
|
|
255
261
|
type: :runtime
|
|
256
262
|
prerelease: false
|
|
257
263
|
version_requirements: !ruby/object:Gem::Requirement
|
|
258
264
|
requirements:
|
|
259
265
|
- - "~>"
|
|
260
266
|
- !ruby/object:Gem::Version
|
|
261
|
-
version:
|
|
267
|
+
version: 3.9.0
|
|
262
268
|
- !ruby/object:Gem::Dependency
|
|
263
269
|
name: voxpupuli-puppet-lint-plugins
|
|
264
270
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -311,9 +317,10 @@ files:
|
|
|
311
317
|
- lib/voxpupuli/test/rake/rubocop.rb
|
|
312
318
|
- lib/voxpupuli/test/rake/spec.rb
|
|
313
319
|
- lib/voxpupuli/test/rake/validate.rb
|
|
320
|
+
- lib/voxpupuli/test/rubocop_formatters/codeclimate.rb
|
|
314
321
|
- lib/voxpupuli/test/spec_helper.rb
|
|
315
322
|
- rubocop.yml
|
|
316
|
-
homepage:
|
|
323
|
+
homepage: https://github.com/voxpupuli/voxpupuli-test
|
|
317
324
|
licenses:
|
|
318
325
|
- Apache-2.0
|
|
319
326
|
metadata: {}
|
|
@@ -331,7 +338,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
331
338
|
- !ruby/object:Gem::Version
|
|
332
339
|
version: '0'
|
|
333
340
|
requirements: []
|
|
334
|
-
rubygems_version:
|
|
341
|
+
rubygems_version: 4.0.3
|
|
335
342
|
specification_version: 4
|
|
336
343
|
summary: Helpers for testing Vox Pupuli modules
|
|
337
344
|
test_files: []
|