From 2f5e3c9be55584cc2e4a0b620b973f963d6a1767 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Tue, 9 Feb 2021 12:04:45 +0100 Subject: [PATCH 1/2] Use GitHub actions for continuous integration (CI) Bye bye Travis CI, you've served us well. --- .gitattributes | 6 ++-- .github/workflows/ci.yml | 61 ++++++++++++++++++++++++++++++++ .gitignore | 4 +-- .travis.yml | 37 ------------------- README.md | 2 +- tests/FunctionalInternetTest.php | 4 +-- 6 files changed, 69 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.gitattributes b/.gitattributes index 64ab6e0..fc0be87 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,7 @@ /.gitattributes export-ignore +/.github/ export-ignore /.gitignore export-ignore -/.travis.yml export-ignore -/examples export-ignore +/examples/ export-ignore /phpunit.xml.dist export-ignore /phpunit.xml.legacy export-ignore -/tests export-ignore +/tests/ export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..366d72a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +name: CI + +on: + push: + pull_request: + +jobs: + PHPUnit: + name: PHPUnit (PHP ${{ matrix.php }}) + runs-on: ubuntu-20.04 + strategy: + matrix: + php: + - 7.4 + - 7.3 + - 7.2 + - 7.1 + - 7.0 + - 5.6 + - 5.5 + - 5.4 + - 5.3 + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: xdebug + - run: composer install + - run: vendor/bin/phpunit --coverage-text + if: ${{ matrix.php >= 7.3 }} + - run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy + if: ${{ matrix.php < 7.3 }} + - run: time php examples/91-benchmark-throughput.php + + PHPUnit-macOS: + name: PHPUnit (macOS) + runs-on: macos-10.15 + continue-on-error: true + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + coverage: xdebug + - run: composer install + - run: vendor/bin/phpunit --coverage-text + - run: time php examples/91-benchmark-throughput.php + + PHPUnit-hhvm: + name: PHPUnit (HHVM) + runs-on: ubuntu-18.04 + continue-on-error: true + steps: + - uses: actions/checkout@v2 + - uses: azjezz/setup-hhvm@v1 + with: + version: lts-3.30 + - run: hhvm $(which composer) install + - run: hhvm vendor/bin/phpunit + - run: time php examples/91-benchmark-throughput.php diff --git a/.gitignore b/.gitignore index 987e2a2..c8153b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -composer.lock -vendor +/composer.lock +/vendor/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a2498b1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -language: php - -# lock distro so new future defaults will not break the build -dist: trusty - -jobs: - include: - - php: 5.3 - dist: precise - - php: 5.4 - - php: 5.5 - - php: 5.6 - - php: 7.0 - - php: 7.1 - - php: 7.2 - - php: 7.3 - - php: 7.4 - - php: hhvm-3.18 - install: - - composer require phpunit/phpunit:^5 --dev --no-interaction # requires legacy phpunit - - name: Mac OS X - os: osx - language: generic - before_install: - - curl -s http://getcomposer.org/installer | php - - mv composer.phar /usr/local/bin/composer - allow_failures: - - php: hhvm-3.18 - - os: osx - -install: - - composer install - -script: - - if [[ "$TRAVIS_PHP_VERSION" > "7.2" ]]; then vendor/bin/phpunit --coverage-text; fi - - if [[ "$TRAVIS_PHP_VERSION" < "7.3" ]]; then vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy; fi - - time php examples/91-benchmark-throughput.php diff --git a/README.md b/README.md index c79bacf..2ec6219 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Stream -[![Build Status](https://travis-ci.org/reactphp/stream.svg?branch=master)](https://travis-ci.org/reactphp/stream) +[![CI status](https://github.com/reactphp/stream/workflows/CI/badge.svg)](https://github.com/reactphp/stream/actions) Event-driven readable and writable streams for non-blocking I/O in [ReactPHP](https://reactphp.org/). diff --git a/tests/FunctionalInternetTest.php b/tests/FunctionalInternetTest.php index f27c5f9..4f07537 100644 --- a/tests/FunctionalInternetTest.php +++ b/tests/FunctionalInternetTest.php @@ -59,7 +59,7 @@ public function testUploadBiggerBlockPlain() public function testUploadKilobyteSecure() { $size = 1000; - $stream = stream_socket_client('tls://httpbin.org:443'); + $stream = stream_socket_client('ssl://httpbin.org:443'); $loop = Factory::create(); $stream = new DuplexResourceStream($stream, $loop); @@ -85,7 +85,7 @@ public function testUploadBiggerBlockSecure() // a bit to trigger different behavior on Linux vs Mac OS X. $size = 136 * 1000; - $stream = stream_socket_client('tls://httpbin.org:443'); + $stream = stream_socket_client('ssl://httpbin.org:443'); // PHP < 7.1.4 (and PHP < 7.0.18) suffers from a bug when writing big // chunks of data over TLS streams at once. From fb4cf1167f54f55541e41b94b12a46133f837d6f Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Tue, 9 Feb 2021 13:57:51 +0100 Subject: [PATCH 2/2] Support PHP 8 --- .github/workflows/ci.yml | 3 ++- README.md | 2 +- tests/TestCase.php | 11 +++++++++++ tests/WritableResourceStreamTest.php | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 366d72a..dc9cf4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ jobs: strategy: matrix: php: + - 8.0 - 7.4 - 7.3 - 7.2 @@ -41,7 +42,7 @@ jobs: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.0 coverage: xdebug - run: composer install - run: vendor/bin/phpunit --coverage-text diff --git a/README.md b/README.md index 2ec6219..a0f3ebb 100644 --- a/README.md +++ b/README.md @@ -1185,7 +1185,7 @@ $ composer require react/stream:^1.1.1 See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. This project aims to run on any platform and thus does not require any PHP -extensions and supports running on legacy PHP 5.3 through current PHP 7+ and HHVM. +extensions and supports running on legacy PHP 5.3 through current PHP 8+ and HHVM. It's *highly recommended to use PHP 7+* for this project due to its vast performance improvements. diff --git a/tests/TestCase.php b/tests/TestCase.php index 7bef2f5..af07e3e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -86,4 +86,15 @@ public function assertContainsStringIgnoringCase($needle, $haystack) $this->assertContains($needle, $haystack, '', true); } } + + public function assertSameIgnoringCase($expected, $actual) + { + if (method_exists($this, 'assertEqualsIgnoringCase')) { + // PHPUnit 7.5+ + $this->assertEqualsIgnoringCase($expected, $actual); + } else { + // legacy PHPUnit 4 - PHPUnit 7.5 + $this->assertSame($expected, $actual); + } + } } diff --git a/tests/WritableResourceStreamTest.php b/tests/WritableResourceStreamTest.php index 7b36418..f0a3b42 100644 --- a/tests/WritableResourceStreamTest.php +++ b/tests/WritableResourceStreamTest.php @@ -485,7 +485,7 @@ public function testWritingToClosedStream() $buffer->handleWrite(); $this->assertInstanceOf('Exception', $error); - $this->assertSame('Unable to write to stream: fwrite(): send of 3 bytes failed with errno=32 Broken pipe', $error->getMessage()); + $this->assertSameIgnoringCase('Unable to write to stream: fwrite(): send of 3 bytes failed with errno=32 Broken pipe', $error->getMessage()); } private function createWriteableLoopMock()