github_bot 0.2.2 → 0.3.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: 0fa326810f555e7ef6cab9db0c96d5055cb7251ca156828a846e1a3a98dcc583
4
- data.tar.gz: e14ac7aba656ca607cf5c6470f95c336c36d432601cef807bd47d7cf1badc75b
3
+ metadata.gz: 8171b42a58a7f35cfa98c74f60bb8bed775b5d7fc8b8ff2eb9ee6d4a17c9cb3b
4
+ data.tar.gz: a0d72d29f3967beb0e22d6b876ffdb8ab57277dcd3f0aa985288c8dab30de272
5
5
  SHA512:
6
- metadata.gz: e7ac68baca52650e65be184da77495e322dd0eb1a93af76841c2753b3da45f95777955ee3ee6cfc4bed563991a2c1c71fc3b6e02e812c3925f57a626e79f7517
7
- data.tar.gz: aff160fd861fce89869963b3f57028d01a373077095c7dae61d8044cdb40e254c3872d3556daee2d1637095f9fbc1fb8cef1641567f73c66240a200222841512
6
+ metadata.gz: d7509a810213e4700965e54323129bfd04e7a1f52c31f72ce333f4f6dc128001cd4fe910ae3680bf437ad7d072e31a48641e3b44ac818ba104a5e047e6153cab
7
+ data.tar.gz: c5fbe516cd9401d0f5f567351896a046dd939861731dd0910c9b15d234f6a063ce2e4449db9b04d6193a26a280e765c8646602f7890af043c4822d273b1e61fa
@@ -13,7 +13,7 @@ jobs:
13
13
  fail-fast: false
14
14
  matrix:
15
15
  ruby:
16
- - 2.7
16
+ - 3.2
17
17
  name: Ruby-${{matrix.ruby}}
18
18
  steps:
19
19
  - name: Check out
@@ -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,19 +1,14 @@
1
1
  require:
2
2
  - rubocop-performance
3
- - rubocop-rspec
4
- - rubocop-rake
5
3
 
6
4
  AllCops:
7
- TargetRubyVersion: 2.6
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
- - 'build/**/*'
14
- - 'pkg/**/*'
15
- - 'tmp/**/*'
16
- - 'spec/**/*'
11
+ SuggestExtensions: false
17
12
 
18
13
  # Bundler Cop Configuration
19
14
  # https://docs.rubocop.org/en/stable/cops_bundler/
@@ -241,7 +236,7 @@ Lint/AssignmentInCondition:
241
236
  Enabled: true
242
237
  Lint/BigDecimalNew:
243
238
  Enabled: true
244
- # Supercedes Lint/UselessComparison in rubocop 0.89.
239
+ # Supersedes Lint/UselessComparison in rubocop 0.89.
245
240
  Lint/BinaryOperatorWithIdenticalOperands:
246
241
  Enabled: true
247
242
  Lint/BooleanSymbol:
@@ -302,7 +297,7 @@ Lint/MissingCopEnableDirective:
302
297
  Enabled: true
303
298
  Lint/MissingSuper:
304
299
  # Disabled. This cop is well-meaning, but doesn't provide exemption of cases where invocation of
305
- # super is not possible. Supercedes Style/MethodMissingSuper in rubocop 0.89.
300
+ # super is not possible. Supersedes Style/MethodMissingSuper in rubocop 0.89.
306
301
  Enabled: false
307
302
  Lint/MultipleComparison:
308
303
  Enabled: true
@@ -388,8 +383,6 @@ Lint/UselessAccessModifier:
388
383
  Enabled: true
389
384
  Lint/UselessAssignment:
390
385
  Enabled: true
391
- Lint/UselessElseWithoutRescue:
392
- Enabled: true
393
386
  Lint/UselessSetterCall:
394
387
  Enabled: true
395
388
  Lint/Void:
@@ -452,7 +445,7 @@ Naming/MemoizedInstanceVariableName:
452
445
  Enabled: true
453
446
  Naming/MethodName:
454
447
  Enabled: true
455
- IgnoredPatterns:
448
+ AllowedPatterns:
456
449
  - 'do_GET'
457
450
  - 'do_POST'
458
451
  - 'do_PUT'
@@ -468,9 +461,10 @@ Naming/RescuedExceptionsVariableName:
468
461
  Enabled: false
469
462
  Naming/VariableName:
470
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".
471
466
  Naming/VariableNumber:
472
- Enabled: true
473
-
467
+ Enabled: false
474
468
 
475
469
  # Performance Cop Configuration
476
470
  # https://rubocop-performance.readthedocs.io/en/stable/cops_performance/
@@ -605,15 +599,11 @@ Style/DefWithParentheses:
605
599
  Style/Dir:
606
600
  Enabled: true
607
601
  Style/Documentation:
608
- Enabled: true
609
- Exclude:
610
- - test/**/*
611
- - spec/**/*
602
+ # Disabled. Documentation is required, but enforcement here does not seem to work.
603
+ Enabled: false
612
604
  Style/DocumentationMethod:
613
- Enabled: true
614
- Exclude:
615
- - test/**/*
616
- - spec/**/*
605
+ # Disabled. Documentation is required, but enforcement here does not seem to work.
606
+ Enabled: false
617
607
  Style/DoubleCopDisableDirective:
618
608
  Enabled: true
619
609
  Style/DoubleNegation:
@@ -659,7 +649,7 @@ Style/GlobalVars:
659
649
  Style/GuardClause:
660
650
  Enabled: true
661
651
  Style/HashSyntax:
662
- Enabled: true
652
+ Enabled: false
663
653
  Style/IdenticalConditionalBranches:
664
654
  Enabled: true
665
655
  Style/IfInsideElse:
@@ -704,7 +694,7 @@ Style/MethodCallWithoutArgsParentheses:
704
694
  Enabled: true
705
695
  Style/MethodCalledOnDoEndBlock:
706
696
  # Disabled. It is acceptable to call a method at the end of a do/end block. In particular, this is
707
- # occationally needed in RSpec code.
697
+ # occasionally needed in RSpec code.
708
698
  Enabled: false
709
699
  Style/MethodDefParentheses:
710
700
  Enabled: true
@@ -804,7 +794,8 @@ Style/RedundantCondition:
804
794
  Style/RedundantConditional:
805
795
  Enabled: true
806
796
  Style/RedundantException:
807
- Enabled: true
797
+ # Disabled. With ImplicitRuntimeError enabled, disable subsequent warning if consumer wishes to continue using RuntimeError
798
+ Enabled: false
808
799
  Style/RedundantFreeze:
809
800
  Enabled: true
810
801
  Style/RedundantInterpolation:
@@ -856,8 +847,8 @@ Style/SpecialGlobalVars:
856
847
  Style/StabbyLambdaParentheses:
857
848
  Enabled: true
858
849
  Style/StderrPuts:
859
- # Disabled. This cop functionally equates use of STDERR with optional warnings. This may be true in some use cases, but there
860
- # are times when using STDERR in CLIs is not an optional warning.
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.
861
852
  Enabled: false
862
853
  Style/StringHashKeys:
863
854
  # Disabled. There are many use cases where using Strings for Hash keys is required.
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.6
1
+ ruby-3.2
data/CHANGELOG.md CHANGED
@@ -1,2 +1,6 @@
1
1
  # 0.1.0
2
- Initial release
2
+ - Initial release
3
+
4
+ # 0.3.0
5
+ - Add Danger validation for changelog and prepare for next patch release ([#7](https://github.com/cerner/github_bot-ruby/pull/7))
6
+ - Update to support ruby 3.2 ([#8](https://github.com/cerner/github_bot-ruby/pull/8))
data/Gemfile CHANGED
@@ -17,7 +17,3 @@ gem 'rubocop-rake', '~> 0.5', require: false
17
17
  gem 'rubocop-rspec', '~> 2.1', require: false
18
18
  gem 'simplecov', '~> 0.19', require: false
19
19
  gem 'timecop', '~> 0.9'
20
-
21
- # debugging
22
- gem 'debase', '~> 0.2.5.beta2'
23
- gem 'ruby-debug-ide'
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # GitHub Bot
2
2
 
3
- ![CI](https://github.com/cerner/github_bot-ruby/actions/workflows/ci.yml/badge.svg)
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/github_bot-ruby)](https://github.com/cerner/github_bot-ruby/blob/main/LICENSE)
5
+ [![Build Status](https://github.com/cerner/github_bot-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/cerner/github_bot-ruby/actions/workflows/ci.yml)
4
6
 
5
7
  This library is a ruby implementation necessary for beginning your GitHub bot development for Ruby-based projects. The key items this project provides to consumers are the following:
6
8
 
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);
data/github_bot.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
- spec.required_ruby_version = '>= 2.6.2'
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 'git', '~> 1.0'
33
- spec.add_dependency 'jwt', '~> 1.0'
34
- spec.add_dependency 'octokit', '~> 4.18'
36
+ spec.add_dependency 'jwt', '~> 2.0'
37
+ spec.add_dependency 'octokit', '>= 4.18'
35
38
  spec.add_dependency 'rails', '>= 5.0.0.1', '< 7.0.0'
36
39
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GithubBot
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.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: github_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
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: 2022-01-24 00:00:00.000000000 Z
11
+ date: 2023-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -30,26 +30,26 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: octokit
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '4.18'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '4.18'
55
55
  - !ruby/object:Gem::Dependency
@@ -114,6 +114,7 @@ files:
114
114
  - bin/rspec
115
115
  - bin/rubocop
116
116
  - config/routes.rb
117
+ - dangerfile.js
117
118
  - github_bot.gemspec
118
119
  - lib/github_bot.rb
119
120
  - lib/github_bot/engine.rb
@@ -136,14 +137,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
137
  requirements:
137
138
  - - ">="
138
139
  - !ruby/object:Gem::Version
139
- version: 2.6.2
140
+ version: 2.7.6
140
141
  required_rubygems_version: !ruby/object:Gem::Requirement
141
142
  requirements:
142
143
  - - ">="
143
144
  - !ruby/object:Gem::Version
144
145
  version: '0'
145
146
  requirements: []
146
- rubygems_version: 3.0.3.1
147
+ rubygems_version: 3.4.10
147
148
  signing_key:
148
149
  specification_version: 4
149
150
  summary: A rubygem designed to assist in the creation of GitHub bot applications.