You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/developers/apps/creating-ci-tests-with-the-checks-api.md
+102Lines changed: 102 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -133,6 +133,26 @@ The `requested` action requests a check run each time code is pushed to the repo
133
133
134
134
You'll add this new method as a [Sinatra helper](https://github.com/sinatra/sinatra#helpers) in case you want other routes to use it too. Under `helpers do`, add this `create_check_run` method:
135
135
136
+
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}
137
+
```ruby
138
+
# Create a new check run with the status queued
139
+
defcreate_check_run
140
+
# # At the time of writing, Octokit does not support the Checks API yet, but
141
+
# it does provide generic HTTP methods you can use:
This code calls the "[Create a check run](/v3/checks/runs/#create-a-check-run)" endpoint using the generic [HTTP `POST` method](http://octokit.github.io/octokit.rb/Octokit/Connection.html#post-instance_method). This method takes two parameters: the URL of the endpoint and the input parameters to the method.
157
178
@@ -208,6 +229,43 @@ In this section, you're not going to kick off the CI test yet, but you'll walk t
208
229
209
230
Let's create the `initiate_check_run` method and update the status of the check run. Add the following code to the helpers section:
210
231
232
+
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}
233
+
```ruby
234
+
# Start the CI process
235
+
definitiate_check_run
236
+
# Once the check run is created, you'll update the status of the check run
237
+
# to 'in_progress' and run the CI process. When the CI finishes, you'll
238
+
# update the check run status to 'completed' and add the CI results.
239
+
240
+
# Octokit doesn't yet support the Checks API, but it does provide generic
The code above calls the "[Update a check run](/v3/checks/runs/#update-a-check-run)" API endpoint using the generic [`patch` HTTP method](http://octokit.github.io/octokit.rb/Octokit/Connection.html#patch-instance_method) to update the check run that you already created.
249
308
@@ -548,6 +607,21 @@ text = "Octo RuboCop version: #{@output['metadata']['rubocop_version']}"
548
607
549
608
Now you've got all the information you need to update your check run. In the [first half of this quickstart](#step-14-updating-a-check-run), you added this code to set the status of the check run to `success`:
550
609
610
+
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}
You'll need to update that code to use the `conclusion` variable you set based on the RuboCop results (to `success` or `neutral`). You can update the code with the following:
566
641
642
+
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}
643
+
```ruby
644
+
# Mark the check run as complete! And if there are warnings, share them.
Now that you're setting a conclusion based on the status of the CI test and you've added the output from the RuboCop results, you've created a CI test! Congratulations. 🙌
{% if currentVersion ver_lt "enterprise-server@2.23" %}
169
180
### Check runs and check suites API
170
181
171
182
Allows a GitHub App to run external checks on a repository's code. See the [Check runs](/v3/checks/runs/) and [Check suites](/v3/checks/suites/) APIs for more details.
0 commit comments