-
-
Notifications
You must be signed in to change notification settings - Fork 598
feat: Support for Organization Runners #1101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9d1ab1e
feat: Support for Organization Runners
haridarshan 02bd5bc
fix: StyleCI
haridarshan ea2f3ec
docs: Add Organization Self-Hosted runner doc
haridarshan 6df9b8f
docs: Add org runner link in README.md
haridarshan 70e7bbe
Merge branch 'KnpLabs:master' into master
haridarshan 50a0ee1
Merge branch 'master' into master
haridarshan 370927e
Merge branch 'KnpLabs:master' into master
haridarshan 91c8043
chore: change argument of `all` method to `$parameters` array
haridarshan ca94676
chore: fix StyleCi
haridarshan 5ff2a51
chore: minor fix
haridarshan 987a552
Add renovate.json
renovate[bot] 234a7a2
Merge pull request #1 from haridarshan/renovate/configure
haridarshan be15552
Update renovate.json
haridarshan 7483542
Delete renovate.json
haridarshan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Github\Api\Organization\Actions; | ||
|
||
use Github\Api\AbstractApi; | ||
|
||
class SelfHostedRunners extends AbstractApi | ||
{ | ||
/** | ||
* @link https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-organization | ||
* | ||
* @param string $organization | ||
* @param string $type | ||
* @param int $page | ||
* | ||
* @return array|string | ||
*/ | ||
public function all(string $organization, string $type = 'all', int $page = 1) | ||
{ | ||
$parameters = [ | ||
'type' => $type, | ||
'page' => $page, | ||
]; | ||
|
||
return $this->get('/orgs/'.rawurlencode($organization).'/actions/runners', $parameters); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#get-a-self-hosted-runner-for-an-organization | ||
* | ||
* @param string $organization | ||
* @param int $runnerId | ||
* | ||
* @return array|string | ||
*/ | ||
public function show(string $organization, int $runnerId) | ||
{ | ||
return $this->get('/orgs/'.rawurlencode($organization).'/actions/runners/'.$runnerId); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-organization | ||
* | ||
* @param string $organization | ||
* @param int $runnerId | ||
* | ||
* @return array|string | ||
*/ | ||
public function remove(string $organization, int $runnerId) | ||
{ | ||
return $this->delete('/orgs/'.rawurlencode($organization).'/actions/runners/'.$runnerId); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization | ||
* | ||
* @param string $organization | ||
* | ||
* @return array|string | ||
*/ | ||
public function applications(string $organization) | ||
{ | ||
return $this->get('/orgs/'.rawurlencode($organization).'/actions/runners/downloads'); | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
test/Github/Tests/Api/Organization/Actions/SelfHostedRunnersTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
|
||
namespace Github\Tests\Api\Organization\Actions; | ||
|
||
use Github\Api\Organization\Actions\SelfHostedRunners; | ||
use Github\Tests\Api\TestCase; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
|
||
class SelfHostedRunnersTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function shouldGetSelfHostedRunners() | ||
{ | ||
$expectedArray = [ | ||
[ | ||
'id' => 1, | ||
'name' => 'MBP', | ||
'os' => 'macos', | ||
'status' => 'online', | ||
], | ||
[ | ||
'id' => 2, | ||
'name' => 'iMac', | ||
'os' => 'macos', | ||
'status' => 'offline', | ||
], | ||
]; | ||
|
||
/** @var SelfHostedRunners|MockObject $api */ | ||
$api = $this->getApiMock(); | ||
|
||
$api | ||
->expects($this->once()) | ||
->method('get') | ||
->with('/orgs/KnpLabs/actions/runners') | ||
->will($this->returnValue($expectedArray)); | ||
|
||
$this->assertEquals($expectedArray, $api->all('KnpLabs')); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetSelfHostedRunner() | ||
{ | ||
$expectedArray = [ | ||
'id' => 1, | ||
'name' => 'MBP', | ||
'os' => 'macos', | ||
'status' => 'online', | ||
]; | ||
|
||
/** @var SelfHostedRunners|MockObject $api */ | ||
$api = $this->getApiMock(); | ||
|
||
$api | ||
->expects($this->once()) | ||
->method('get') | ||
->with('/orgs/KnpLabs/actions/runners/1') | ||
->will($this->returnValue($expectedArray)); | ||
|
||
$this->assertEquals($expectedArray, $api->show('KnpLabs', 1)); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldRemoveSelfHostedRunner() | ||
{ | ||
$expectedValue = 'response'; | ||
|
||
/** @var SelfHostedRunners|MockObject $api */ | ||
$api = $this->getApiMock(); | ||
|
||
$api | ||
->expects($this->once()) | ||
->method('delete') | ||
->with('/orgs/KnpLabs/actions/runners/1') | ||
->will($this->returnValue($expectedValue)); | ||
|
||
$this->assertEquals($expectedValue, $api->remove('KnpLabs', 1)); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetSelfHostedRunnerApps() | ||
{ | ||
$expectedArray = [ | ||
['os' => 'osx', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'], | ||
['os' => 'linux', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'], | ||
['os' => 'linux', 'architecture' => 'arm', 'download_url' => 'download_url', 'filename' => 'filename'], | ||
['os' => 'win', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'], | ||
['os' => 'linux', 'architecture' => 'arm64', 'download_url' => 'download_url', 'filename' => 'filename'], | ||
]; | ||
|
||
/** @var SelfHostedRunners|MockObject $api */ | ||
$api = $this->getApiMock(); | ||
|
||
$api | ||
->expects($this->once()) | ||
->method('get') | ||
->with('/orgs/KnpLabs/actions/runners/downloads') | ||
->will($this->returnValue($expectedArray)); | ||
|
||
$this->assertEquals($expectedArray, $api->applications('KnpLabs')); | ||
} | ||
|
||
protected function getApiClass() | ||
{ | ||
return SelfHostedRunners::class; | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.