Skip to content

Commit 8d74cce

Browse files
authored
Simple GitHub Actions to run Autobahn and PHPUnit tests (#19)
* Initial github action ci * Remove older php versions * Only run tests on linux for now * Add IP address to hosts file in docker test runner
1 parent 3cd8de8 commit 8d74cce

File tree

5 files changed

+39
-8
lines changed

5 files changed

+39
-8
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
PHPUnit:
9+
name: PHPUnit (PHP ${{ matrix.php }} on ${{ matrix.os }})
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
os:
14+
- ubuntu-20.04
15+
php:
16+
- 8.0
17+
- 7.4
18+
- 7.3
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php }}
24+
- run: composer install
25+
- run: sh test/ab/run_ab_tests.sh
26+
- run: vendor/bin/phpunit

test/ab/docker_bootstrap.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ set -x
33

44
echo "Running $0"
55

6-
echo Adding "$1 host.ratchet.internal" to /etc/hosts file
6+
echo Adding "$1 host.dock.internal" to /etc/hosts file
77

8-
echo $1 host.ratchet.internal >> /etc/hosts
8+
echo $1 host.dock.internal >> /etc/hosts
99

1010
echo /etc/hosts contains:
1111
cat /etc/hosts

test/ab/fuzzingclient.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
"servers": [
66
{"agent": "RxWebsocketServer/0.0.0",
7-
"url": "ws://host.docker.internal:9001",
7+
"url": "ws://host.dock.internal:9002",
88
"options": {"version": 18}}
99
],
1010
"cases": ["*"],

test/ab/run_ab_tests.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,28 @@ docker run --rm \
1010
sleep 10
1111
php -d memory_limit=256M clientRunner.php
1212

13-
docker stop rxwsfuzzingserver
1413

1514

16-
sleep 5
15+
sleep 10
1716

1817

1918
php -d memory_limit=256M testServer.php &
2019
SERVER_PID=$!
2120
sleep 3
2221

22+
if [ "$RUNNER_OS" = "Linux" ]; then
23+
IPADDR=`hostname -I | cut -f 1 -d ' '`
24+
else
25+
IPADDR=`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | head -1 | tr -d 'adr:'`
26+
fi
27+
2328
docker run --rm \
2429
\
2530
-v ${PWD}:/config \
2631
-v ${PWD}/reports:/reports \
27-
-p 9001:9001 \
2832
--name rxwsfuzzingclient \
29-
crossbario/autobahn-testsuite wstest -m fuzzingclient -s /config/fuzzingclient.json
33+
crossbario/autobahn-testsuite /bin/sh -c "sh /config/docker_bootstrap.sh $IPADDR; wstest -m fuzzingclient -s /config/fuzzingclient.json"
34+
3035
sleep 12
3136

3237
kill $SERVER_PID

test/ab/testServer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
$timerObservable = Observable::timer(1000 * $argv[1]);
1212
}
1313

14-
$server = new \Rx\Websocket\Server("tcp://0.0.0.0:9001", true);
14+
$server = new \Rx\Websocket\Server("tcp://0.0.0.0:9002", true);
1515

1616
$server
1717
->takeUntil($timerObservable)

0 commit comments

Comments
 (0)