Skip to content

Use GitHub actions for continuous integration (CI) #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +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
/travis-init.sh export-ignore
/tests/ export-ignore
112 changes: 112 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
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:
- 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: sudo apt-get update && sudo apt-get install libevent-dev
- 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 && 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.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 && 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
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 }}
- 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:
- 8.0
- 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
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
composer.lock
phpunit.xml
vendor
/composer.lock
/phpunit.xml
/vendor/
89 changes: 0 additions & 89 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion tests/AbstractLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ public function testSignalsKeepTheLoopRunning()
$loop->stop();
});

$this->assertRunSlowerThan(1.5);
$this->assertRunSlowerThan(1.4);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/Timer/AbstractTimerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 2ms1ms due to timer inaccuracies)
// 1 invocation should take 5msa 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);
Expand All @@ -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);
});

Expand Down Expand Up @@ -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);
}
}
38 changes: 0 additions & 38 deletions travis-init.sh

This file was deleted.