diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 48cc56ef..440ca0b2 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -14,6 +14,8 @@ jobs: strategy: matrix: php-version: ['8.2', '8.3'] + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # rr get-binary picks this env automatically steps: - uses: actions/checkout@v4 - name: Start postgres database server @@ -27,6 +29,9 @@ jobs: php-version: ${{ matrix.php-version }} php-extensions: openswoole-22.1.2 extensions-cache-key: tests-extensions-${{ matrix.php-version }}-${{ inputs.test-group }} + - name: Download RoadRunner binary + if: ${{ inputs.test-group == 'api' }} + run: ./vendor/bin/rr get --no-interaction --no-config --location bin/ && chmod +x bin/rr - run: composer test:${{ inputs.test-group }}:ci - uses: actions/upload-artifact@v4 if: ${{ matrix.php-version == '8.2' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6b08e29..016daf0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,28 +50,26 @@ jobs: with: test-group: cli - openswoole-api-tests: + roadrunner-api-tests: uses: './.github/workflows/ci-tests.yml' with: test-group: api - roadrunner-api-tests: + openswoole-api-tests: runs-on: ubuntu-22.04 strategy: matrix: php-version: ['8.2', '8.3'] - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # rr get-binary picks this env automatically steps: - uses: actions/checkout@v4 - run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_postgres - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} + extensions: openswoole-22.1.2 tools: composer - - run: composer install --no-interaction --prefer-dist --ignore-platform-req=ext-openswoole - - run: ./vendor/bin/rr get --no-interaction --no-config --location bin/ && chmod +x bin/rr - - run: composer test:api:rr + - run: composer install --no-interaction --prefer-dist + - run: composer test:api:openswoole sqlite-db-tests: uses: './.github/workflows/ci-db-tests.yml' diff --git a/.gitignore b/.gitignore index b07b73d1..04c8ed56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ .idea bin/rr -config/roadrunner/.pid +.pid build !docker/build composer.lock diff --git a/.rr.test.yml b/.rr.test.yml new file mode 100644 index 00000000..6925555b --- /dev/null +++ b/.rr.test.yml @@ -0,0 +1,49 @@ +version: '3' + +############################################################################################### +# It's important to keep this file in the project root, otherwise code coverage does not work # +# See https://github.com/orgs/roadrunner-server/discussions/1440#discussioncomment-8486186 # +############################################################################################### + +rpc: + listen: tcp://127.0.0.1:6001 + +server: + command: 'php ./bin/roadrunner-worker.php' + +http: + address: '0.0.0.0:9999' + middleware: ['static'] + static: + dir: './public' + forbid: ['.php', '.htaccess'] + pool: + num_workers: 1 + debug: false + +jobs: + pool: + num_workers: 1 + debug: false + timeout: 300 + consume: ['shlink'] + pipelines: + shlink: + driver: memory + config: + priority: 10 + prefetch: 10 + +logs: + encoding: json + mode: development + channels: + http: + mode: 'off' # Disable logging as Shlink handles it internally + server: + encoding: json + level: info + metrics: + level: panic + jobs: + level: panic diff --git a/bin/test/run-api-tests.sh b/bin/test/run-api-tests.sh index d8ed270a..c90ae041 100755 --- a/bin/test/run-api-tests.sh +++ b/bin/test/run-api-tests.sh @@ -18,13 +18,7 @@ touch $OUTPUT_LOGS echo 'Starting server...' [ "$TEST_RUNTIME" = 'openswoole' ] && vendor/bin/laminas mezzio:swoole:start -d -[ "$TEST_RUNTIME" = 'rr' ] && bin/rr serve -p -c=config/roadrunner/.rr.dev.yml \ - -o=http.address=0.0.0.0:9999 \ - -o=http.pool.debug=false \ - -o=jobs.pool.debug=false \ - -o=logs.encoding=json \ - -o=logs.channels.http.encoding=json \ - -o=logs.channels.server.encoding=json \ +[ "$TEST_RUNTIME" = 'rr' ] && bin/rr serve -p -c=.rr.test.yml \ -o=logs.output="${PWD}/${OUTPUT_LOGS}" \ -o=logs.channels.http.output="${PWD}/${OUTPUT_LOGS}" \ -o=logs.channels.server.output="${PWD}/${OUTPUT_LOGS}" & diff --git a/composer.json b/composer.json index 05767381..dabd4d0c 100644 --- a/composer.json +++ b/composer.json @@ -130,7 +130,7 @@ "test:db:postgres": "DB_DRIVER=postgres composer test:db:sqlite", "test:db:ms": "DB_DRIVER=mssql composer test:db:sqlite", "test:api": "bin/test/run-api-tests.sh", - "test:api:rr": "TEST_RUNTIME=rr bin/test/run-api-tests.sh", + "test:api:openswoole": "TEST_RUNTIME=openswoole bin/test/run-api-tests.sh", "test:api:ci": "GENERATE_COVERAGE=yes composer test:api", "test:api:pretty": "GENERATE_COVERAGE=pretty composer test:api", "test:cli": "APP_ENV=test DB_DRIVER=maria TEST_ENV=cli php vendor/bin/phpunit --order-by=random --colors=always --testdox -c phpunit-cli.xml --log-junit=build/coverage-cli/junit.xml",