Skip to content

Commit

Permalink
feature #1141 Add API to rerequest a check run (Spea)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.15-dev branch.

Discussion
----------

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).

Commits
-------

48e025e Add API to rerequest a check run
  • Loading branch information
acrobat authored Sep 26, 2024
2 parents 845545b + 48e025e commit 055cf51
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 055cf51

Please sign in to comment.