Skip to content

Commit 196a237

Browse files
committed
Add a max number of annotations
1 parent 7fc8f55 commit 196a237

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

server.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class GHAapp < Sinatra::Application
8383

8484
# Create a new check run with the status queued
8585
def create_check_run
86-
# At the time of writing, Octokit does not support the Checks API, but
86+
# At the time of writing, Octokit does not support the Checks API, but
8787
# it does provide generic HTTP methods you can use:
8888
# https://developer.github.com/v3/checks/runs/#create-a-check-run
8989
check_run = @installation_client.post(
@@ -99,8 +99,8 @@ def create_check_run
9999
)
100100

101101
# You requested the creation of a check run from GitHub. Now, you'll wait
102-
# to get confirmation from GitHub, in the form of a webhook, that it was
103-
# created before starting CI. Equivalently, a 201 response from
102+
# to get confirmation from GitHub, in the form of a webhook, that it was
103+
# created before starting CI. Equivalently, a 201 response from
104104
# POST /repos/:owner/:repo/check-runs could also be used as confirmation.
105105
end
106106

@@ -110,7 +110,7 @@ def initiate_check_run
110110
# to 'in_progress' and run the CI process. When the CI finishes, you'll
111111
# update the check run status to 'completed' and add the CI results.
112112

113-
# At the time of writing, Octokit doesn't support the Checks API, but
113+
# At the time of writing, Octokit doesn't support the Checks API, but
114114
# it does provide generic HTTP methods you can use:
115115
# https://developer.github.com/v3/checks/runs/#update-a-check-run
116116
updated_check_run = @installation_client.patch(
@@ -139,6 +139,12 @@ def initiate_check_run
139139
`rm -rf #{repository}`
140140
@output = JSON.parse @report
141141
annotations = []
142+
# You can create a maximum of 50 annotations per request to the Checks
143+
# API. To add more than 50 annotations, use the "Update a check run" API
144+
# endpoint. This example code limits the number of annotations to 50.
145+
# See https://developer.github.com/v3/checks/runs/#update-a-check-run
146+
# for details.
147+
max_annotations = 50
142148

143149
# RuboCop reports the number of errors found in 'offense_count'
144150
if @output['summary']['offense_count'] == 0
@@ -153,6 +159,10 @@ def initiate_check_run
153159

154160
# Parse each offense to get details and location
155161
file['offenses'].each do |offense|
162+
# Limit the number of annotations to 50
163+
next if max_annotations == 0
164+
max_annotations -= 1
165+
156166
start_line = offense['location']['start_line']
157167
end_line = offense['location']['last_line']
158168
start_column = offense['location']['start_column']

0 commit comments

Comments
 (0)