metadata-json-lint 2.2.0 → 3.0.1
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 +8 -0
- data/.github/workflows/release.yml +32 -0
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +7 -1
- data/CHANGELOG.md +55 -4
- data/Gemfile +8 -1
- data/HISTORY.md +107 -0
- data/LICENSE +174 -9
- data/README.md +65 -1
- data/Rakefile +26 -1
- data/bin/metadata-json-lint +1 -1
- data/lib/metadata-json-lint/schema.rb +2 -3
- data/lib/metadata_json_lint.rb +14 -0
- data/metadata-json-lint.gemspec +6 -13
- data/spec/spec_helper.rb +24 -0
- data/tests/bad_license/Rakefile +1 -1
- data/tests/broken/Rakefile +1 -1
- data/tests/duplicate-dep/Rakefile +1 -1
- data/tests/duplicate-requirement/Rakefile +2 -0
- data/tests/duplicate-requirement/expected +1 -0
- data/tests/duplicate-requirement/metadata.json +87 -0
- data/tests/json_format/Rakefile +1 -1
- data/tests/long_summary/Rakefile +1 -1
- data/tests/missing_version_requirement/Rakefile +1 -1
- data/tests/mixed_version_syntax/Rakefile +1 -1
- data/tests/multiple_problems/Rakefile +1 -1
- data/tests/no_dependencies/Rakefile +1 -1
- data/tests/no_pe/Rakefile +1 -1
- data/tests/no_version_range/Rakefile +1 -1
- data/tests/non_array_requirements/Rakefile +1 -1
- data/tests/noname/Rakefile +1 -1
- data/tests/open_ended_dependency/Rakefile +1 -1
- data/tests/perfect/Rakefile +1 -1
- data/tests/proprietary/Rakefile +1 -1
- data/tests/rake_chaining/Rakefile +1 -1
- data/tests/rake_global_options/Rakefile +1 -1
- data/tests/rake_multiple_json_options/Rakefile +1 -1
- data/tests/requirements_eol_version/Rakefile +1 -1
- data/tests/tags_no_array/Rakefile +1 -1
- data/tests/tags_with_array/Rakefile +1 -1
- data/tests/test.sh +3 -0
- data/tests/types/Rakefile +1 -1
- metadata +33 -31
- data/.travis.yml +0 -25
data/README.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# metadata-json-lint
|
2
2
|
|
3
|
+
[![License](https://img.shields.io/github/license/voxpupuli/metadata-json-lint.svg)](https://github.com/voxpupuli/metadata-json-lint/blob/master/LICENSE)
|
4
|
+
[![Test](https://github.com/voxpupuli/metadata-json-lint/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/metadata-json-lint/actions/workflows/test.yml)
|
5
|
+
[![codecov](https://codecov.io/gh/voxpupuli/metadata-json-lint/branch/master/graph/badge.svg)](https://codecov.io/gh/voxpupuli/metadata-json-lint)
|
6
|
+
[![Release](https://github.com/voxpupuli/metadata-json-lint/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/metadata-json-lint/actions/workflows/release.yml)
|
7
|
+
[![RubyGem Version](https://img.shields.io/gem/v/metadata-json-lint.svg)](https://rubygems.org/gems/metadata-json-lint)
|
8
|
+
[![RubyGem Downloads](https://img.shields.io/gem/dt/metadata-json-lint.svg)](https://rubygems.org/gems/metadata-json-lint)
|
9
|
+
|
3
10
|
The metadata-json-lint tool validates and lints `metadata.json` files in Puppet modules against style guidelines from the [Puppet Forge module metadata](https://docs.puppet.com/puppet/latest/modules_publishing.html#write-a-metadatajson-file) recommendations.
|
4
11
|
|
5
12
|
## Compatibility
|
@@ -41,7 +48,7 @@ rake metadata_lint
|
|
41
48
|
To set options for the Rake task, include them when you define the task:
|
42
49
|
|
43
50
|
```ruby
|
44
|
-
require '
|
51
|
+
require 'metadata_json_lint'
|
45
52
|
task :metadata_lint do
|
46
53
|
MetadataJsonLint.parse('metadata.json') do |options|
|
47
54
|
options.strict_license = false
|
@@ -66,3 +73,60 @@ MetadataJsonLint.options.strict_license = false
|
|
66
73
|
## Contributors
|
67
74
|
|
68
75
|
A big thank you to the [contributors](https://github.com/voxpupuli/metadata-json-lint/graphs/contributors).
|
76
|
+
|
77
|
+
## Making a new release
|
78
|
+
|
79
|
+
How to make a new release?
|
80
|
+
|
81
|
+
* update the gemspec file with the desired version
|
82
|
+
|
83
|
+
```console
|
84
|
+
$ git diff
|
85
|
+
diff --git a/metadata-json-lint.gemspec b/metadata-json-lint.gemspec
|
86
|
+
index c86668e..6a3ad38 100644
|
87
|
+
--- a/metadata-json-lint.gemspec
|
88
|
+
+++ b/metadata-json-lint.gemspec
|
89
|
+
@@ -2,7 +2,7 @@ require 'date'
|
90
|
+
|
91
|
+
Gem::Specification.new do |s|
|
92
|
+
s.name = 'metadata-json-lint'
|
93
|
+
- s.version = '2.4.0'
|
94
|
+
+ s.version = '2.5.0'
|
95
|
+
s.date = Date.today.to_s
|
96
|
+
s.summary = 'metadata-json-lint /path/to/metadata.json'
|
97
|
+
s.description = 'Utility to verify Puppet metadata.json files'
|
98
|
+
```
|
99
|
+
|
100
|
+
* export a GitHub access token as environment variable:
|
101
|
+
|
102
|
+
```console
|
103
|
+
export CHANGELOG_GITHUB_TOKEN=*token*
|
104
|
+
```
|
105
|
+
|
106
|
+
* Install deps and generate the changelog
|
107
|
+
|
108
|
+
```console
|
109
|
+
$ bundle install --path .vendor/ --jobs=$(nproc) --with release
|
110
|
+
$ bundle exec rake changelog
|
111
|
+
Found 25 tags
|
112
|
+
Fetching tags dates: 25/25
|
113
|
+
Sorting tags...
|
114
|
+
Received issues: 103
|
115
|
+
Pull Request count: 77
|
116
|
+
Filtered pull requests: 72
|
117
|
+
Filtered issues: 26
|
118
|
+
Fetching events for issues and PR: 98
|
119
|
+
Fetching closed dates for issues: 98/98
|
120
|
+
Fetching SHAs for tags: 25
|
121
|
+
Associating PRs with tags: 72/72
|
122
|
+
Generating entry...
|
123
|
+
Done!
|
124
|
+
Generated log placed in ~/metadata-json-lint/CHANGELOG.md
|
125
|
+
```
|
126
|
+
|
127
|
+
* Check the diff for `CHANGELOG.md`. Does it contain a breaking change but the
|
128
|
+
new version is only a minor bump? Does the new release only contains bug fixes?
|
129
|
+
Adjust the version properly while honouring semantic versioning. If required,
|
130
|
+
regenerate the `CHANGELOG.md`. Afterwards submit it as a PR.
|
131
|
+
|
132
|
+
* If it gets approved, merge the PR, create a git tag on that and push it.
|
data/Rakefile
CHANGED
@@ -2,7 +2,18 @@ desc 'Run all tests'
|
|
2
2
|
task :test => %i[rubocop spec test:acceptance]
|
3
3
|
|
4
4
|
require 'rubocop/rake_task'
|
5
|
-
RuboCop::RakeTask.new
|
5
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
6
|
+
# These make the rubocop experience maybe slightly less terrible
|
7
|
+
task.options = ['-D', '-S', '-E']
|
8
|
+
|
9
|
+
# Use Rubocop's Github Actions formatter if possible
|
10
|
+
if ENV['GITHUB_ACTIONS'] == 'true'
|
11
|
+
rubocop_spec = Gem::Specification.find_by_name('rubocop')
|
12
|
+
if Gem::Version.new(rubocop_spec.version) >= Gem::Version.new('1.2')
|
13
|
+
task.formatters << 'github'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
6
17
|
|
7
18
|
namespace :test do
|
8
19
|
desc 'Acceptance suite under test/ which runs metadata-json-lint against sample files with expected output'
|
@@ -13,3 +24,17 @@ end
|
|
13
24
|
|
14
25
|
require 'rspec/core/rake_task'
|
15
26
|
RSpec::Core::RakeTask.new(:spec)
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rubygems'
|
30
|
+
require 'github_changelog_generator/task'
|
31
|
+
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
32
|
+
else
|
33
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
34
|
+
config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog]
|
35
|
+
config.user = 'voxpupuli'
|
36
|
+
config.project = 'metadata-json-lint'
|
37
|
+
gem_version = Gem::Specification.load("#{config.project}.gemspec").version
|
38
|
+
config.future_release = gem_version
|
39
|
+
end
|
40
|
+
end
|
data/bin/metadata-json-lint
CHANGED
@@ -9,7 +9,6 @@ module MetadataJsonLint
|
|
9
9
|
class Schema
|
10
10
|
# Based on https://docs.puppet.com/puppet/latest/modules_metadata.html
|
11
11
|
#
|
12
|
-
# rubocop:disable Style/TrailingCommaInLiteral # easier to modify individual lines
|
13
12
|
def schema
|
14
13
|
{
|
15
14
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
@@ -101,7 +100,7 @@ module MetadataJsonLint
|
|
101
100
|
'tags' => {
|
102
101
|
'type' => 'array',
|
103
102
|
'items' => {
|
104
|
-
'type' => 'string'
|
103
|
+
'type' => 'string',
|
105
104
|
},
|
106
105
|
},
|
107
106
|
'version' => {
|
@@ -121,7 +120,6 @@ module MetadataJsonLint
|
|
121
120
|
],
|
122
121
|
}
|
123
122
|
end
|
124
|
-
# rubocop:enable Style/TrailingCommaInLiteral
|
125
123
|
|
126
124
|
def validate(data, options = {})
|
127
125
|
JSON::Validator.register_format_validator('semver', method(:semver_validator))
|
@@ -166,3 +164,4 @@ module MetadataJsonLint
|
|
166
164
|
end
|
167
165
|
end
|
168
166
|
end
|
167
|
+
# rubocop:enable Metrics/ClassLength
|
data/lib/metadata_json_lint.rb
CHANGED
@@ -137,6 +137,18 @@ module MetadataJsonLint
|
|
137
137
|
end
|
138
138
|
module_function :parse
|
139
139
|
|
140
|
+
def validate_requirements_unique(requirements)
|
141
|
+
names = requirements.map { |x| x['name'] }
|
142
|
+
counts = Hash.new(0)
|
143
|
+
|
144
|
+
names.each { |name| counts[name.downcase] += 1 }
|
145
|
+
|
146
|
+
counts.each do |k, v|
|
147
|
+
error :requirements, "Duplicate entries in the 'requirements' list with the name '#{k}'" if v > 1
|
148
|
+
end
|
149
|
+
end
|
150
|
+
module_function :validate_requirements_unique
|
151
|
+
|
140
152
|
def validate_requirements!(requirements)
|
141
153
|
return unless requirements.is_a?(Array)
|
142
154
|
|
@@ -154,6 +166,8 @@ module MetadataJsonLint
|
|
154
166
|
|
155
167
|
validate_puppet_ver!(puppet_req) unless puppet_req.instance_variable_get('@requirement').nil?
|
156
168
|
end
|
169
|
+
|
170
|
+
validate_requirements_unique(requirements)
|
157
171
|
end
|
158
172
|
module_function :validate_requirements!
|
159
173
|
|
data/metadata-json-lint.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'date'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'metadata-json-lint'
|
5
|
-
s.version = '
|
5
|
+
s.version = '3.0.1'
|
6
6
|
s.date = Date.today.to_s
|
7
7
|
s.summary = 'metadata-json-lint /path/to/metadata.json'
|
8
8
|
s.description = 'Utility to verify Puppet metadata.json files'
|
@@ -13,22 +13,15 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
14
|
s.test_files = s.files.grep(%r{^(tests|spec)/})
|
15
15
|
|
16
|
-
s.homepage = '
|
16
|
+
s.homepage = 'https://github.com/voxpupuli/metadata-json-lint'
|
17
17
|
s.license = 'Apache-2.0'
|
18
18
|
|
19
|
-
s.required_ruby_version = '>= 2.
|
20
|
-
s.add_runtime_dependency 'spdx-licenses', '~> 1.0'
|
19
|
+
s.required_ruby_version = '>= 2.1.0'
|
21
20
|
s.add_runtime_dependency 'json-schema', '~> 2.8'
|
21
|
+
s.add_runtime_dependency 'spdx-licenses', '~> 1.0'
|
22
22
|
s.add_development_dependency 'pry'
|
23
23
|
s.add_development_dependency 'rake'
|
24
|
-
s.add_development_dependency 'semantic_puppet'
|
25
24
|
s.add_development_dependency 'rspec'
|
26
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
27
|
-
s.
|
28
|
-
----------------------------------------------------------
|
29
|
-
For the most accurate results, the semantic_puppet
|
30
|
-
gem should be included within your Gemfile if you
|
31
|
-
use Puppet <= 4.8.x
|
32
|
-
----------------------------------------------------------
|
33
|
-
'.gsub(/^ /, '')
|
25
|
+
s.add_development_dependency 'rubocop', '~> 0.57.2'
|
26
|
+
s.add_development_dependency 'semantic_puppet'
|
34
27
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
begin
|
2
|
+
require 'simplecov'
|
3
|
+
require 'simplecov-console'
|
4
|
+
require 'codecov'
|
5
|
+
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
6
|
+
else
|
7
|
+
SimpleCov.start do
|
8
|
+
track_files 'lib/**/*.rb'
|
9
|
+
|
10
|
+
add_filter '/spec'
|
11
|
+
|
12
|
+
enable_coverage :branch
|
13
|
+
|
14
|
+
# do not track vendored files
|
15
|
+
add_filter '/vendor'
|
16
|
+
add_filter '/.vendor'
|
17
|
+
end
|
18
|
+
|
19
|
+
SimpleCov.formatters = [
|
20
|
+
SimpleCov::Formatter::Console,
|
21
|
+
SimpleCov::Formatter::Codecov
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
1
25
|
require 'metadata_json_lint'
|
2
26
|
|
3
27
|
# This file was generated by the `rspec --init` command
|
data/tests/bad_license/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
data/tests/broken/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
@@ -0,0 +1 @@
|
|
1
|
+
Duplicate entries in the 'requirements' list with the name 'puppet'
|
@@ -0,0 +1,87 @@
|
|
1
|
+
{
|
2
|
+
"name": "puppetlabs-postgresql",
|
3
|
+
"version": "3.4.1",
|
4
|
+
"author": "Inkling/Puppet Labs",
|
5
|
+
"summary": "PostgreSQL defined resource types",
|
6
|
+
"license": "Apache-2.0",
|
7
|
+
"source": "git://github.com/puppetlabs/puppet-postgresql.git",
|
8
|
+
"project_page": "https://github.com/puppetlabs/puppet-postgresql",
|
9
|
+
"issues_url": "https://github.com/puppetlabs/puppet-postgresql/issues",
|
10
|
+
"operatingsystem_support": [
|
11
|
+
{
|
12
|
+
"operatingsystem": "RedHat",
|
13
|
+
"operatingsystemrelease": [
|
14
|
+
"5",
|
15
|
+
"6",
|
16
|
+
"7"
|
17
|
+
]
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"operatingsystem": "CentOS",
|
21
|
+
"operatingsystemrelease": [
|
22
|
+
"5",
|
23
|
+
"6",
|
24
|
+
"7"
|
25
|
+
]
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"operatingsystem": "OracleLinux",
|
29
|
+
"operatingsystemrelease": [
|
30
|
+
"5",
|
31
|
+
"6",
|
32
|
+
"7"
|
33
|
+
]
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"operatingsystem": "Scientific",
|
37
|
+
"operatingsystemrelease": [
|
38
|
+
"5",
|
39
|
+
"6",
|
40
|
+
"7"
|
41
|
+
]
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"operatingsystem": "Debian",
|
45
|
+
"operatingsystemrelease": [
|
46
|
+
"6",
|
47
|
+
"7"
|
48
|
+
]
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"operatingsystem": "Ubuntu",
|
52
|
+
"operatingsystemrelease": [
|
53
|
+
"10.04",
|
54
|
+
"12.04",
|
55
|
+
"14.04"
|
56
|
+
]
|
57
|
+
}
|
58
|
+
],
|
59
|
+
"requirements": [
|
60
|
+
{
|
61
|
+
"name": "puppet",
|
62
|
+
"version_requirement": "5.5.1"
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"name": "puppet",
|
66
|
+
"version_requirement": "6.11.0"
|
67
|
+
}
|
68
|
+
],
|
69
|
+
"dependencies": [
|
70
|
+
{
|
71
|
+
"name": "puppetlabs/stdlib",
|
72
|
+
"version_requirement": "4.x"
|
73
|
+
},
|
74
|
+
{
|
75
|
+
"name": "puppetlabs/firewall",
|
76
|
+
"version_requirement": ">= 0.0.4"
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"name": "puppetlabs/apt",
|
80
|
+
"version_requirement": ">=1.1.0 <2.0.0"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"name": "puppetlabs/concat",
|
84
|
+
"version_requirement": ">= 1.1.0 <2.0.0"
|
85
|
+
}
|
86
|
+
]
|
87
|
+
}
|
data/tests/json_format/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
data/tests/long_summary/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
data/tests/no_pe/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
data/tests/noname/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
data/tests/perfect/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|
data/tests/proprietary/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
2
2
|
require 'metadata-json-lint/rake_task'
|