forked from php-pm/php-pm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
82 lines (75 loc) · 3.34 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
sudo: false
language: php
php:
- 7.1
- 7.2
- 7.3
install:
- composer validate
- composer install
script:
## Unit test
- ./vendor/bin/phpunit
## Integration test
- mkdir web && echo "Hello" > web/index.html
- bin/ppm start --workers=1 --bridge=StaticBridge --static-directory=web --max-requests=1 -v &
- sleep 5
- bin/ppm status
- curl -v -f "http://127.0.0.1:8080"
- bin/ppm status
- curl -v -f "http://127.0.0.1:8080"
- bin/ppm status
- bin/ppm stop
## Test memory limit
- bin/ppm start --workers=1 --bridge=PHPPM\\Tests\\TestBridge --static-directory=web --memory-limit=5 -v > /tmp/ppmout &
- sleep 5
# Memory limit: Nothing should happen
- curl -f --silent "http://127.0.0.1:8080/test?memory=0" &
- sleep 5
- bash -c 'grep -q "because it reached memory limit of 5" /tmp/ppmout || exit 0'
- bin/ppm status
- sleep 5
# Memory limit: Worker should restart
- curl -f --silent "http://127.0.0.1:8080/test?memory=10" &
- sleep 5
- bash -c 'grep -q "because it reached memory limit of 5" /tmp/ppmout && exit 0'
- bin/ppm status
- bin/ppm stop
## Trigger 502 error by triggering an exit() in the worker
- bin/ppm start --workers=1 --bridge=PHPPM\\Tests\\TestBridge --static-directory=web --max-requests=1 --max-execution-time=15 -v > /tmp/ppmout &
- sleep 5
- bash -c 'if [[ $(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:8080/test?exit_prematurely=1") == "502" ]]; then exit 0; else exit 1; fi'
- bin/ppm status
## Trigger 503 error by tying up the worker and making a second request
- curl -f --silent "http://127.0.0.1:8080/test?sleep=10000" &
- bash -c 'if [[ $(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:8080") == "503" ]]; then exit 0; else exit 1; fi'
- bin/ppm status
## Trigger 504 error by making a sleep request and waiting until the timeout
- bash -c 'if [[ $(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:8080/test?sleep=10000") == "504" ]]; then exit 0; else exit 1; fi'
- bin/ppm status
## Trigger 502 error by making the bridge throw an exception
- bash -c 'if [[ $(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:8080/test?exception=1") == "502" ]]; then exit 0; else exit 1; fi'
- bash -c 'grep -q "An exception was thrown by the bridge. Forcing restart of the worker. The exception was" /tmp/ppmout && exit 0'
- bash -c 'grep -q "This is a very bad exception" /tmp/ppmout && exit 0'
- bash -c 'grep -q "Shutdown function triggered" /tmp/ppmoutshutdownfunc && exit 0'
- bin/ppm status
- bin/ppm stop
matrix:
fast_finish: true
jobs:
include:
- stage: lint
php: 7.3
install:
- rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
- composer require "phpstan/phpstan" "friendsofphp/php-cs-fixer:^2.8"
script:
# Static analyzer check
- ./vendor/bin/phpstan analyze -c .phpstan.neon --level=4 --no-progress src
# Check the code style
- IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${TRAVIS_COMMIT_RANGE}")); unset IFS
- ./vendor/bin/php-cs-fixer fix --config=.php_cs.php -v --dry-run --diff --stop-on-violation --using-cache=no --path-mode=intersection -- "${COMMIT_SCA_FILES[@]}"
# Cache package sources
cache:
directories:
- $HOME/.composer/cache