Skip to content

Commit e455d67

Browse files
committed
add additional check run methods
1 parent 5eb55ce commit e455d67

File tree

2 files changed

+83
-2
lines changed

2 files changed

+83
-2
lines changed

doc/repo/checks.md

+31-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $params = [
1313
'details_url' => 'https://nimbleci.com/...',
1414
'output' => {...}
1515
];
16-
$checks = $client->api('repo')->checks()->create('NimbleCI', 'docker-web-tester-behat', $params);
16+
$check = $client->api('repo')->checks()->create('NimbleCI', 'docker-web-tester-behat', $params);
1717
```
1818

1919
### Update an existing check on a commit
@@ -27,5 +27,34 @@ $params = [
2727
'details_url' => 'https://nimbleci.com/...',
2828
'output' => {...}
2929
];
30-
$checks = $client->api('repo')->checks()->create('NimbleCI', 'docker-web-tester-behat', $checkRunId, $params);
30+
$check = $client->api('repo')->checks()->create('NimbleCI', 'docker-web-tester-behat', $checkRunId, $params);
31+
```
32+
33+
### List check runs for a Git reference
34+
35+
https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-git-reference
36+
37+
```php
38+
$params = [
39+
'check_name' => 'my check',
40+
'status' => 'completed',
41+
'filter' => 'latest',
42+
];
43+
$checks = $client->api('repo')->checks()->all('NimbleCI', 'docker-web-tester-behat', $ref, $params);
44+
```
45+
46+
### Get a check run
47+
48+
https://developer.github.com/v3/checks/runs/#get-a-check-run
49+
50+
```php
51+
$check = $client->api('repo')->checks()->show('NimbleCI', 'docker-web-tester-behat', $checkRunId);
52+
```
53+
54+
### List check run annotations
55+
56+
https://developer.github.com/v3/checks/runs/#list-check-run-annotations
57+
58+
```php
59+
$annotations = $client->api('repo')->checks()->annotations('NimbleCI', 'docker-web-tester-behat', $checkRunId);
3160
```

lib/Github/Api/Repository/Checks.php

+52
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,56 @@ public function update($username, $repository, $checkRunId, array $params = [])
5555

5656
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.rawurlencode($checkRunId), $params);
5757
}
58+
59+
/**
60+
* @link https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-git-reference
61+
*
62+
* @param string $username
63+
* @param string $repository
64+
* @param string $ref
65+
* @param array $params
66+
*
67+
* @return array
68+
*/
69+
public function all($username, $repository, $ref, $params = [])
70+
{
71+
// This api is in preview mode, so set the correct accept-header.
72+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
73+
74+
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($ref).'/check-runs', $params);
75+
}
76+
77+
/**
78+
* @link https://developer.github.com/v3/checks/runs/#get-a-check-run
79+
*
80+
* @param string $username
81+
* @param string $repository
82+
* @param string $checkRunId
83+
*
84+
* @return array
85+
*/
86+
public function show($username, $repository, $checkRunId)
87+
{
88+
// This api is in preview mode, so set the correct accept-header.
89+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
90+
91+
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.rawurlencode($checkRunId));
92+
}
93+
94+
/**
95+
* @link https://developer.github.com/v3/checks/runs/#list-check-run-annotations
96+
*
97+
* @param string $username
98+
* @param string $repository
99+
* @param string $checkRunId
100+
*
101+
* @return array
102+
*/
103+
public function annotations($username, $repository, $checkRunId)
104+
{
105+
// This api is in preview mode, so set the correct accept-header.
106+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
107+
108+
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.rawurlencode($checkRunId).'/annotations');
109+
}
58110
}

0 commit comments

Comments
 (0)