mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-27 20:11:34 +03:00
Improved run-api-tests.sh script to make it compatible with sh
This commit is contained in:
parent
df70810aa6
commit
bfbeb7b1fb
5 changed files with 25 additions and 22 deletions
1
.github/workflows/ci-tests.yml
vendored
1
.github/workflows/ci-tests.yml
vendored
|
@ -28,7 +28,6 @@ jobs:
|
||||||
php-extensions: openswoole-4.11.1
|
php-extensions: openswoole-4.11.1
|
||||||
extensions-cache-key: tests-extensions-${{ matrix.php-version }}-${{ inputs.test-group }}
|
extensions-cache-key: tests-extensions-${{ matrix.php-version }}-${{ inputs.test-group }}
|
||||||
- run: composer test:${{ inputs.test-group }}:ci
|
- run: composer test:${{ inputs.test-group }}:ci
|
||||||
shell: bash
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
if: ${{ matrix.php-version == '8.1' }}
|
if: ${{ matrix.php-version == '8.1' }}
|
||||||
with:
|
with:
|
||||||
|
|
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
|
@ -49,7 +49,6 @@ jobs:
|
||||||
- run: composer install --no-interaction --prefer-dist
|
- run: composer install --no-interaction --prefer-dist
|
||||||
- run: ./vendor/bin/rr get --location bin/ && chmod +x bin/rr
|
- run: ./vendor/bin/rr get --location bin/ && chmod +x bin/rr
|
||||||
- run: composer test:api:rr
|
- run: composer test:api:rr
|
||||||
shell: bash
|
|
||||||
|
|
||||||
cli-tests:
|
cli-tests:
|
||||||
uses: './.github/workflows/ci-tests.yml'
|
uses: './.github/workflows/ci-tests.yml'
|
||||||
|
|
|
@ -12,26 +12,35 @@ mkdir data/log/api-tests
|
||||||
touch $OUTPUT_LOGS
|
touch $OUTPUT_LOGS
|
||||||
|
|
||||||
# Try to stop server just in case it hanged in last execution
|
# Try to stop server just in case it hanged in last execution
|
||||||
[[ $TEST_RUNTIME == 'openswoole' ]] && vendor/bin/laminas mezzio:swoole:stop
|
if test "$TEST_RUNTIME" == 'openswoole'; then
|
||||||
[[ $TEST_RUNTIME == 'rr' ]] && bin/rr stop -f
|
vendor/bin/laminas mezzio:swoole:stop
|
||||||
|
elif test "$TEST_RUNTIME" == 'rr'; then
|
||||||
|
bin/rr stop -f
|
||||||
|
fi
|
||||||
|
|
||||||
echo 'Starting server...'
|
echo 'Starting server...'
|
||||||
[[ $TEST_RUNTIME == 'openswoole' ]] && vendor/bin/laminas mezzio:swoole:start -d
|
if test "$TEST_RUNTIME" == 'openswoole'; then
|
||||||
[[ $TEST_RUNTIME == 'rr' ]] && bin/rr serve -p -c=config/roadrunner/.rr.dev.yml \
|
vendor/bin/laminas mezzio:swoole:start -d
|
||||||
-o=http.address=0.0.0.0:9999 \
|
elif test "$TEST_RUNTIME" == 'rr'; then
|
||||||
-o=logs.encoding=json \
|
bin/rr serve -p -c=config/roadrunner/.rr.dev.yml \
|
||||||
-o=logs.channels.http.encoding=json \
|
-o=http.address=0.0.0.0:9999 \
|
||||||
-o=logs.channels.server.encoding=json \
|
-o=logs.encoding=json \
|
||||||
-o=logs.output="${PWD}/${OUTPUT_LOGS}" \
|
-o=logs.channels.http.encoding=json \
|
||||||
-o=logs.channels.http.output="${PWD}/${OUTPUT_LOGS}" \
|
-o=logs.channels.server.encoding=json \
|
||||||
-o=logs.channels.server.output="${PWD}/${OUTPUT_LOGS}" &
|
-o=logs.output="${PWD}/${OUTPUT_LOGS}" \
|
||||||
|
-o=logs.channels.http.output="${PWD}/${OUTPUT_LOGS}" \
|
||||||
|
-o=logs.channels.server.output="${PWD}/${OUTPUT_LOGS}" &
|
||||||
|
fi
|
||||||
sleep 2 # Let's give the server a couple of seconds to start
|
sleep 2 # Let's give the server a couple of seconds to start
|
||||||
|
|
||||||
vendor/bin/phpunit --order-by=random -c phpunit-api.xml --testdox --colors=always --log-junit=build/coverage-api/junit.xml $*
|
vendor/bin/phpunit --order-by=random -c phpunit-api.xml --testdox --colors=always --log-junit=build/coverage-api/junit.xml $*
|
||||||
testsExitCode=$?
|
testsExitCode=$?
|
||||||
|
|
||||||
[[ $TEST_RUNTIME == 'openswoole' ]] && vendor/bin/laminas mezzio:swoole:stop
|
if test "$TEST_RUNTIME" == 'openswoole'; then
|
||||||
[[ $TEST_RUNTIME == 'rr' ]] && bin/rr stop -c config/roadrunner/.rr.dev.yml -o=http.address=0.0.0.0:9999
|
vendor/bin/laminas mezzio:swoole:stop
|
||||||
|
elif test "$TEST_RUNTIME" == 'rr'; then
|
||||||
|
bin/rr stop -c config/roadrunner/.rr.dev.yml -o=http.address=0.0.0.0:9999
|
||||||
|
fi
|
||||||
|
|
||||||
# Exit this script with the same code as the tests. If tests failed, this script has to fail
|
# Exit this script with the same code as the tests. If tests failed, this script has to fail
|
||||||
exit $testsExitCode
|
exit $testsExitCode
|
||||||
|
|
|
@ -17,8 +17,9 @@ use function Shlinkio\Shlink\Config\swooleIsInstalled;
|
||||||
|
|
||||||
use const PHP_SAPI;
|
use const PHP_SAPI;
|
||||||
|
|
||||||
$enableSwoole = PHP_SAPI === 'cli' && swooleIsInstalled();
|
|
||||||
$isTestEnv = env('APP_ENV') === 'test';
|
$isTestEnv = env('APP_ENV') === 'test';
|
||||||
|
$isRR = env('RR_MODE') !== null;
|
||||||
|
$enableSwoole = PHP_SAPI === 'cli' && ! $isRR && swooleIsInstalled();
|
||||||
|
|
||||||
return (new ConfigAggregator\ConfigAggregator([
|
return (new ConfigAggregator\ConfigAggregator([
|
||||||
! $isTestEnv
|
! $isTestEnv
|
||||||
|
|
7
indocker
7
indocker
|
@ -5,9 +5,4 @@ if ! [[ $(docker ps | grep shlink) ]]; then
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$*" == *"test:api:rr"* ]]; then
|
docker exec -it shlink_swoole /bin/sh -c "$*"
|
||||||
# API tests should be run inside the RoadRunner container when the test runtime is RoadRunner
|
|
||||||
docker exec -it shlink_roadrunner /bin/sh -c "$*"
|
|
||||||
else
|
|
||||||
docker exec -it shlink_swoole /bin/sh -c "$*"
|
|
||||||
fi
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue