Skip to content

Commit ea98734

Browse files
committed
Merge branch '2.x'
* 2.x: Fix bc break in check api class Switch CI setup from travisci to github actions Adding GitHub authentication to GraphQL documentation bug #915 Fix call to test a webhook method (morrislaptop) Remove antiope preview header as checks api is now stable
2 parents b8dffe4 + b79d090 commit ea98734

File tree

6 files changed

+69
-55
lines changed

6 files changed

+69
-55
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
[push, pull_request]
5+
6+
jobs:
7+
test:
8+
name: Test on ${{ matrix.php-versions }} PHP
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
matrix:
13+
php-versions: ['7.1', '7.2', '7.3', '7.4']
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: ${{ matrix.php-versions }}
22+
coverage: xdebug
23+
24+
- name: Install Composer Dependencies
25+
uses: ramsey/composer-install@v1
26+
27+
- name: Run phpunit
28+
run: vendor/bin/phpunit --verbose --coverage-text
29+
30+
roave_bc_check:
31+
name: Roave BC Check
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v2
35+
36+
- name: Roave BC Check
37+
uses: docker://nyholm/roave-bc-check-ga
38+
39+
phpstan:
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- uses: actions/checkout@v2
44+
45+
- uses: shivammathur/setup-php@v2
46+
with:
47+
php-version: 7.1
48+
49+
- name: Install Composer Dependencies
50+
uses: ramsey/composer-install@v1
51+
52+
- name: Run phpstan
53+
run: vendor/bin/phpstan analyse --no-progress

.travis.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

doc/graphql.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ Wraps [GitHub v4 API (GraphQL API)](http://developer.github.com/v4/).
99
$rateLimits = $client->api('graphql')->execute($query);
1010
```
1111

12+
#### Authentication
13+
14+
To use [GitHub v4 API (GraphQL API)](http://developer.github.com/v4/) requests must [authenticated]((../security.md)).
15+
16+
```php
17+
$client->authenticate($token, null, Github\Client::AUTH_ACCESS_TOKEN);
18+
19+
$result = $client->api('graphql')->execute($query);
20+
```
21+
1222
#### Use variables
1323

1424
[Variables](https://developer.github.com/v4/guides/forming-calls/#working-with-variables) allow specifying of requested data without dynamical change of a query on a client side.
@@ -28,5 +38,7 @@ $variables = [
2838
'organizationLogin' => 'KnpLabs'
2939
];
3040

41+
$client->authenticate('<your-token>', null, Github\Client::AUTH_ACCESS_TOKEN);
42+
3143
$orgInfo = $client->api('graphql')->execute($query, $variables);
32-
```
44+
```

lib/Github/Api/Repository/Checks.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
class Checks extends AbstractApi
1515
{
16+
// NEXT_MAJOR: remove trait use.
1617
use AcceptHeaderTrait;
1718

1819
/**
@@ -32,9 +33,6 @@ public function create($username, $repository, array $params = [])
3233
throw new MissingArgumentException(['name', 'head_sha']);
3334
}
3435

35-
// This api is in preview mode, so set the correct accept-header.
36-
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
37-
3836
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs', $params);
3937
}
4038

@@ -50,9 +48,6 @@ public function create($username, $repository, array $params = [])
5048
*/
5149
public function update($username, $repository, $checkRunId, array $params = [])
5250
{
53-
// This api is in preview mode, so set the correct accept-header.
54-
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
55-
5651
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.rawurlencode($checkRunId), $params);
5752
}
5853

@@ -68,9 +63,6 @@ public function update($username, $repository, $checkRunId, array $params = [])
6863
*/
6964
public function all($username, $repository, $ref, $params = [])
7065
{
71-
// This api is in preview mode, so set the correct accept-header.
72-
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
73-
7466
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($ref).'/check-runs', $params);
7567
}
7668

@@ -85,9 +77,6 @@ public function all($username, $repository, $ref, $params = [])
8577
*/
8678
public function show($username, $repository, $checkRunId)
8779
{
88-
// This api is in preview mode, so set the correct accept-header.
89-
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
90-
9180
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.rawurlencode($checkRunId));
9281
}
9382

@@ -102,9 +91,6 @@ public function show($username, $repository, $checkRunId)
10291
*/
10392
public function annotations($username, $repository, $checkRunId)
10493
{
105-
// This api is in preview mode, so set the correct accept-header.
106-
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
107-
10894
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.rawurlencode($checkRunId).'/annotations');
10995
}
11096
}

lib/Github/Api/Repository/Hooks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function ping($username, $repository, $id)
4747

4848
public function test($username, $repository, $id)
4949
{
50-
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks/'.rawurlencode($id).'/test');
50+
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks/'.rawurlencode($id).'/tests');
5151
}
5252

5353
public function remove($username, $repository, $id)

test/Github/Tests/Api/Repository/HooksTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function shouldTestHook()
144144
$api = $this->getApiMock();
145145
$api->expects($this->once())
146146
->method('post')
147-
->with('/repos/KnpLabs/php-github-api/hooks/123/test')
147+
->with('/repos/KnpLabs/php-github-api/hooks/123/tests')
148148
->will($this->returnValue($expectedValue));
149149

150150
$this->assertEquals($expectedValue, $api->test('KnpLabs', 'php-github-api', 123));

0 commit comments

Comments
 (0)