github_bot 0.2.2 → 0.3.1
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/.github/workflows/cd.yml +1 -1
- data/.github/workflows/ci.yml +10 -2
- data/.rubocop.yml +19 -28
- data/.ruby-version +1 -1
- data/CHANGELOG.md +8 -1
- data/Gemfile +0 -4
- data/README.md +3 -1
- data/dangerfile.js +97 -0
- data/github_bot.gemspec +6 -3
- data/lib/github_bot/version.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61973c7486e9ca173cb3dbbccc00dc26447dd60fddf21c81c0e7fb9b9e52472c
|
4
|
+
data.tar.gz: e4cf36b31641a4ad74ae46542d7a2004e84eff80aa5873f734006598881eb9f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af7c17cac25261f7d7f849a612150a7e39698d6eba0f6e2173744e5447095ea20484384e2e1012cb091ea855ca6e4aa0d6638332c2b44091a93ddf4fae5bfec7
|
7
|
+
data.tar.gz: a5fbfbda3d8d093a2d48d9bd20e32ee87e3719d4a485cfc5cf7ea70722c2b5f276b73934e30810fb714e22a98912809e7fd77367966327d46451b70d231e047c
|
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,19 +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/**/*'
|
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
|
-
#
|
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.
|
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
|
-
|
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:
|
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
|
-
|
609
|
-
|
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
|
-
|
614
|
-
|
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:
|
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
|
-
#
|
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
|
-
|
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
|
860
|
-
#
|
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
|
1
|
+
ruby-3.2
|
data/CHANGELOG.md
CHANGED
@@ -1,2 +1,9 @@
|
|
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))
|
7
|
+
|
8
|
+
# 0.3.1
|
9
|
+
- Back version of ruby to be in RVM supported set ([#9](https://github.com/cerner/github_bot-ruby/pull/9))
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# GitHub Bot
|
2
2
|
|
3
|
-
](http://engineering.cerner.com/2014/01/cerner-and-open-source/)
|
4
|
+
[](https://github.com/cerner/github_bot-ruby/blob/main/LICENSE)
|
5
|
+
[](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
|
-
|
30
|
+
# rubocop:disable Gemspec/RequiredRubyVersion
|
31
|
+
# The intent is for supportability from ruby 2.7 and greater
|
32
|
+
spec.required_ruby_version = '>= 2.7.2'
|
33
|
+
# rubocop:enable Gemspec/RequiredRubyVersion
|
31
34
|
|
32
35
|
spec.add_dependency 'git', '~> 1.0'
|
33
|
-
spec.add_dependency 'jwt', '~>
|
34
|
-
spec.add_dependency 'octokit', '
|
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
|
data/lib/github_bot/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.1
|
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: git
|
@@ -30,26 +30,26 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
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: '
|
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.
|
140
|
+
version: 2.7.2
|
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.
|
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.
|