codeowner_validator 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b7c6486b06a5d901e16a9832878588af1e3a053c2dc831a10ec391712019fba
4
- data.tar.gz: b1d39da8af2673c74ba6d054588538c0c21b8b251333b8e65c83a1af970bc992
3
+ metadata.gz: af5d012aae29107c60cb74edc6bfaa3d56d6523b9413be3d0bc7d24cb5f9f3d3
4
+ data.tar.gz: 5886013628d005e5fe99e0a53d19a48a80b1cd378e98518ff66d4ccfc59bd809
5
5
  SHA512:
6
- metadata.gz: eaf28f5df9af24d42f6b197fa75f3596f2549609917ed6b2cf8cfb6d70b9e4d3391b4a4c365723cd950e07cd5012db4308937ae2287d506d54318ca81fc91a99
7
- data.tar.gz: e16eccee7010b4713cba8440d7e8d134ce9976d68a5a3437e1fa0e2531b3e6972696d9ce65877c0d4280e98288d495aec09221388bbe1abd3f2fed73c0aa32fb
6
+ metadata.gz: bd1a3bb3edf928012d9dab14eddb4c052ed7ed1e3fc43dcba5b36f8df71cdabbf0b628dcee5b5344d88f5a7af95423ea4d3fb8bfd4b5e3790da0d2dbac1b0b78
7
+ data.tar.gz: e5bda23020dd0abb542633c12b6bc03c1025e4b0d1d4bc96c981037937ea3713710fb92592173523dc39ae7cc4171b9be847e85bb74979450f076ea1255333bd
@@ -4,7 +4,7 @@ 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:
@@ -32,6 +32,13 @@ jobs:
32
32
  ruby-version: ${{ matrix.ruby }}
33
33
  - name: Install dependencies
34
34
  run: bundle install --jobs 4 --retry 3
35
+ - if: github.event_name == 'pull_request'
36
+ name: Danger
37
+ uses: danger/danger-js@9.1.8
38
+ env:
39
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40
+ # https://github.com/danger/danger-js/issues/557#issuecomment-664851950
41
+ DANGER_DISABLE_TRANSPILATION: true
35
42
  - name: Run tests
36
43
  run: bundle exec rspec
37
44
  - name: Run Rubocop
data/.rubocop.yml CHANGED
@@ -1,18 +1,13 @@
1
1
  require:
2
2
  - rubocop-performance
3
- - rubocop-rspec
4
- - rubocop-rake
5
3
 
6
4
  AllCops:
7
- TargetRubyVersion: 2.6
8
5
  DisabledByDefault: true
9
6
  Exclude:
10
- - 'bin/{bundle,bundle-audit,bundler-audit,rake,rspec,rubocop}'
7
+ - 'bin/{bundle,bundle-audit,bundler-audit,rackup,rake,rspec,rubocop}'
11
8
  - 'target/**/*'
12
9
  - 'vendor/**/*'
13
- - 'build/**/*'
14
- - 'pkg/**/*'
15
- - 'tmp/**/*'
10
+ SuggestExtensions: false
16
11
 
17
12
  # Bundler Cop Configuration
18
13
  # https://docs.rubocop.org/en/stable/cops_bundler/
@@ -240,7 +235,7 @@ Lint/AssignmentInCondition:
240
235
  Enabled: true
241
236
  Lint/BigDecimalNew:
242
237
  Enabled: true
243
- # Supercedes Lint/UselessComparison in rubocop 0.89.
238
+ # Supersedes Lint/UselessComparison in rubocop 0.89.
244
239
  Lint/BinaryOperatorWithIdenticalOperands:
245
240
  Enabled: true
246
241
  Lint/BooleanSymbol:
@@ -301,7 +296,7 @@ Lint/MissingCopEnableDirective:
301
296
  Enabled: true
302
297
  Lint/MissingSuper:
303
298
  # Disabled. This cop is well-meaning, but doesn't provide exemption of cases where invocation of
304
- # super is not possible. Supercedes Style/MethodMissingSuper in rubocop 0.89.
299
+ # super is not possible. Supersedes Style/MethodMissingSuper in rubocop 0.89.
305
300
  Enabled: false
306
301
  Lint/MultipleComparison:
307
302
  Enabled: true
@@ -387,8 +382,6 @@ Lint/UselessAccessModifier:
387
382
  Enabled: true
388
383
  Lint/UselessAssignment:
389
384
  Enabled: true
390
- Lint/UselessElseWithoutRescue:
391
- Enabled: true
392
385
  Lint/UselessSetterCall:
393
386
  Enabled: true
394
387
  Lint/Void:
@@ -451,7 +444,7 @@ Naming/MemoizedInstanceVariableName:
451
444
  Enabled: true
452
445
  Naming/MethodName:
453
446
  Enabled: true
454
- IgnoredPatterns:
447
+ AllowedPatterns:
455
448
  - 'do_GET'
456
449
  - 'do_POST'
457
450
  - 'do_PUT'
@@ -467,9 +460,10 @@ Naming/RescuedExceptionsVariableName:
467
460
  Enabled: false
468
461
  Naming/VariableName:
469
462
  Enabled: true
463
+ # Disabled. It's acceptable (and in heavy usage already) to name things like "data_model_1"
464
+ # instead of forcing "data_model1".
470
465
  Naming/VariableNumber:
471
- Enabled: true
472
-
466
+ Enabled: false
473
467
 
474
468
  # Performance Cop Configuration
475
469
  # https://rubocop-performance.readthedocs.io/en/stable/cops_performance/
@@ -604,15 +598,11 @@ Style/DefWithParentheses:
604
598
  Style/Dir:
605
599
  Enabled: true
606
600
  Style/Documentation:
607
- Enabled: true
608
- Exclude:
609
- - test/**/*
610
- - spec/**/*
601
+ # Disabled. Documentation is required, but enforcement here does not seem to work.
602
+ Enabled: false
611
603
  Style/DocumentationMethod:
612
- Enabled: true
613
- Exclude:
614
- - test/**/*
615
- - spec/**/*
604
+ # Disabled. Documentation is required, but enforcement here does not seem to work.
605
+ Enabled: false
616
606
  Style/DoubleCopDisableDirective:
617
607
  Enabled: true
618
608
  Style/DoubleNegation:
@@ -703,7 +693,7 @@ Style/MethodCallWithoutArgsParentheses:
703
693
  Enabled: true
704
694
  Style/MethodCalledOnDoEndBlock:
705
695
  # Disabled. It is acceptable to call a method at the end of a do/end block. In particular, this is
706
- # occationally needed in RSpec code.
696
+ # occasionally needed in RSpec code.
707
697
  Enabled: false
708
698
  Style/MethodDefParentheses:
709
699
  Enabled: true
@@ -803,7 +793,8 @@ Style/RedundantCondition:
803
793
  Style/RedundantConditional:
804
794
  Enabled: true
805
795
  Style/RedundantException:
806
- Enabled: true
796
+ # Disabled. With ImplicitRuntimeError enabled, disable subsequent warning if consumer wishes to continue using RuntimeError
797
+ Enabled: false
807
798
  Style/RedundantFreeze:
808
799
  Enabled: true
809
800
  Style/RedundantInterpolation:
@@ -855,8 +846,8 @@ Style/SpecialGlobalVars:
855
846
  Style/StabbyLambdaParentheses:
856
847
  Enabled: true
857
848
  Style/StderrPuts:
858
- # Disabled. This cop functionally equates use of STDERR with optional warnings. This may be true in some use cases, but there
859
- # are times when using STDERR in CLIs is not an optional warning.
849
+ # Disabled. This cop functionally equates use of STDERR with optional warnings. This may be true
850
+ # in some use cases, but there are times when using STDERR in CLIs is not an optional warning.
860
851
  Enabled: false
861
852
  Style/StringHashKeys:
862
853
  # Disabled. There are many use cases where using Strings for Hash keys is required.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
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))
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'
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.required_ruby_version = '>= 2.6.2'
31
31
 
32
32
  spec.add_dependency 'rainbow', '>= 2.0', '< 4.0.0'
33
- spec.add_dependency 'thor', '~> 0.19'
33
+ spec.add_dependency 'thor', '>= 0.19'
34
34
 
35
35
  spec.add_dependency 'tty-prompt', '~> 0.12'
36
36
  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
- if ENV['CODEOWNER_FILE_PATHS']
266
- ENV['CODEOWNER_FILE_PATHS']&.split(',')&.each(&:strip!)&.each do |str|
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
@@ -12,7 +12,7 @@ module CodeownerValidator
12
12
  class << self
13
13
  # @see CodeownerValidator::Group::Comment.match?
14
14
  def match?(type)
15
- Comment::TYPE_ERROR == type
15
+ type == Comment::TYPE_ERROR
16
16
  end
17
17
  end
18
18
  end
@@ -12,7 +12,7 @@ module CodeownerValidator
12
12
  class << self
13
13
  # @see CodeownerValidator::Group::Comment.match?
14
14
  def match?(type)
15
- Comment::TYPE_INFO == type
15
+ type == Comment::TYPE_INFO
16
16
  end
17
17
  end
18
18
  end
@@ -12,7 +12,7 @@ module CodeownerValidator
12
12
  class << self
13
13
  # @see CodeownerValidator::Group::Comment.match?
14
14
  def match?(type)
15
- Comment::TYPE_VERBOSE == type
15
+ type == Comment::TYPE_VERBOSE
16
16
  end
17
17
  end
18
18
  end
@@ -12,7 +12,7 @@ module CodeownerValidator
12
12
  class << self
13
13
  # @see CodeownerValidator::Group::Comment.match?
14
14
  def match?(type)
15
- Comment::TYPE_WARN == type
15
+ type == Comment::TYPE_WARN
16
16
  end
17
17
  end
18
18
  end
@@ -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
- if ENV['CODEOWNER_WHITELIST_FILE_PATHS']
83
- ENV['CODEOWNER_WHITELIST_FILE_PATHS']&.split(',')&.each(&:strip!)&.each do |str|
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
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'codeowner_validator/common/tasks/base'
4
+ require 'codeowner_validator/group/comment'
4
5
 
5
6
  module CodeownerValidator
6
7
  module Tasks
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'codeowner_validator/common/tasks/base'
4
+ require 'codeowner_validator/group/comment'
4
5
 
5
6
  module CodeownerValidator
6
7
  module Tasks
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CodeownerValidator
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
 
6
6
  # version module
7
7
  module Version
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.1.1
4
+ version: 0.2.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: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2023-03-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
@@ -197,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
198
  - !ruby/object:Gem::Version
198
199
  version: '0'
199
200
  requirements: []
200
- rubygems_version: 3.0.3
201
+ rubygems_version: 3.0.3.1
201
202
  signing_key:
202
203
  specification_version: 4
203
204
  summary: Write a short summary, because RubyGems requires one.