diff --git a/.gitattributes b/.gitattributes index 64ab6e0f..fc0be872 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 00000000..1d9d32ab --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,62 @@ +name: CI + +on: + push: + pull_request: + +jobs: + PHPUnit: + name: PHPUnit (PHP ${{ matrix.php }} on ${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-20.04 + - windows-2019 + php: + - 8.0 + - 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 }} + + 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: 8.0 + coverage: xdebug + - run: composer install + - run: vendor/bin/phpunit --coverage-text + + 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 diff --git a/.gitignore b/.gitignore index 987e2a25..c8153b57 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 d1d2b11e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,46 +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 - - name: Mac OS X - os: osx - language: generic - before_install: - - curl -s http://getcomposer.org/installer | php - - mv composer.phar /usr/local/bin/composer - - name: Windows - os: windows - language: bash - before_install: - - choco install php - - choco install composer - - export PATH="$(powershell -Command '("Process", "Machine" | % { [Environment]::GetEnvironmentVariable("PATH", $_) -Split ";" -Replace "\\$", "" } | Select -Unique | % { cygpath $_ }) -Join ":"')" - - php -r "file_put_contents(php_ini_loaded_file(),'extension_dir=ext'.PHP_EOL,FILE_APPEND);" - - php -r "file_put_contents(php_ini_loaded_file(),'extension=sockets'.PHP_EOL,FILE_APPEND);" - install: - - composer install - allow_failures: - - php: hhvm-3.18 - - os: osx - - os: windows - -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 diff --git a/README.md b/README.md index fafc66f8..85d3186b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Socket -[![Build Status](https://travis-ci.org/reactphp/socket.svg?branch=master)](https://travis-ci.org/reactphp/socket) +[![CI status](https://github.com/reactphp/socket/workflows/CI/badge.svg)](https://github.com/reactphp/socket/actions) Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for [ReactPHP](https://reactphp.org/). @@ -1433,7 +1433,7 @@ $ composer require react/socket:^1.6 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, partly due to its vast performance improvements and partly because legacy PHP versions require several workarounds as described below. diff --git a/tests/FunctionalConnectorTest.php b/tests/FunctionalConnectorTest.php index edce03cd..33655926 100644 --- a/tests/FunctionalConnectorTest.php +++ b/tests/FunctionalConnectorTest.php @@ -40,6 +40,10 @@ public function connectionToTcpServerShouldSucceedWithLocalhost() */ public function testConnectTwiceWithoutHappyEyeBallsOnlySendsSingleDnsQueryDueToLocalDnsCache() { + if ((DIRECTORY_SEPARATOR === '\\' && PHP_VERSION_ID < 70000) || defined('HHVM_VERSION')) { + $this->markTestSkipped('Not supported on Windows for PHP versions < 7.0 and legacy HHVM'); + } + $loop = Factory::create(); $socket = stream_socket_server('udp://127.0.0.1:0', $errno, $errstr, STREAM_SERVER_BIND); @@ -77,6 +81,9 @@ public function testConnectTwiceWithoutHappyEyeBallsOnlySendsSingleDnsQueryDueTo */ public function connectionToRemoteTCP4n6ServerShouldResultInOurIP() { + // max_nesting_level was set to 100 for PHP Versions < 5.4 which resulted in failing test for legacy PHP + ini_set('xdebug.max_nesting_level', 256); + $loop = Factory::create(); $connector = new Connector($loop, array('happy_eyeballs' => true)); diff --git a/tests/FunctionalSecureServerTest.php b/tests/FunctionalSecureServerTest.php index 568732f5..58b1cf4d 100644 --- a/tests/FunctionalSecureServerTest.php +++ b/tests/FunctionalSecureServerTest.php @@ -15,7 +15,7 @@ class FunctionalSecureServerTest extends TestCase { - const TIMEOUT = 0.5; + const TIMEOUT = 2; /** * @before @@ -174,7 +174,7 @@ public function testClientUsesTls10WhenCryptoMethodIsExplicitlyConfiguredByClien try { $client = Block\await($promise, $loop, self::TIMEOUT); } catch (\RuntimeException $e) { - if (strpos($e->getMessage(), 'no protocols available') !== false) { + if (strpos($e->getMessage(), 'no protocols available') !== false || strpos($e->getMessage(), 'routines:state_machine:internal error') !== false) { $this->markTestSkipped('TLS v1.0 not available on this system'); } diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index 7ec2047e..71e77b2c 100644 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -101,6 +101,10 @@ public function gettingPlaintextStuffFromEncryptedGoogleShouldNotWork() public function testConnectingFailsIfConnectorUsesInvalidDnsResolverAddress() { + if (PHP_OS === 'Darwin') { + $this->markTestSkipped('Skipped on macOS due to a bug in reactphp/dns (solved in reactphp/dns#171)'); + } + $loop = Factory::create(); $factory = new ResolverFactory(); diff --git a/tests/SecureIntegrationTest.php b/tests/SecureIntegrationTest.php index c55880b6..16d6dc35 100644 --- a/tests/SecureIntegrationTest.php +++ b/tests/SecureIntegrationTest.php @@ -15,7 +15,7 @@ class SecureIntegrationTest extends TestCase { - const TIMEOUT = 0.5; + const TIMEOUT = 2; private $loop; private $server;