github_bot 0.1.0 → 0.2.2
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/ISSUE_TEMPLATE/bug_report.md +1 -1
- data/.github/ISSUE_TEMPLATE/config.yml +1 -1
- data/Gemfile +1 -0
- data/lib/github_bot/github/check_run.rb +5 -0
- data/lib/github_bot/github/client.rb +2 -1
- data/lib/github_bot/github/payload.rb +28 -3
- data/lib/github_bot/validator/base.rb +25 -8
- data/lib/github_bot/version.rb +1 -1
- metadata +2 -6
- data/bin/rails +0 -26
- data/bin/rake +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fa326810f555e7ef6cab9db0c96d5055cb7251ca156828a846e1a3a98dcc583
|
4
|
+
data.tar.gz: e14ac7aba656ca607cf5c6470f95c336c36d432601cef807bd47d7cf1badc75b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7ac68baca52650e65be184da77495e322dd0eb1a93af76841c2753b3da45f95777955ee3ee6cfc4bed563991a2c1c71fc3b6e02e812c3925f57a626e79f7517
|
7
|
+
data.tar.gz: aff160fd861fce89869963b3f57028d01a373077095c7dae61d8044cdb40e254c3872d3556daee2d1637095f9fbc1fb8cef1641567f73c66240a200222841512
|
@@ -9,7 +9,7 @@ assignees: ''
|
|
9
9
|
|
10
10
|
> Before reporting a bug
|
11
11
|
- [ ] Check the bug is reproducible.
|
12
|
-
- [ ] Search for [existing issues](https://github.com/
|
12
|
+
- [ ] Search for [existing issues](https://github.com/cerner/github_bot-ruby/issues).
|
13
13
|
|
14
14
|
**Describe the bug**
|
15
15
|
A clear and concise description of what the bug is.
|
data/Gemfile
CHANGED
@@ -16,6 +16,7 @@ gem 'rubocop-performance', '~> 1.8', require: false
|
|
16
16
|
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
|
+
gem 'timecop', '~> 0.9'
|
19
20
|
|
20
21
|
# debugging
|
21
22
|
gem 'debase', '~> 0.2.5.beta2'
|
@@ -44,6 +44,11 @@ module GithubBot
|
|
44
44
|
update(status: 'completed', conclusion: 'action_required', completed_at: Time.now, **options)
|
45
45
|
end
|
46
46
|
|
47
|
+
# Public: Updates the check run to a neutral state
|
48
|
+
def neutral!(**options)
|
49
|
+
update(status: 'completed', conclusion: 'neutral', completed_at: Time.now, **options)
|
50
|
+
end
|
51
|
+
|
47
52
|
private
|
48
53
|
|
49
54
|
def update(**options)
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'octokit'
|
4
4
|
require 'uri'
|
5
|
+
require 'jwt'
|
5
6
|
require_relative 'payload'
|
6
7
|
|
7
8
|
module GithubBot
|
@@ -180,7 +181,7 @@ module GithubBot
|
|
180
181
|
exp: current + (10 * 60),
|
181
182
|
iss: ENV['GITHUB_APP_IDENTIFIER']
|
182
183
|
}
|
183
|
-
JWT.encode(payload, private_key, 'RS256')
|
184
|
+
::JWT.encode(payload, private_key, 'RS256')
|
184
185
|
end
|
185
186
|
|
186
187
|
# relay messages to Octokit::Client if responds to allow extension
|
@@ -67,6 +67,11 @@ module GithubBot
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
# Public: Returns the review information for payloads that are of type pull request review
|
71
|
+
def review
|
72
|
+
payload[:review]
|
73
|
+
end
|
74
|
+
|
70
75
|
# Public: Returns <true> if the sender is of type 'Bot'; otherwise, <false>
|
71
76
|
def sender_type_bot?
|
72
77
|
payload[:sender][:type].downcase == 'bot' # rubocop:disable Performance/Casecmp
|
@@ -135,15 +140,35 @@ module GithubBot
|
|
135
140
|
# Public: Returns the repository fork URL from the original project with the most
|
136
141
|
# recent updated forked instance first
|
137
142
|
#
|
143
|
+
# Utilizing API: https://docs.github.com/en/rest/reference/repos#forks
|
144
|
+
# Example: https://api.github.com/repos/octocat/Hello-World/forks?page=1
|
145
|
+
#
|
138
146
|
# @return [Array] The array of [String] URLs associated to the forked repositories
|
139
147
|
def repository_fork_urls
|
140
148
|
return @repository_fork_urls if @repository_fork_urls
|
141
149
|
|
142
150
|
@repository_fork_urls =
|
143
151
|
[].tap do |ar|
|
144
|
-
|
145
|
-
|
146
|
-
|
152
|
+
# iterate over pages of forks
|
153
|
+
page_count = 1
|
154
|
+
forks_url = repository[:forks_url]
|
155
|
+
loop do
|
156
|
+
uri = URI.parse(forks_url)
|
157
|
+
new_query_ar = URI.decode_www_form(String(uri.query)) << ['page', page_count]
|
158
|
+
uri.query = URI.encode_www_form(new_query_ar)
|
159
|
+
|
160
|
+
Rails.logger.info "#{self.class}##{__method__} retrieving #{uri}"
|
161
|
+
|
162
|
+
json = uri.open.read
|
163
|
+
json_response = JSON.parse(json)
|
164
|
+
break if json_response.empty?
|
165
|
+
|
166
|
+
# iterate over each fork and capture the clone_url
|
167
|
+
json_response.each do |fork|
|
168
|
+
ar << fork['clone_url']
|
169
|
+
end
|
170
|
+
|
171
|
+
page_count += 1
|
147
172
|
end
|
148
173
|
end
|
149
174
|
end
|
@@ -69,14 +69,31 @@ module GithubBot
|
|
69
69
|
else
|
70
70
|
# because limitation of 50 checks per API call execution, break up annotations
|
71
71
|
# https://developer.github.com/v3/checks/runs/
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
72
|
+
|
73
|
+
# need to identify if something other than warnings
|
74
|
+
non_warnings = @feedback.select { |h| h[:annotation_level] != 'warning' }
|
75
|
+
|
76
|
+
if non_warnings.empty?
|
77
|
+
@feedback.each_slice(50).to_a.each do |annotations|
|
78
|
+
@check.neutral!(
|
79
|
+
output: {
|
80
|
+
title: "#{name} validation is complete...",
|
81
|
+
summary: "#{name} validation determined there are no required changes; however, please review the " \
|
82
|
+
'warnings as they may impact future changes.',
|
83
|
+
annotations: annotations
|
84
|
+
}
|
85
|
+
)
|
86
|
+
end
|
87
|
+
else
|
88
|
+
@feedback.each_slice(50).to_a.each do |annotations|
|
89
|
+
@check.action_required!(
|
90
|
+
output: {
|
91
|
+
title: "#{name} validation is complete...",
|
92
|
+
summary: "#{name} validation determined there are changes that need attention.",
|
93
|
+
annotations: annotations
|
94
|
+
}
|
95
|
+
)
|
96
|
+
end
|
80
97
|
end
|
81
98
|
end
|
82
99
|
rescue StandardError => e
|
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.2.2
|
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: 2022-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -80,8 +80,6 @@ email:
|
|
80
80
|
executables:
|
81
81
|
- bundle-audit
|
82
82
|
- bundler-audit
|
83
|
-
- rails
|
84
|
-
- rake
|
85
83
|
- rspec
|
86
84
|
- rubocop
|
87
85
|
extensions: []
|
@@ -113,8 +111,6 @@ files:
|
|
113
111
|
- app/helpers/github_bot/github_request_helper.rb
|
114
112
|
- bin/bundle-audit
|
115
113
|
- bin/bundler-audit
|
116
|
-
- bin/rails
|
117
|
-
- bin/rake
|
118
114
|
- bin/rspec
|
119
115
|
- bin/rubocop
|
120
116
|
- config/routes.rb
|
data/bin/rails
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# This command will automatically be run when you run "rails" with Rails gems
|
5
|
-
# installed from the root of your application.
|
6
|
-
|
7
|
-
ENGINE_ROOT = File.expand_path('..', __dir__)
|
8
|
-
ENGINE_PATH = File.expand_path('../lib/github_bot/engine', __dir__)
|
9
|
-
|
10
|
-
# Set up gems listed in the Gemfile.
|
11
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
12
|
-
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
13
|
-
|
14
|
-
require 'rails'
|
15
|
-
# Pick the frameworks you want:
|
16
|
-
require 'active_model/railtie'
|
17
|
-
require 'active_job/railtie'
|
18
|
-
require 'active_record/railtie'
|
19
|
-
require 'active_storage/engine'
|
20
|
-
require 'action_controller/railtie'
|
21
|
-
require 'action_mailer/railtie'
|
22
|
-
require 'action_view/railtie'
|
23
|
-
require 'action_cable/engine'
|
24
|
-
require 'sprockets/railtie'
|
25
|
-
# require "rails/test_unit/railtie"
|
26
|
-
require 'rails/engine/commands'
|
data/bin/rake
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rake' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
-
Pathname.new(__FILE__).realpath)
|
14
|
-
|
15
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
-
|
17
|
-
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
-
load(bundle_binstub)
|
20
|
-
else
|
21
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require "rubygems"
|
27
|
-
require "bundler/setup"
|
28
|
-
|
29
|
-
load Gem.bin_path("rake", "rake")
|