Skip to content

Commit

Permalink
Add PHP 7.3 to Travis CI build and support EditorConfig (#742)
Browse files Browse the repository at this point in the history
  • Loading branch information
ste93cry authored Jan 22, 2019
1 parent 5ec1fbe commit 7338be3
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 72 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; top-most EditorConfig file
root = true

; Unix-style newlines
[*]
charset = utf-8
end_of_line = LF
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.md]
max_line_length = 80

[COMMIT_EDITMSG]
max_line_length = 0
Empty file removed .gitmodules
Empty file.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tools:
external_code_coverage:
runs: 1
timeout: 600

build:
nodes:
Expand Down
102 changes: 44 additions & 58 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,56 @@
language: php

php:
- 7.1
- 7.2

matrix:
fast_finish: true
allow_failures:
- php: nightly
- 7.1
- 7.2
- 7.3
- nightly

env:
- REMOVE_XDEBUG="0"
- REMOVE_XDEBUG="1"

cache:
directories:
- $HOME/.composer/cache
- dependencies=lowest
- dependencies=highest

before_install:
- if [ "$REMOVE_XDEBUG" = "1" ]; then phpenv config-rm xdebug.ini; fi
matrix:
fast_finish: true
allow_failures:
- php: nightly

install: travis_retry composer install --no-interaction
cache:
directories:
- $HOME/.composer/cache

script:
- composer tests
stages:
- Code style & static analysis
- Test
- Code coverage

jobs:
include:
- stage: Test
php: 7.2
env:
REMOVE_XDEBUG: "0"
COVERAGE: true
script:
- vendor/bin/phpunit --verbose --configuration phpunit.xml.dist --coverage-clover tests/clover.xml
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover tests/clover.xml --revision=$TRAVIS_COMMIT
- php: 7.1
env:
COMPOSER_OPTIONS: "--prefer-lowest"
REMOVE_XDEBUG: "1"
install: travis_retry composer update --no-interaction --prefer-lowest
- php: nightly
allow_failure: true
before_install:
- composer remove --dev friendsofphp/php-cs-fixer
env:
REMOVE_XDEBUG: "0"
- stage: Code style & static analysis
env:
CS-FIXER: true
REMOVE_XDEBUG: "1"
script:
- composer phpcs
- env:
PHPSTAN: true
REMOVE_XDEBUG: "1"
script:
- composer phpstan
include:
- stage: Code style & static analysis
name: PHP CS Fixer
script: composer phpcs
- script: composer phpstan
name: PHPStan
- stage: Code coverage
php: 7.3
env: dependencies=highest
script:
- vendor/bin/phpunit --verbose --coverage-clover=build/logs/clover.xml
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml --revision=$TRAVIS_COMMIT
after_success:
- travis_retry php vendor/bin/php-coveralls --verbose

install:
- if [ "$dependencies" = "lowest" ]; then composer update --no-interaction --prefer-lowest --prefer-dist; fi;
- if [ "$dependencies" = "highest" ]; then composer update --no-interaction --prefer-dist; fi;

notifications:
webhooks:
urls:
- https://zeus.ci/hooks/cf8597c4-ffba-11e7-89c9-0a580a281308/public/provider/travis/webhook
on_success: always
on_failure: always
on_start: always
on_cancel: always
on_error: always
webhooks:
urls:
- https://zeus.ci/hooks/cf8597c4-ffba-11e7-89c9-0a580a281308/public/provider/travis/webhook
on_success: always
on_failure: always
on_start: always
on_cancel: always
on_error: always
4 changes: 2 additions & 2 deletions src/ClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Http\Message\MessageFactory;
use Http\Message\UriFactory;
use Jean85\PrettyVersions;
use Sentry\HttpClient\Authentication\SentryAuth;
use Sentry\HttpClient\Authentication\SentryAuthentication;
use Sentry\Integration\ErrorHandlerIntegration;
use Sentry\Integration\RequestIntegration;
use Sentry\Serializer\RepresentationSerializer;
Expand Down Expand Up @@ -287,7 +287,7 @@ private function createHttpClientInstance(): PluginClient
}

$this->addHttpClientPlugin(new HeaderSetPlugin(['User-Agent' => $this->sdkIdentifier . '/' . $this->getSdkVersion()]));
$this->addHttpClientPlugin(new AuthenticationPlugin(new SentryAuth($this->options, $this->sdkIdentifier, $this->getSdkVersion())));
$this->addHttpClientPlugin(new AuthenticationPlugin(new SentryAuthentication($this->options, $this->sdkIdentifier, $this->getSdkVersion())));
$this->addHttpClientPlugin(new RetryPlugin(['retries' => $this->options->getSendAttempts()]));
$this->addHttpClientPlugin(new ErrorPlugin());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @author Stefano Arlandini <sarlandini@alice.it>
*/
final class SentryAuth implements Authentication
final class SentryAuthentication implements Authentication
{
/**
* @var Options The Sentry client configuration
Expand Down Expand Up @@ -68,6 +68,9 @@ public function authenticate(RequestInterface $request): RequestInterface
$headers[] = $headerKey . '=' . $headerValue;
}

return $request->withHeader('X-Sentry-Auth', 'Sentry ' . implode(', ', $headers));
/** @var RequestInterface $request */
$request = $request->withHeader('X-Sentry-Auth', 'Sentry ' . implode(', ', $headers));

return $request;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\RequestInterface;
use Sentry\Client;
use Sentry\HttpClient\Authentication\SentryAuth;
use Sentry\HttpClient\Authentication\SentryAuthentication;
use Sentry\Options;

/**
* @group time-sensitive
*/
final class SentryAuthTest extends TestCase
final class SentryAuthenticationTest extends TestCase
{
public function testAuthenticate(): void
{
$configuration = new Options(['dsn' => 'http://public:secret@example.com/']);
$authentication = new SentryAuth($configuration, 'sentry.php.test', '1.2.3');
$authentication = new SentryAuthentication($configuration, 'sentry.php.test', '1.2.3');

/** @var RequestInterface|MockObject $request */
$request = $this->getMockBuilder(RequestInterface::class)
Expand Down Expand Up @@ -47,7 +47,7 @@ public function testAuthenticate(): void
public function testAuthenticateWithNoSecretKey(): void
{
$configuration = new Options(['dsn' => 'http://public@example.com/']);
$authentication = new SentryAuth($configuration, 'sentry.php.test', '2.0.0');
$authentication = new SentryAuthentication($configuration, 'sentry.php.test', '2.0.0');

/** @var RequestInterface|MockObject $request */
$request = $this->getMockBuilder(RequestInterface::class)
Expand Down
6 changes: 3 additions & 3 deletions tests/SdkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use function Sentry\addBreadcrumb;
use Sentry\Breadcrumb;
use Sentry\ClientInterface;
use Sentry\State\Hub;
use function Sentry\addBreadcrumb;
use function Sentry\captureEvent;
use function Sentry\captureException;
use function Sentry\captureLastError;
use function Sentry\captureMessage;
use Sentry\ClientInterface;
use function Sentry\configureScope;
use function Sentry\init;
use Sentry\State\Hub;
use function Sentry\withScope;

class SdkTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/AbstractSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public function testSerializeValueResource(bool $serializeAllObjects): void

$this->assertNotFalse($filename, 'Temp file creation failed');

$resource = fopen($filename, 'w');
$resource = fopen($filename, 'wb');

$result = $this->invokeSerialization($serializer, $resource);

Expand Down
2 changes: 1 addition & 1 deletion tests/Util/JSONTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function encodeDataProvider(): array
*/
public function testEncodeThrowsIfValueIsResource(): void
{
$resource = fopen('php://memory', 'r');
$resource = fopen('php://memory', 'rb');

$this->assertNotFalse($resource);

Expand Down

0 comments on commit 7338be3

Please sign in to comment.