From 1854d5dac3e687184ab2e2c75c65728f915991f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Tue, 29 Jun 2021 12:49:45 +0200 Subject: [PATCH 1/4] Use GitHub actions for continuous integration (CI) Bye bye Travis CI, you've served us well. --- .gitattributes | 2 +- .github/workflows/ci.yml | 74 +++++++++++++++++++++++++++++++++ .gitignore | 6 +-- .travis.yml | 89 ---------------------------------------- README.md | 2 +- travis-init.sh | 5 +++ 6 files changed, 84 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.gitattributes b/.gitattributes index ce7c8e68..35ea0de2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,6 @@ /.gitattributes export-ignore +/.github/ export-ignore /.gitignore export-ignore -/.travis.yml export-ignore /examples export-ignore /phpunit.xml.dist export-ignore /phpunit.xml.legacy export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..4ff1a0c3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,74 @@ +name: CI + +on: + push: + pull_request: + +jobs: + PHPUnit: + name: PHPUnit (PHP ${{ matrix.php }}) + runs-on: ubuntu-18.04 # legacy Ubuntu 18.04 for legacy libevent + 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: sudo apt-get update && sudo apt-get install libevent-dev + - run: sudo add-apt-repository ppa:ondrej/php -y && sudo apt-get update -q && sudo apt-get install libuv1-dev + if: ${{ matrix.php >= 5.6 }} + - run: sudo sh -c "TRAVIS_PHP_VERSION=${{ matrix.php }} ./travis-init.sh" + if: ${{ matrix.php != 7.0 }} # exclude flaky PHP 7.0 build + - 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-Windows: + name: PHPUnit (PHP ${{ matrix.php }} on Windows) + runs-on: windows-2019 + continue-on-error: true + strategy: + matrix: + php: + - 7.4 + - 7.3 + - 7.2 + - 7.1 + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: xdebug + extensions: sockets,event # future: add uv-beta (installs, but can not load) + - 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-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 81b92580..5cf9a2cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -composer.lock -phpunit.xml -vendor +/composer.lock +/phpunit.xml +/vendor/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e3ac120a..00000000 --- a/.travis.yml +++ /dev/null @@ -1,89 +0,0 @@ -language: php - -# lock distro so new future defaults will not break the build -dist: xenial - -jobs: - include: - - php: 5.3 - dist: precise - before_install: [] # skip libuv - - php: 5.4 - dist: trusty - before_install: [] # skip libuv - - php: 5.5 - dist: trusty - before_install: [] # skip libuv - - php: 5.6 - - php: 7.0 - - php: 7.1 - - php: 7.2 - - php: 7.3 - - php: 7.4 - - php: hhvm-3.18 - dist: trusty - before_install: [] # skip libuv - install: - - composer install # skip ./travis-init.sh - - name: "Windows" - os: windows - language: shell # no built-in php support - before_install: - - choco install php - - choco install composer - - export PATH="$(powershell -Command '("Process", "Machine" | % { [Environment]::GetEnvironmentVariable("PATH", $_) -Split ";" -Replace "\\$", "" } | Select -Unique | % { cygpath $_ }) -Join ":"')" - install: - - composer install - - name: "Windows PHP 7.2 with ext-event" - os: windows - language: shell # no built-in php support - before_install: - - curl -OL https://windows.php.net/downloads/pecl/releases/event/2.5.3/php_event-2.5.3-7.2-nts-vc15-x64.zip # latest version as of 2019-12-23 - - choco install php --version=7.2.26 # latest version supported by ext-event as of 2019-12-23 - - choco install composer - - export PATH="$(powershell -Command '("Process", "Machine" | % { [Environment]::GetEnvironmentVariable("PATH", $_) -Split ";" -Replace "\\$", "" } | Select -Unique | % { cygpath $_ }) -Join ":"')" - - php -r "\$z=new ZipArchive();\$z->open(glob('php_event*.zip')[0]);\$z->extractTo(dirname(php_ini_loaded_file()).'/ext','php_event.dll');" - - 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);" # ext-sockets needs to be loaded before ext-event - - php -r "file_put_contents(php_ini_loaded_file(),'extension=event'.PHP_EOL,FILE_APPEND);" - install: - - composer install - - name: "Windows PHP 7.4 with ext-uv" - os: windows - language: shell # no built-in php support - before_install: - - curl -OL https://windows.php.net/downloads/pecl/releases/uv/0.2.4/php_uv-0.2.4-7.4-nts-vc15-x64.zip # latest version as of 2019-12-23 - - choco install php --version=7.4.0 # latest version supported by ext-uv as of 2019-12-23 - - choco install composer - - export PATH="$(powershell -Command '("Process", "Machine" | % { [Environment]::GetEnvironmentVariable("PATH", $_) -Split ";" -Replace "\\$", "" } | Select -Unique | % { cygpath $_ }) -Join ":"')" - - php -r "\$z=new ZipArchive();\$z->open(glob('php_uv*.zip')[0]);\$z->extractTo(dirname(php_ini_loaded_file()).'/ext','php_uv.dll');\$z->extractTo(dirname(php_ini_loaded_file()),'libuv.dll');" - - 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);" # ext-sockets needs to be loaded before ext-uv - - php -r "file_put_contents(php_ini_loaded_file(),'extension=uv'.PHP_EOL,FILE_APPEND);" - install: - - composer install - allow_failures: - - php: hhvm-3.18 - - os: windows - -addons: - apt: - packages: - - libevent-dev # Used by 'event' and 'libevent' PHP extensions - -cache: - directories: - - $HOME/.composer/cache/files - -before_install: - - sudo add-apt-repository ppa:ondrej/php -y - - sudo apt-get update -q - - sudo apt-get install libuv1-dev - -install: - - ./travis-init.sh - - 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 402309b1..f76b3392 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # EventLoop Component -[![Build Status](https://travis-ci.org/reactphp/event-loop.svg?branch=master)](https://travis-ci.org/reactphp/event-loop) +[![CI status](https://github.com/reactphp/event-loop/workflows/CI/badge.svg)](https://github.com/reactphp/event-loop/actions) [ReactPHP](https://reactphp.org/)'s core reactor event loop that libraries can use for evented I/O. diff --git a/travis-init.sh b/travis-init.sh index 94ec4f36..987f0b1a 100755 --- a/travis-init.sh +++ b/travis-init.sh @@ -6,6 +6,10 @@ set -o pipefail if [[ "$TRAVIS_PHP_VERSION" != "5.3" ]]; then echo "yes" | pecl install event echo "yes" | pecl install ev + if ! [[ "$TRAVIS_PHP_VERSION" < "7.0" ]]; then + echo "extension=event.so" >> "$(php -r 'echo php_ini_loaded_file();')" + echo "extension=ev.so" >> "$(php -r 'echo php_ini_loaded_file();')" + fi fi # install 'libevent' PHP extension on legacy PHP 5 only @@ -35,4 +39,5 @@ fi # install 'libuv' PHP extension on PHP 7+ only if ! [[ "$TRAVIS_PHP_VERSION" < "7.0" ]]; then echo "yes" | pecl install uv-beta + echo "extension=uv.so" >> "$(php -r 'echo php_ini_loaded_file();')" fi From 129d9963d549fdbbad7680e128cf6d9e409fecb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Tue, 29 Jun 2021 13:12:04 +0200 Subject: [PATCH 2/4] Fix failing test cases due to inaccurate timers --- tests/AbstractLoopTest.php | 2 +- tests/Timer/AbstractTimerTest.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/AbstractLoopTest.php b/tests/AbstractLoopTest.php index 292ffd1a..61790882 100644 --- a/tests/AbstractLoopTest.php +++ b/tests/AbstractLoopTest.php @@ -727,7 +727,7 @@ public function testSignalsKeepTheLoopRunning() $loop->stop(); }); - $this->assertRunSlowerThan(1.5); + $this->assertRunSlowerThan(1.4); } /** diff --git a/tests/Timer/AbstractTimerTest.php b/tests/Timer/AbstractTimerTest.php index cd53bd13..c5198385 100644 --- a/tests/Timer/AbstractTimerTest.php +++ b/tests/Timer/AbstractTimerTest.php @@ -26,13 +26,13 @@ public function testAddTimerWillBeInvokedOnceAndBlocksLoopWhenRunning() { $loop = $this->createLoop(); - $loop->addTimer(0.002, $this->expectCallableOnce()); + $loop->addTimer(0.005, $this->expectCallableOnce()); $start = microtime(true); $loop->run(); $end = microtime(true); - // 1 invocation should take 2ms (± 1ms due to timer inaccuracies) + // 1 invocation should take 5ms (± a few milliseconds due to timer inaccuracies) // make no strict assumptions about time interval, must at least take 1ms // and should not take longer than 0.1s for slower loops. $this->assertGreaterThanOrEqual(0.001, $end - $start); @@ -57,7 +57,7 @@ public function testAddPeriodicTimerWillBeInvokedUntilItIsCancelled() // make no strict assumptions about actual time interval. // leave some room to ensure this ticks exactly 3 times. - $loop->addTimer(0.399, function () use ($loop, $periodic) { + $loop->addTimer(0.350, function () use ($loop, $periodic) { $loop->cancelTimer($periodic); }); @@ -135,7 +135,7 @@ function () use (&$start) { $loop->run(); $end = \microtime(true); - // 1ms should be enough even on slow machines - $this->assertLessThan(0.001, $end - $start); + // 1ms should be enough even on slow machines (± 1ms due to timer inaccuracies) + $this->assertLessThan(0.002, $end - $start); } } From 0322d2ce3bd5dfd45bcc7fdab69993d8c5414fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Tue, 29 Jun 2021 14:37:11 +0200 Subject: [PATCH 3/4] Clean up CI config to simplify installing PHP extensions --- .gitattributes | 5 ++--- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++++++++++---- travis-init.sh | 43 --------------------------------------- 3 files changed, 42 insertions(+), 50 deletions(-) delete mode 100755 travis-init.sh diff --git a/.gitattributes b/.gitattributes index 35ea0de2..fc0be872 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,7 @@ /.gitattributes export-ignore /.github/ export-ignore /.gitignore export-ignore -/examples export-ignore +/examples/ export-ignore /phpunit.xml.dist export-ignore /phpunit.xml.legacy export-ignore -/tests export-ignore -/travis-init.sh export-ignore +/tests/ export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ff1a0c3..d3310c44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,10 +27,46 @@ jobs: php-version: ${{ matrix.php }} coverage: xdebug - run: sudo apt-get update && sudo apt-get install libevent-dev - - run: sudo add-apt-repository ppa:ondrej/php -y && sudo apt-get update -q && sudo apt-get install libuv1-dev - if: ${{ matrix.php >= 5.6 }} - - run: sudo sh -c "TRAVIS_PHP_VERSION=${{ matrix.php }} ./travis-init.sh" - if: ${{ matrix.php != 7.0 }} # exclude flaky PHP 7.0 build + - name: Install ext-event on PHP >= 5.4 + run: | + echo "yes" | sudo pecl install event + # explicitly enable extensions in php.ini on PHP 5.6+ + php -r 'exit((int)(PHP_VERSION_ID >= 50600));' || echo "extension=event.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')" + if: ${{ matrix.php >= 5.4 }} + - name: Install ext-ev on PHP >= 5.4 + run: | + echo "yes" | sudo pecl install ev + # explicitly enable extensions in php.ini on PHP 5.6+ + php -r 'exit((int)(PHP_VERSION_ID >= 50600));' || echo "extension=ev.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')" + if: ${{ matrix.php >= 5.4 }} + - name: Install ext-uv on PHP >= 7.0 + run: | + sudo add-apt-repository ppa:ondrej/php -y && sudo apt-get update -q && sudo apt-get install libuv1-dev + echo "yes" | sudo pecl install uv-beta + echo "extension=uv.so" >> "$(php -r 'echo php_ini_loaded_file();')" + if: ${{ matrix.php >= 7.0 }} + - name: Install legacy ext-libevent on PHP < 7.0 + run: | + curl http://pecl.php.net/get/libevent-0.1.0.tgz | tar -xz + pushd libevent-0.1.0 + phpize + ./configure + make + sudo make install + popd + echo "extension=libevent.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')" + if: ${{ matrix.php < 7.0 }} + - name: Install legacy ext-libev on PHP < 7.0 + run: | + git clone --recursive https://github.com/m4rw3r/php-libev + pushd php-libev + phpize + ./configure --with-libev + make + sudo make install + popd + echo "extension=libev.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')" + if: ${{ matrix.php < 7.0 }} - run: composer install - run: vendor/bin/phpunit --coverage-text if: ${{ matrix.php >= 7.3 }} diff --git a/travis-init.sh b/travis-init.sh deleted file mode 100755 index 987f0b1a..00000000 --- a/travis-init.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -set -e -set -o pipefail - -# install 'event' and 'ev' PHP extension on PHP 5.4+ only -if [[ "$TRAVIS_PHP_VERSION" != "5.3" ]]; then - echo "yes" | pecl install event - echo "yes" | pecl install ev - if ! [[ "$TRAVIS_PHP_VERSION" < "7.0" ]]; then - echo "extension=event.so" >> "$(php -r 'echo php_ini_loaded_file();')" - echo "extension=ev.so" >> "$(php -r 'echo php_ini_loaded_file();')" - fi -fi - -# install 'libevent' PHP extension on legacy PHP 5 only -if [[ "$TRAVIS_PHP_VERSION" < "7.0" ]]; then - curl http://pecl.php.net/get/libevent-0.1.0.tgz | tar -xz - pushd libevent-0.1.0 - phpize - ./configure - make - make install - popd - echo "extension=libevent.so" >> "$(php -r 'echo php_ini_loaded_file();')" -fi - -# install 'libev' PHP extension on legacy PHP 5 only -if [[ "$TRAVIS_PHP_VERSION" < "7.0" ]]; then - git clone --recursive https://github.com/m4rw3r/php-libev - pushd php-libev - phpize - ./configure --with-libev - make - make install - popd - echo "extension=libev.so" >> "$(php -r 'echo php_ini_loaded_file();')" -fi - -# install 'libuv' PHP extension on PHP 7+ only -if ! [[ "$TRAVIS_PHP_VERSION" < "7.0" ]]; then - echo "yes" | pecl install uv-beta - echo "extension=uv.so" >> "$(php -r 'echo php_ini_loaded_file();')" -fi From fb5966123661d564a498b97e6ad8e39867b32116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Tue, 29 Jun 2021 15:53:01 +0200 Subject: [PATCH 4/4] Support PHP 8 --- .github/workflows/ci.yml | 10 ++++++---- README.md | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3310c44..92f06ab7 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 @@ -27,24 +28,24 @@ jobs: php-version: ${{ matrix.php }} coverage: xdebug - run: sudo apt-get update && sudo apt-get install libevent-dev - - name: Install ext-event on PHP >= 5.4 + - name: Install ext-event between PHP 5.4 and PHP 7.x run: | echo "yes" | sudo pecl install event # explicitly enable extensions in php.ini on PHP 5.6+ php -r 'exit((int)(PHP_VERSION_ID >= 50600));' || echo "extension=event.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')" - if: ${{ matrix.php >= 5.4 }} + if: ${{ matrix.php >= 5.4 && matrix.php < 8.0 }} - name: Install ext-ev on PHP >= 5.4 run: | echo "yes" | sudo pecl install ev # explicitly enable extensions in php.ini on PHP 5.6+ php -r 'exit((int)(PHP_VERSION_ID >= 50600));' || echo "extension=ev.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')" if: ${{ matrix.php >= 5.4 }} - - name: Install ext-uv on PHP >= 7.0 + - name: Install ext-uv on PHP 7.x run: | sudo add-apt-repository ppa:ondrej/php -y && sudo apt-get update -q && sudo apt-get install libuv1-dev echo "yes" | sudo pecl install uv-beta echo "extension=uv.so" >> "$(php -r 'echo php_ini_loaded_file();')" - if: ${{ matrix.php >= 7.0 }} + if: ${{ matrix.php >= 7.0 && matrix.php < 8.0 }} - name: Install legacy ext-libevent on PHP < 7.0 run: | curl http://pecl.php.net/get/libevent-0.1.0.tgz | tar -xz @@ -80,6 +81,7 @@ jobs: strategy: matrix: php: + - 8.0 - 7.4 - 7.3 - 7.2 diff --git a/README.md b/README.md index f76b3392..853766b2 100644 --- a/README.md +++ b/README.md @@ -702,7 +702,7 @@ $ composer require react/event-loop:^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 +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. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy