forked from codeclimate/codeclimate-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpull_request_test.rb
executable file
·46 lines (42 loc) · 996 Bytes
/
pull_request_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env ruby
#
# Ad-hoc script for updating a pull request using our service.
#
# Usage:
#
# $ OAUTH_TOKEN="..." bundle exec ruby pull_request_test.rb
#
# OAUTH_TOKEN: Personal GitHub access token
#
# GitHub >
# Account settings >
# Applications >
# Personal access tokens >
# Generate new token
#
###
require "cc/services"
CC::Service.load_services
class WithResponseLogging
def initialize(invocation)
@invocation = invocation
end
def call
@invocation.call.tap { |r| p r }
end
end
service = CC::Service::GitHubPullRequests.new(
{
oauth_token: ENV.fetch("OAUTH_TOKEN"),
},
name: "pull_request",
# https://github.com/codeclimate/nillson/pull/33
state: "success",
github_slug: "codeclimate/nillson",
issue_comparison_counts: { "new" => 0, "fixed" => 0 },
number: 33,
commit_sha: "986ec903b8420f4e8c8d696d8950f7bd0667ff0c",
)
CC::Service::Invocation.new(service) do |i|
i.wrap(WithResponseLogging)
end