codeowner_validator 0.1.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/cd.yml +1 -1
- data/.github/workflows/ci.yml +10 -2
- data/.rubocop.yml +19 -27
- data/.ruby-version +1 -1
- data/CHANGELOG.md +8 -2
- data/Gemfile +0 -4
- data/README.md +4 -2
- data/codeowner_validator.gemspec +5 -2
- data/dangerfile.js +97 -0
- data/lib/codeowner_validator/code_owners.rb +2 -4
- data/lib/codeowner_validator/group/comment/error.rb +1 -1
- data/lib/codeowner_validator/group/comment/info.rb +1 -1
- data/lib/codeowner_validator/group/comment/verbose.rb +1 -1
- data/lib/codeowner_validator/group/comment/warn.rb +1 -1
- data/lib/codeowner_validator/helpers/utility_helper.rb +12 -7
- data/lib/codeowner_validator/lists/whitelist.rb +2 -4
- data/lib/codeowner_validator/tasks/missing_assignment_checker.rb +1 -0
- data/lib/codeowner_validator/tasks/syntax_checker.rb +1 -0
- data/lib/codeowner_validator/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d35f65763b9fadd44bcb19531f9562d50c50e4f2e2c4c0a5f3a732390b6cb994
|
4
|
+
data.tar.gz: c92f01df71595708c7b2545f4cd9062472ccd3e322eaee80ad5a7610c6de34fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e0ea092271b5c2bf7f2b5d2260dec6c0ab562332323ac21f5bd2787915228cb0e8b133ad8eec34e8bce91106cd3dfab74b2309b3a346557b506fe1dcf6241f9
|
7
|
+
data.tar.gz: c48f25546f3e3b369c1f4dbace312c9d08a3a5fb33b0fa01bb6a4a388b6c8802054a0bc01eab9e1fb6d94eaa75fbcca1c7d78f3cbaba0c84950401f2d71f4744
|
data/.github/workflows/cd.yml
CHANGED
data/.github/workflows/ci.yml
CHANGED
@@ -4,11 +4,12 @@ name: CI
|
|
4
4
|
|
5
5
|
on:
|
6
6
|
push:
|
7
|
-
branches: ['
|
7
|
+
branches: ['main']
|
8
8
|
pull_request:
|
9
9
|
branches: ['main']
|
10
10
|
schedule:
|
11
11
|
- cron: '0 1 * * SUN'
|
12
|
+
workflow_dispatch:
|
12
13
|
|
13
14
|
jobs:
|
14
15
|
tests:
|
@@ -17,9 +18,9 @@ jobs:
|
|
17
18
|
fail-fast: false
|
18
19
|
matrix:
|
19
20
|
ruby:
|
20
|
-
- 2.6
|
21
21
|
- 2.7
|
22
22
|
- 3.0
|
23
|
+
- 3.2
|
23
24
|
name: Ruby-${{matrix.ruby}}
|
24
25
|
continue-on-error: ${{matrix.ruby == 'head'}}
|
25
26
|
steps:
|
@@ -32,6 +33,13 @@ jobs:
|
|
32
33
|
ruby-version: ${{ matrix.ruby }}
|
33
34
|
- name: Install dependencies
|
34
35
|
run: bundle install --jobs 4 --retry 3
|
36
|
+
- if: github.event_name == 'pull_request'
|
37
|
+
name: Danger
|
38
|
+
uses: danger/danger-js@9.1.8
|
39
|
+
env:
|
40
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
41
|
+
# https://github.com/danger/danger-js/issues/557#issuecomment-664851950
|
42
|
+
DANGER_DISABLE_TRANSPILATION: true
|
35
43
|
- name: Run tests
|
36
44
|
run: bundle exec rspec
|
37
45
|
- name: Run Rubocop
|
data/.rubocop.yml
CHANGED
@@ -1,18 +1,14 @@
|
|
1
1
|
require:
|
2
2
|
- rubocop-performance
|
3
|
-
- rubocop-rspec
|
4
|
-
- rubocop-rake
|
5
3
|
|
6
4
|
AllCops:
|
7
|
-
TargetRubyVersion: 2
|
5
|
+
TargetRubyVersion: 3.2
|
8
6
|
DisabledByDefault: true
|
9
7
|
Exclude:
|
10
|
-
- 'bin/{bundle,bundle-audit,bundler-audit,rake,rspec,rubocop}'
|
8
|
+
- 'bin/{bundle,bundle-audit,bundler-audit,rackup,rake,rspec,rubocop}'
|
11
9
|
- 'target/**/*'
|
12
10
|
- 'vendor/**/*'
|
13
|
-
|
14
|
-
- 'pkg/**/*'
|
15
|
-
- 'tmp/**/*'
|
11
|
+
SuggestExtensions: false
|
16
12
|
|
17
13
|
# Bundler Cop Configuration
|
18
14
|
# https://docs.rubocop.org/en/stable/cops_bundler/
|
@@ -240,7 +236,7 @@ Lint/AssignmentInCondition:
|
|
240
236
|
Enabled: true
|
241
237
|
Lint/BigDecimalNew:
|
242
238
|
Enabled: true
|
243
|
-
#
|
239
|
+
# Supersedes Lint/UselessComparison in rubocop 0.89.
|
244
240
|
Lint/BinaryOperatorWithIdenticalOperands:
|
245
241
|
Enabled: true
|
246
242
|
Lint/BooleanSymbol:
|
@@ -301,7 +297,7 @@ Lint/MissingCopEnableDirective:
|
|
301
297
|
Enabled: true
|
302
298
|
Lint/MissingSuper:
|
303
299
|
# Disabled. This cop is well-meaning, but doesn't provide exemption of cases where invocation of
|
304
|
-
# super is not possible.
|
300
|
+
# super is not possible. Supersedes Style/MethodMissingSuper in rubocop 0.89.
|
305
301
|
Enabled: false
|
306
302
|
Lint/MultipleComparison:
|
307
303
|
Enabled: true
|
@@ -387,8 +383,6 @@ Lint/UselessAccessModifier:
|
|
387
383
|
Enabled: true
|
388
384
|
Lint/UselessAssignment:
|
389
385
|
Enabled: true
|
390
|
-
Lint/UselessElseWithoutRescue:
|
391
|
-
Enabled: true
|
392
386
|
Lint/UselessSetterCall:
|
393
387
|
Enabled: true
|
394
388
|
Lint/Void:
|
@@ -451,7 +445,7 @@ Naming/MemoizedInstanceVariableName:
|
|
451
445
|
Enabled: true
|
452
446
|
Naming/MethodName:
|
453
447
|
Enabled: true
|
454
|
-
|
448
|
+
AllowedPatterns:
|
455
449
|
- 'do_GET'
|
456
450
|
- 'do_POST'
|
457
451
|
- 'do_PUT'
|
@@ -467,9 +461,10 @@ Naming/RescuedExceptionsVariableName:
|
|
467
461
|
Enabled: false
|
468
462
|
Naming/VariableName:
|
469
463
|
Enabled: true
|
464
|
+
# Disabled. It's acceptable (and in heavy usage already) to name things like "data_model_1"
|
465
|
+
# instead of forcing "data_model1".
|
470
466
|
Naming/VariableNumber:
|
471
|
-
Enabled:
|
472
|
-
|
467
|
+
Enabled: false
|
473
468
|
|
474
469
|
# Performance Cop Configuration
|
475
470
|
# https://rubocop-performance.readthedocs.io/en/stable/cops_performance/
|
@@ -604,15 +599,11 @@ Style/DefWithParentheses:
|
|
604
599
|
Style/Dir:
|
605
600
|
Enabled: true
|
606
601
|
Style/Documentation:
|
607
|
-
|
608
|
-
|
609
|
-
- test/**/*
|
610
|
-
- spec/**/*
|
602
|
+
# Disabled. Documentation is required, but enforcement here does not seem to work.
|
603
|
+
Enabled: false
|
611
604
|
Style/DocumentationMethod:
|
612
|
-
|
613
|
-
|
614
|
-
- test/**/*
|
615
|
-
- spec/**/*
|
605
|
+
# Disabled. Documentation is required, but enforcement here does not seem to work.
|
606
|
+
Enabled: false
|
616
607
|
Style/DoubleCopDisableDirective:
|
617
608
|
Enabled: true
|
618
609
|
Style/DoubleNegation:
|
@@ -658,7 +649,7 @@ Style/GlobalVars:
|
|
658
649
|
Style/GuardClause:
|
659
650
|
Enabled: true
|
660
651
|
Style/HashSyntax:
|
661
|
-
Enabled:
|
652
|
+
Enabled: false
|
662
653
|
Style/IdenticalConditionalBranches:
|
663
654
|
Enabled: true
|
664
655
|
Style/IfInsideElse:
|
@@ -703,7 +694,7 @@ Style/MethodCallWithoutArgsParentheses:
|
|
703
694
|
Enabled: true
|
704
695
|
Style/MethodCalledOnDoEndBlock:
|
705
696
|
# Disabled. It is acceptable to call a method at the end of a do/end block. In particular, this is
|
706
|
-
#
|
697
|
+
# occasionally needed in RSpec code.
|
707
698
|
Enabled: false
|
708
699
|
Style/MethodDefParentheses:
|
709
700
|
Enabled: true
|
@@ -803,7 +794,8 @@ Style/RedundantCondition:
|
|
803
794
|
Style/RedundantConditional:
|
804
795
|
Enabled: true
|
805
796
|
Style/RedundantException:
|
806
|
-
|
797
|
+
# Disabled. With ImplicitRuntimeError enabled, disable subsequent warning if consumer wishes to continue using RuntimeError
|
798
|
+
Enabled: false
|
807
799
|
Style/RedundantFreeze:
|
808
800
|
Enabled: true
|
809
801
|
Style/RedundantInterpolation:
|
@@ -855,8 +847,8 @@ Style/SpecialGlobalVars:
|
|
855
847
|
Style/StabbyLambdaParentheses:
|
856
848
|
Enabled: true
|
857
849
|
Style/StderrPuts:
|
858
|
-
# Disabled. This cop functionally equates use of STDERR with optional warnings. This may be true
|
859
|
-
#
|
850
|
+
# Disabled. This cop functionally equates use of STDERR with optional warnings. This may be true
|
851
|
+
# in some use cases, but there are times when using STDERR in CLIs is not an optional warning.
|
860
852
|
Enabled: false
|
861
853
|
Style/StringHashKeys:
|
862
854
|
# Disabled. There are many use cases where using Strings for Hash keys is required.
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2
|
1
|
+
ruby-3.2
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# 0.1.0
|
2
|
-
Initial release
|
2
|
+
- Initial release
|
3
3
|
|
4
4
|
# 0.1.1
|
5
|
-
Fix homepage reference
|
5
|
+
- Fix homepage reference
|
6
|
+
|
7
|
+
# 0.2.0
|
8
|
+
- Update version of thor to have a broader availability ([#6](https://github.com/cerner/codeowner_validator/pull/6))
|
9
|
+
|
10
|
+
# 0.3.0
|
11
|
+
- Update to support ruby 3.2 ([#9](https://github.com/cerner/codeowner_validator/pull/9))
|
data/Gemfile
CHANGED
@@ -14,7 +14,3 @@ gem 'rubocop-performance', '~> 1.8', require: false
|
|
14
14
|
gem 'rubocop-rake', '~> 0.5', require: false
|
15
15
|
gem 'rubocop-rspec', '~> 2.1', require: false
|
16
16
|
gem 'simplecov', '~> 0.19', require: false
|
17
|
-
|
18
|
-
# debugging
|
19
|
-
gem 'debase', '~> 0.2.5.beta2'
|
20
|
-
gem 'ruby-debug-ide'
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# CODEOWNER Validator
|
2
2
|
|
3
|
-
![
|
3
|
+
[![Cerner OSS](https://badgen.net/badge/Cerner/OSS/blue)](http://engineering.cerner.com/2014/01/cerner-and-open-source/)
|
4
|
+
[![License](https://badgen.net/github/license/cerner/codeowner_validator)](https://github.com/cerner/codeowner_validator/blob/main/LICENSE)
|
5
|
+
[![Build Status](https://github.com/cerner/codeowner_validator/actions/workflows/ci.yml/badge.svg)](https://github.com/cerner/codeowner_validator/actions/workflows/ci.yml)
|
4
6
|
|
5
7
|
This library provides interactions with the GitHub CODEOWNERS file for performing validation tasks that include
|
6
8
|
* ownership checks
|
@@ -157,4 +159,4 @@ Everyone interacting in the CodeownerValidator project’s codebases, issue trac
|
|
157
159
|
Shout-out to @jonatas and his project [codeowners-checker](https://github.com/toptal/codeowners-checker). The checker provided easy reusage which greatly reduced the
|
158
160
|
dependencies within this project.
|
159
161
|
|
160
|
-
[pathspec-ruby]: https://github.com/highb/pathspec-ruby
|
162
|
+
[pathspec-ruby]: https://github.com/highb/pathspec-ruby
|
data/codeowner_validator.gemspec
CHANGED
@@ -27,10 +27,13 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
|
-
|
30
|
+
# rubocop:disable Gemspec/RequiredRubyVersion
|
31
|
+
# The intent is for supportability from ruby 2.7 and greater
|
32
|
+
spec.required_ruby_version = '>= 2.7.6'
|
33
|
+
# rubocop:enable Gemspec/RequiredRubyVersion
|
31
34
|
|
32
35
|
spec.add_dependency 'rainbow', '>= 2.0', '< 4.0.0'
|
33
|
-
spec.add_dependency 'thor', '
|
36
|
+
spec.add_dependency 'thor', '>= 0.19'
|
34
37
|
|
35
38
|
spec.add_dependency 'tty-prompt', '~> 0.12'
|
36
39
|
spec.add_dependency 'tty-spinner', '~> 0.4'
|
data/dangerfile.js
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
const PR_LINK = `([#${danger.github.pr.number}](${danger.github.pr.html_url}))`;
|
2
|
+
|
3
|
+
const CHANGELOG_SUMMARY_TITLE = `Instructions and example for changelog`;
|
4
|
+
const CHANGELOG_BODY = `Please add an entry to \`CHANGELOG.md\` to the "Unreleased" section. Make sure the entry includes this PR's number.
|
5
|
+
|
6
|
+
Example:`;
|
7
|
+
|
8
|
+
const CHANGELOG_END_BODY = `If none of the above apply, you can opt out of this check by adding \`#skip-changelog\` to the PR description.`;
|
9
|
+
|
10
|
+
function getCleanTitleWithPrLink() {
|
11
|
+
const title = danger.github.pr.title;
|
12
|
+
return title.split(": ").slice(-1)[0].trim().replace(/\.+$/, "") + ` ` + PR_LINK;
|
13
|
+
}
|
14
|
+
|
15
|
+
function getChangelogDetailsHtml() {
|
16
|
+
return `
|
17
|
+
### ${CHANGELOG_SUMMARY_TITLE}
|
18
|
+
|
19
|
+
${CHANGELOG_BODY}
|
20
|
+
|
21
|
+
\`\`\`markdown
|
22
|
+
- ${getCleanTitleWithPrLink()}
|
23
|
+
\`\`\`
|
24
|
+
|
25
|
+
${CHANGELOG_END_BODY}
|
26
|
+
`;
|
27
|
+
}
|
28
|
+
|
29
|
+
function getChangelogDetailsTxt() {
|
30
|
+
return (
|
31
|
+
CHANGELOG_SUMMARY_TITLE +
|
32
|
+
"\n" +
|
33
|
+
CHANGELOG_BODY +
|
34
|
+
"\n" +
|
35
|
+
getCleanTitleWithPrLink() +
|
36
|
+
"\n" +
|
37
|
+
CHANGELOG_END_BODY
|
38
|
+
);
|
39
|
+
}
|
40
|
+
|
41
|
+
function HasPermissionToComment() {
|
42
|
+
return (
|
43
|
+
danger.github.pr.head.repo.git_url == danger.github.pr.base.repo.git_url
|
44
|
+
);
|
45
|
+
}
|
46
|
+
|
47
|
+
async function containsChangelog(path) {
|
48
|
+
const contents = await danger.github.utils.fileContents(path);
|
49
|
+
return contents.includes(PR_LINK);
|
50
|
+
}
|
51
|
+
|
52
|
+
async function checkChangelog() {
|
53
|
+
const skipChangelog =
|
54
|
+
danger.github && (danger.github.pr.body + "").toLowerCase().includes("#skip-changelog");
|
55
|
+
if (skipChangelog) {
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
|
59
|
+
const hasChangelog = await containsChangelog("CHANGELOG.md");
|
60
|
+
|
61
|
+
if (!hasChangelog) {
|
62
|
+
if (HasPermissionToComment()) {
|
63
|
+
fail("Please consider adding a changelog entry for the next release.");
|
64
|
+
markdown(getChangelogDetailsHtml());
|
65
|
+
} else {
|
66
|
+
//Fallback
|
67
|
+
console.log(
|
68
|
+
"Please consider adding a changelog entry for the next release."
|
69
|
+
);
|
70
|
+
console.log(getChangelogDetailsTxt());
|
71
|
+
process.exitCode = 1;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
async function checkIfFeature() {
|
77
|
+
const title = danger.github.pr.title;
|
78
|
+
if (title.startsWith("feat:") && HasPermissionToComment()) {
|
79
|
+
message(
|
80
|
+
'Do not forget to update <a href="https://github.com/getsentry/sentry-docs">Sentry-docs</a> with your feature once the pull request gets approved.'
|
81
|
+
);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
async function checkAll() {
|
86
|
+
// See: https://spectrum.chat/danger/javascript/support-for-github-draft-prs~82948576-ce84-40e7-a043-7675e5bf5690
|
87
|
+
const isDraft = danger.github.pr.mergeable_state === "draft";
|
88
|
+
|
89
|
+
if (isDraft) {
|
90
|
+
return;
|
91
|
+
}
|
92
|
+
|
93
|
+
await checkIfFeature();
|
94
|
+
await checkChangelog();
|
95
|
+
}
|
96
|
+
|
97
|
+
schedule(checkAll);
|
@@ -262,10 +262,8 @@ module CodeownerValidator
|
|
262
262
|
@codeowner_file_paths = %w[CODEOWNERS docs/CODEOWNERS .github/CODEOWNERS]
|
263
263
|
|
264
264
|
# allow customization of the locations to search for the file
|
265
|
-
|
266
|
-
|
267
|
-
@codeowner_file_paths << str
|
268
|
-
end
|
265
|
+
ENV['CODEOWNER_FILE_PATHS']&.split(',')&.each(&:strip!)&.each do |str|
|
266
|
+
@codeowner_file_paths << str
|
269
267
|
end
|
270
268
|
|
271
269
|
@codeowner_file_paths
|
@@ -13,18 +13,23 @@ module CodeownerValidator
|
|
13
13
|
def in_folder(folder)
|
14
14
|
raise "The folder location '#{folder}' does not exists" unless File.directory?(folder)
|
15
15
|
|
16
|
-
|
17
|
-
Bundler.with_clean_env do
|
18
|
-
Dir.chdir folder do
|
19
|
-
yield
|
20
|
-
end
|
21
|
-
end
|
22
|
-
else
|
16
|
+
with_clean_env do
|
23
17
|
Dir.chdir folder do
|
24
18
|
yield
|
25
19
|
end
|
26
20
|
end
|
27
21
|
end
|
22
|
+
|
23
|
+
def with_clean_env
|
24
|
+
return yield unless defined?(Bundler)
|
25
|
+
|
26
|
+
if Bundler.respond_to?(:with_unbundled_env)
|
27
|
+
Bundler.with_unbundled_env { yield }
|
28
|
+
else
|
29
|
+
# Deprecated on Bundler 2.1
|
30
|
+
Bundler.with_clean_env { yield }
|
31
|
+
end
|
32
|
+
end
|
28
33
|
end
|
29
34
|
end
|
30
35
|
# rubocop:enable Style/ImplicitRuntimeError
|
@@ -79,10 +79,8 @@ module CodeownerValidator
|
|
79
79
|
@whitelist_file_paths = %w[CODEOWNERS_WHITELIST .github/CODEOWNERS_WHITELIST]
|
80
80
|
|
81
81
|
# allow customization of the locations to search for the file
|
82
|
-
|
83
|
-
|
84
|
-
@whitelist_file_paths << str
|
85
|
-
end
|
82
|
+
ENV['CODEOWNER_WHITELIST_FILE_PATHS']&.split(',')&.each(&:strip!)&.each do |str|
|
83
|
+
@whitelist_file_paths << str
|
86
84
|
end
|
87
85
|
|
88
86
|
@whitelist_file_paths
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeowner_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Howdeshell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
@@ -34,14 +34,14 @@ dependencies:
|
|
34
34
|
name: thor
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0.19'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0.19'
|
47
47
|
- !ruby/object:Gem::Dependency
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- bin/rspec
|
158
158
|
- bin/rubocop
|
159
159
|
- codeowner_validator.gemspec
|
160
|
+
- dangerfile.js
|
160
161
|
- lib/codeowner_validator.rb
|
161
162
|
- lib/codeowner_validator/cli/validator_cli.rb
|
162
163
|
- lib/codeowner_validator/code_owners.rb
|
@@ -190,14 +191,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
190
191
|
requirements:
|
191
192
|
- - ">="
|
192
193
|
- !ruby/object:Gem::Version
|
193
|
-
version: 2.6
|
194
|
+
version: 2.7.6
|
194
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
196
|
requirements:
|
196
197
|
- - ">="
|
197
198
|
- !ruby/object:Gem::Version
|
198
199
|
version: '0'
|
199
200
|
requirements: []
|
200
|
-
rubygems_version: 3.
|
201
|
+
rubygems_version: 3.4.10
|
201
202
|
signing_key:
|
202
203
|
specification_version: 4
|
203
204
|
summary: Write a short summary, because RubyGems requires one.
|