Skip to content

Commit 61977fc

Browse files
authored
Merge pull request #230 from clue-labs/github-ci
Use GitHub actions for continuous integration (CI)
2 parents 1a709e2 + fb59661 commit 61977fc

File tree

8 files changed

+126
-142
lines changed

8 files changed

+126
-142
lines changed

.gitattributes

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/.gitattributes export-ignore
2+
/.github/ export-ignore
23
/.gitignore export-ignore
3-
/.travis.yml export-ignore
4-
/examples export-ignore
4+
/examples/ export-ignore
55
/phpunit.xml.dist export-ignore
66
/phpunit.xml.legacy export-ignore
7-
/tests export-ignore
8-
/travis-init.sh export-ignore
7+
/tests/ export-ignore

.github/workflows/ci.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
PHPUnit:
9+
name: PHPUnit (PHP ${{ matrix.php }})
10+
runs-on: ubuntu-18.04 # legacy Ubuntu 18.04 for legacy libevent
11+
strategy:
12+
matrix:
13+
php:
14+
- 8.0
15+
- 7.4
16+
- 7.3
17+
- 7.2
18+
- 7.1
19+
- 7.0
20+
- 5.6
21+
- 5.5
22+
- 5.4
23+
- 5.3
24+
steps:
25+
- uses: actions/checkout@v2
26+
- uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
coverage: xdebug
30+
- run: sudo apt-get update && sudo apt-get install libevent-dev
31+
- name: Install ext-event between PHP 5.4 and PHP 7.x
32+
run: |
33+
echo "yes" | sudo pecl install event
34+
# explicitly enable extensions in php.ini on PHP 5.6+
35+
php -r 'exit((int)(PHP_VERSION_ID >= 50600));' || echo "extension=event.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')"
36+
if: ${{ matrix.php >= 5.4 && matrix.php < 8.0 }}
37+
- name: Install ext-ev on PHP >= 5.4
38+
run: |
39+
echo "yes" | sudo pecl install ev
40+
# explicitly enable extensions in php.ini on PHP 5.6+
41+
php -r 'exit((int)(PHP_VERSION_ID >= 50600));' || echo "extension=ev.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')"
42+
if: ${{ matrix.php >= 5.4 }}
43+
- name: Install ext-uv on PHP 7.x
44+
run: |
45+
sudo add-apt-repository ppa:ondrej/php -y && sudo apt-get update -q && sudo apt-get install libuv1-dev
46+
echo "yes" | sudo pecl install uv-beta
47+
echo "extension=uv.so" >> "$(php -r 'echo php_ini_loaded_file();')"
48+
if: ${{ matrix.php >= 7.0 && matrix.php < 8.0 }}
49+
- name: Install legacy ext-libevent on PHP < 7.0
50+
run: |
51+
curl http://pecl.php.net/get/libevent-0.1.0.tgz | tar -xz
52+
pushd libevent-0.1.0
53+
phpize
54+
./configure
55+
make
56+
sudo make install
57+
popd
58+
echo "extension=libevent.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')"
59+
if: ${{ matrix.php < 7.0 }}
60+
- name: Install legacy ext-libev on PHP < 7.0
61+
run: |
62+
git clone --recursive https://github.com/m4rw3r/php-libev
63+
pushd php-libev
64+
phpize
65+
./configure --with-libev
66+
make
67+
sudo make install
68+
popd
69+
echo "extension=libev.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')"
70+
if: ${{ matrix.php < 7.0 }}
71+
- run: composer install
72+
- run: vendor/bin/phpunit --coverage-text
73+
if: ${{ matrix.php >= 7.3 }}
74+
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
75+
if: ${{ matrix.php < 7.3 }}
76+
77+
PHPUnit-Windows:
78+
name: PHPUnit (PHP ${{ matrix.php }} on Windows)
79+
runs-on: windows-2019
80+
continue-on-error: true
81+
strategy:
82+
matrix:
83+
php:
84+
- 8.0
85+
- 7.4
86+
- 7.3
87+
- 7.2
88+
- 7.1
89+
steps:
90+
- uses: actions/checkout@v2
91+
- uses: shivammathur/setup-php@v2
92+
with:
93+
php-version: ${{ matrix.php }}
94+
coverage: xdebug
95+
extensions: sockets,event # future: add uv-beta (installs, but can not load)
96+
- run: composer install
97+
- run: vendor/bin/phpunit --coverage-text
98+
if: ${{ matrix.php >= 7.3 }}
99+
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
100+
if: ${{ matrix.php < 7.3 }}
101+
102+
PHPUnit-hhvm:
103+
name: PHPUnit (HHVM)
104+
runs-on: ubuntu-18.04
105+
continue-on-error: true
106+
steps:
107+
- uses: actions/checkout@v2
108+
- uses: azjezz/setup-hhvm@v1
109+
with:
110+
version: lts-3.30
111+
- run: hhvm $(which composer) install
112+
- run: hhvm vendor/bin/phpunit

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
composer.lock
2-
phpunit.xml
3-
vendor
1+
/composer.lock
2+
/phpunit.xml
3+
/vendor/

.travis.yml

Lines changed: 0 additions & 89 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# EventLoop Component
22

3-
[![Build Status](https://travis-ci.org/reactphp/event-loop.svg?branch=master)](https://travis-ci.org/reactphp/event-loop)
3+
[![CI status](https://github.com/reactphp/event-loop/workflows/CI/badge.svg)](https://github.com/reactphp/event-loop/actions)
44

55
[ReactPHP](https://reactphp.org/)'s core reactor event loop that libraries can use for evented I/O.
66

@@ -702,7 +702,7 @@ $ composer require react/event-loop:^1.1.1
702702
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
703703

704704
This project aims to run on any platform and thus does not require any PHP
705-
extensions and supports running on legacy PHP 5.3 through current PHP 7+ and
705+
extensions and supports running on legacy PHP 5.3 through current PHP 8+ and
706706
HHVM.
707707
It's *highly recommended to use PHP 7+* for this project.
708708

tests/AbstractLoopTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ public function testSignalsKeepTheLoopRunning()
727727
$loop->stop();
728728
});
729729

730-
$this->assertRunSlowerThan(1.5);
730+
$this->assertRunSlowerThan(1.4);
731731
}
732732

733733
/**

tests/Timer/AbstractTimerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public function testAddTimerWillBeInvokedOnceAndBlocksLoopWhenRunning()
2626
{
2727
$loop = $this->createLoop();
2828

29-
$loop->addTimer(0.002, $this->expectCallableOnce());
29+
$loop->addTimer(0.005, $this->expectCallableOnce());
3030

3131
$start = microtime(true);
3232
$loop->run();
3333
$end = microtime(true);
3434

35-
// 1 invocation should take 2ms1ms due to timer inaccuracies)
35+
// 1 invocation should take 5msa few milliseconds due to timer inaccuracies)
3636
// make no strict assumptions about time interval, must at least take 1ms
3737
// and should not take longer than 0.1s for slower loops.
3838
$this->assertGreaterThanOrEqual(0.001, $end - $start);
@@ -57,7 +57,7 @@ public function testAddPeriodicTimerWillBeInvokedUntilItIsCancelled()
5757

5858
// make no strict assumptions about actual time interval.
5959
// leave some room to ensure this ticks exactly 3 times.
60-
$loop->addTimer(0.399, function () use ($loop, $periodic) {
60+
$loop->addTimer(0.350, function () use ($loop, $periodic) {
6161
$loop->cancelTimer($periodic);
6262
});
6363

@@ -135,7 +135,7 @@ function () use (&$start) {
135135
$loop->run();
136136
$end = \microtime(true);
137137

138-
// 1ms should be enough even on slow machines
139-
$this->assertLessThan(0.001, $end - $start);
138+
// 1ms should be enough even on slow machines (± 1ms due to timer inaccuracies)
139+
$this->assertLessThan(0.002, $end - $start);
140140
}
141141
}

travis-init.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)