Skip to content

Commit 0c686f2

Browse files
Use patch rather than sed to patch reportportal/basic
1 parent 574d06b commit 0c686f2

4 files changed

Lines changed: 47 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
# ReportPortal agent only works for PHP 7.1, 7.2, 7.3 and 7.4
6464
#if: github.ref_name == 'main' && vars.REPORT_PORTAL_ENABLED == 'true' && contains(fromJson('["7.1", "7.2", "7.3", "7.4"]'), matrix.php)
6565
if: vars.REPORT_PORTAL_ENABLED == 'true' && contains(fromJson('["7.1", "7.2", "7.3", "7.4"]'), matrix.php)
66-
run: ./tests/reportportal_conf.sh
66+
run: ./tests/reportportal/reportportal_conf.sh
6767
env:
6868
REPORT_PORTAL_API_KEY: ${{ secrets.REPORT_PORTAL_API_KEY }}
6969
REPORT_PORTAL_ENDPOINT: ${{ vars.REPORT_PORTAL_ENDPOINT }}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
312c312
2+
< $result = self::$client->post('v1/' . self::$projectName . '/launch', array(
3+
---
4+
> $result = self::$client->post('v2/' . self::$projectName . '/launch', array(
5+
337c337
6+
< $result = self::$client->put('v1/' . self::$projectName . '/launch/' . self::$launchID . '/finish', array(
7+
---
8+
> $result = self::$client->put('v2/' . self::$projectName . '/launch/' . self::$launchID . '/finish', array(
9+
358c358
10+
< $result = self::$client->put('v1/' . self::$projectName . '/launch/' . self::$launchID . '/stop', array(
11+
---
12+
> $result = self::$client->put('v2/' . self::$projectName . '/launch/' . self::$launchID . '/stop', array(
13+
383c383
14+
< $result = self::$client->post('v1/' . self::$projectName . '/item', array(
15+
---
16+
> $result = self::$client->post('v2/' . self::$projectName . '/item', array(
17+
425c425
18+
< $result = self::$client->post('v1/' . self::$projectName . '/log', array(
19+
---
20+
> $result = self::$client->post('v2/' . self::$projectName . '/log', array(
21+
478c478
22+
< 'v1/' . self::$projectName . '/log',
23+
---
24+
> 'v2/' . self::$projectName . '/log',
25+
500c500
26+
< $result = self::$client->put('v1/' . self::$projectName . '/item/' . $itemID, array(
27+
---
28+
> $result = self::$client->put('v2/' . self::$projectName . '/item/' . $itemID, array(
29+
507c507,508
30+
< 'status' => $status
31+
---
32+
> 'status' => $status,
33+
> 'launchUuid' => self::$launchID
34+
544c545
35+
< $result = self::$client->post('v1/' . self::$projectName . '/item/' . $parentItemID, array(
36+
---
37+
> $result = self::$client->post('v2/' . self::$projectName . '/item/' . $parentItemID, array(
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ if [ -z "$REPORT_PORTAL_API_KEY" ] || [ -z "$REPORT_PORTAL_ENDPOINT" ]; then
66
exit 1
77
fi
88

9-
# Remove /api/v1 from REPORT_PORTAL_ENDPOINT (reportportal/agent-php-PHPUnit requires only host)
10-
export REPORT_PORTAL_HOST=${REPORT_PORTAL_ENDPOINT/\/api\/v1/}
9+
# Remove /api/v1 or api/v2 from REPORT_PORTAL_ENDPOINT (reportportal/agent-php-PHPUnit requires only host)
10+
export REPORT_PORTAL_HOST=${REPORT_PORTAL_ENDPOINT/\/api\/v[12]/}
1111

1212
# Add secrets values in tests/reportportal_phpunit_conf_template.xml
13-
# Following environment variables are required:
13+
# Following environment variables are used:
1414
# REPORT_PORTAL_API_KEY
1515
# REPORT_PORTAL_HOST
1616
# PHP_VERSION
17-
envsubst < tests/reportportal_phpunit_conf_template.xml > tests/reportportal_phpunit_conf.xml
17+
envsubst < tests/reportportal/reportportal_phpunit_conf_template.xml > tests/reportportal/reportportal_phpunit_conf.xml
1818

1919
# Add conf for ReportPortal extension in phpunit.ci.xml
2020
# Inserts content of file tests/reportportal_phpunit_conf.xml before </phpunit> end tag in phpunit.ci.xml
21-
sed -i $'/<\/phpunit>/{e cat tests/reportportal_phpunit_conf.xml\n}' phpunit.ci.xml
21+
sed -i $'/<\/phpunit>/{e cat tests/reportportal/reportportal_phpunit_conf.xml\n}' phpunit.ci.xml
2222

2323
# Add ReportPortal extension to composer.json
2424
# 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
2727
composer require --dev reportportal/phpunit
2828

2929
# Patch reportportal/basic to make it compatible with api/v2
30-
# Use api/v2 instead of api/v1 (hardcoded in reportportal/basic)
31-
sed -i 's/v1\//v2\//g' vendor/reportportal/basic/src/service/ReportPortalHTTPService.php
32-
# Add launchUuid to finishItem method in reportportal/basic to make it compatible with api/v2
33-
sed -i "/function finishItem/,/}/s/\('status' => \$status\)/\1,\n'launchUuid' => self::\$launchID/" vendor/reportportal/basic/src/service/ReportPortalHTTPService.php
30+
# Patch content:
31+
# * Replace api/v1 (hardcoded in reportportal/basic) by api/v2
32+
# * Add launchUuid to finishItem method (otherwise all tests will be marked as "interrupted")
33+
patch vendor/reportportal/basic/src/service/ReportPortalHTTPService.php tests/reportportal/ReportPortalHTTPService.php.patch
File renamed without changes.

0 commit comments

Comments
 (0)