diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d50df52..4d886bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: # ReportPortal agent only works for PHP 7.1, 7.2, 7.3 and 7.4 #if: github.ref_name == 'main' && vars.REPORT_PORTAL_ENABLED == 'true' && contains(fromJson('["7.1", "7.2", "7.3", "7.4"]'), matrix.php) if: vars.REPORT_PORTAL_ENABLED == 'true' && contains(fromJson('["7.1", "7.2", "7.3", "7.4"]'), matrix.php) - run: ./tests/reportportal_conf.sh + run: ./tests/reportportal/reportportal_conf.sh env: REPORT_PORTAL_API_KEY: ${{ secrets.REPORT_PORTAL_API_KEY }} REPORT_PORTAL_ENDPOINT: ${{ vars.REPORT_PORTAL_ENDPOINT }} diff --git a/tests/reportportal/ReportPortalHTTPService.php.patch b/tests/reportportal/ReportPortalHTTPService.php.patch new file mode 100644 index 0000000..23bdfdc --- /dev/null +++ b/tests/reportportal/ReportPortalHTTPService.php.patch @@ -0,0 +1,37 @@ +312c312 +< $result = self::$client->post('v1/' . self::$projectName . '/launch', array( +--- +> $result = self::$client->post('v2/' . self::$projectName . '/launch', array( +337c337 +< $result = self::$client->put('v1/' . self::$projectName . '/launch/' . self::$launchID . '/finish', array( +--- +> $result = self::$client->put('v2/' . self::$projectName . '/launch/' . self::$launchID . '/finish', array( +358c358 +< $result = self::$client->put('v1/' . self::$projectName . '/launch/' . self::$launchID . '/stop', array( +--- +> $result = self::$client->put('v2/' . self::$projectName . '/launch/' . self::$launchID . '/stop', array( +383c383 +< $result = self::$client->post('v1/' . self::$projectName . '/item', array( +--- +> $result = self::$client->post('v2/' . self::$projectName . '/item', array( +425c425 +< $result = self::$client->post('v1/' . self::$projectName . '/log', array( +--- +> $result = self::$client->post('v2/' . self::$projectName . '/log', array( +478c478 +< 'v1/' . self::$projectName . '/log', +--- +> 'v2/' . self::$projectName . '/log', +500c500 +< $result = self::$client->put('v1/' . self::$projectName . '/item/' . $itemID, array( +--- +> $result = self::$client->put('v2/' . self::$projectName . '/item/' . $itemID, array( +507c507,508 +< 'status' => $status +--- +> 'status' => $status, +> 'launchUuid' => self::$launchID +544c545 +< $result = self::$client->post('v1/' . self::$projectName . '/item/' . $parentItemID, array( +--- +> $result = self::$client->post('v2/' . self::$projectName . '/item/' . $parentItemID, array( diff --git a/tests/reportportal_conf.sh b/tests/reportportal/reportportal_conf.sh similarity index 57% rename from tests/reportportal_conf.sh rename to tests/reportportal/reportportal_conf.sh index 59d4581..cac1c60 100755 --- a/tests/reportportal_conf.sh +++ b/tests/reportportal/reportportal_conf.sh @@ -6,19 +6,19 @@ if [ -z "$REPORT_PORTAL_API_KEY" ] || [ -z "$REPORT_PORTAL_ENDPOINT" ]; then exit 1 fi -# Remove /api/v1 from REPORT_PORTAL_ENDPOINT (reportportal/agent-php-PHPUnit requires only host) -export REPORT_PORTAL_HOST=${REPORT_PORTAL_ENDPOINT/\/api\/v1/} +# Remove /api/v1 or api/v2 from REPORT_PORTAL_ENDPOINT (reportportal/agent-php-PHPUnit requires only host) +export REPORT_PORTAL_HOST=${REPORT_PORTAL_ENDPOINT/\/api\/v[12]/} # Add secrets values in tests/reportportal_phpunit_conf_template.xml # Following environment variables are required: # REPORT_PORTAL_API_KEY # REPORT_PORTAL_HOST # PHP_VERSION -envsubst < tests/reportportal_phpunit_conf_template.xml > tests/reportportal_phpunit_conf.xml +envsubst < tests/reportportal/reportportal_phpunit_conf_template.xml > tests/reportportal/reportportal_phpunit_conf.xml # Add conf for ReportPortal extension in phpunit.ci.xml # Inserts content of file tests/reportportal_phpunit_conf.xml before end tag in phpunit.ci.xml -sed -i $'/<\/phpunit>/{e cat tests/reportportal_phpunit_conf.xml\n}' phpunit.ci.xml +sed -i $'/<\/phpunit>/{e cat tests/reportportal/reportportal_phpunit_conf.xml\n}' phpunit.ci.xml # Add ReportPortal extension to composer.json # reportportal/phpunit has no stable version, so we set minimum stability to dev only when running tests @@ -27,7 +27,7 @@ composer config minimum-stability dev composer require --dev reportportal/phpunit # Patch reportportal/basic to make it compatible with api/v2 -# Use api/v2 instead of api/v1 (hardcoded in reportportal/basic) -sed -i 's/v1\//v2\//g' vendor/reportportal/basic/src/service/ReportPortalHTTPService.php -# Add launchUuid to finishItem method in reportportal/basic to make it compatible with api/v2 -sed -i "/function finishItem/,/}/s/\('status' => \$status\)/\1,\n'launchUuid' => self::\$launchID/" vendor/reportportal/basic/src/service/ReportPortalHTTPService.php \ No newline at end of file +# Patch content: +# * Replace api/v1 (hardcoded in reportportal/basic) by api/v2 +# * Add launchUuid to finishItem method (otherwise all tests will be marked as "interrupted") +patch vendor/reportportal/basic/src/service/ReportPortalHTTPService.php tests/reportportal/ReportPortalHTTPService.php.patch diff --git a/tests/reportportal_phpunit_conf_template.xml b/tests/reportportal/reportportal_phpunit_conf_template.xml similarity index 100% rename from tests/reportportal_phpunit_conf_template.xml rename to tests/reportportal/reportportal_phpunit_conf_template.xml