Skip to content

Commit

Permalink
Add API to rerequest a check run
Browse files Browse the repository at this point in the history
This change adds a new method to rerequest a check run (see also https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#rerequest-a-check-run).
  • Loading branch information
Spea committed Sep 26, 2024
1 parent 845545b commit 48e025e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion doc/repo/check_runs.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ $params = [/*...*/];
$checks = $client->api('repo')->checkRuns()->allForReference('KnpLabs', 'php-github-api', $reference, $params);
```

### Rerequest a check run

https://docs.github.com/en/rest/reference/checks#rerequest-a-check-run


```php
$checks = $client->api('repo')->checkRuns()->rerequest('KnpLabs', 'php-github-api', $checkRunId);
```
10 changes: 10 additions & 0 deletions lib/Github/Api/Repository/Checks/CheckRuns.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,14 @@ public function allForReference(string $username, string $repository, string $re

return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($ref).'/check-runs', $params);
}

/**
* @link https://docs.github.com/en/rest/reference/checks#rerequest-a-check-run
*
* @return array
*/
public function rerequest(string $username, string $repository, int $checkRunId)
{
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId.'/rerequest');
}
}
14 changes: 14 additions & 0 deletions test/Github/Tests/Api/Repository/Checks/CheckRunsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ public function shouldGetAllChecksForReference()
$api->allForReference('KnpLabs', 'php-github-api', 'cb4abc15424c0015b4468d73df55efb8b60a4a3d', $params);
}

/**
* @test
*/
public function shouldRerequestCheckRun()
{
/** @var CheckRuns|MockObject $api */
$api = $this->getApiMock();
$api->expects($this->once())
->method('post')
->with('/repos/KnpLabs/php-github-api/check-runs/123/rerequest');

$api->rerequest('KnpLabs', 'php-github-api', 123);
}

protected function getApiClass(): string
{
return CheckRuns::class;
Expand Down

0 comments on commit 48e025e

Please sign in to comment.