Skip to content

Commit 077130e

Browse files
authored
Merge pull request #167 from reportportal/develop
Release
2 parents 643db51 + 32a22cf commit 077130e

18 files changed

+230
-117
lines changed

.github/workflows/release.yml

+13-14
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ jobs:
7575
git tag -a ${{ env.RELEASE_VERSION }} -m "Release ${{ env.RELEASE_VERSION }}"
7676
git push --tags
7777
78+
- name: Checkout develop branch
79+
uses: actions/checkout@v3
80+
with:
81+
ref: 'develop'
82+
fetch-depth: 0
83+
84+
- name: Merge release branch into develop
85+
id: mergeIntoDevelop
86+
run: |
87+
git merge -m 'Merge master branch into develop after a release' origin/master
88+
git status | (! grep -Fq 'both modified:') || git status | grep -F 'both modified:' \
89+
| { echo -e 'Unable to merge master into develop, merge conflicts:'; (! grep -Eo '[^ ]+$') }
90+
7891
- name: Update CHANGELOG.md
7992
id: changelogUpdate
8093
run: |
@@ -87,7 +100,6 @@ jobs:
87100
mv ${{ env.CHANGE_LOG_FILE }}${{ env.TMP_SUFFIX }} ${{ env.CHANGE_LOG_FILE }}
88101
git add ${{ env.CHANGE_LOG_FILE }}
89102
git commit -m "Changelog update"
90-
git push
91103
92104
- name: Read changelog Entry
93105
id: readChangelogEntry
@@ -104,19 +116,6 @@ jobs:
104116
name: Release ${{ env.RELEASE_VERSION }}
105117
body: ${{ steps.readChangelogEntry.outputs.changes }}
106118

107-
- name: Checkout develop branch
108-
uses: actions/checkout@v3
109-
with:
110-
ref: 'develop'
111-
fetch-depth: 0
112-
113-
- name: Merge release branch into develop
114-
id: mergeIntoDevelop
115-
run: |
116-
git merge -m 'Merge master branch into develop after a release' origin/master
117-
git status | (! grep -Fq 'both modified:') || git status | grep -F 'both modified:' \
118-
| { echo -e 'Unable to merge master into develop, merge conflicts:'; (! grep -Eo '[^ ]+$') }
119-
120119
- name: Update version file
121120
id: versionFileUpdate
122121
run: |

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## [Unreleased]
44
### Changed
5+
- Client version updated on [5.3.5](https://github.com/reportportal/client-Python/releases/tag/5.3.5), by @HardNorth
6+
- The Agent publish a warning and does not report anything in case of a missed required variable now, by @HardNorth
7+
- `RP_UUID` configuration parameter was renamed to `RP_API_KEY` to maintain common convention, by @HardNorth
8+
9+
## [5.3.2]
10+
### Changed
511
- Client version updated on [5.3.0](https://github.com/reportportal/client-Python/releases/tag/5.3.0), by @HardNorth
612

713
## [5.3.1]

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ REQUIRED:
5757

5858
```
5959
--listener robotframework_reportportal.listener
60-
--variable RP_UUID:"your_user_uuid"
60+
--variable RP_API_KEY:"your_user_api_key"
6161
--variable RP_ENDPOINT:"your_reportportal_url"
6262
--variable RP_LAUNCH:"launch_name"
6363
--variable RP_PROJECT:"reportportal_project_name"

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ requires = [
33
# sync with setup.py until we discard non-pep-517/518
44
"setuptools>=40.0",
55
"setuptools-scm",
6-
"wheel",
6+
"wheel==0.37.1",
77
]
88
build-backend = "setuptools.build_meta"

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
python-dateutil>=2.8.1
2-
reportportal-client==5.3.0
2+
reportportal-client==5.3.5
33
robotframework
44
six>=1.15.0

robotframework_reportportal/listener.py

+24-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import logging
1818
import os
19+
from functools import wraps
1920
from mimetypes import guess_type
2021

2122
from reportportal_client.helpers import gen_attributes
@@ -29,6 +30,17 @@
2930
logger = logging.getLogger(__name__)
3031

3132

33+
def check_rp_enabled(func):
34+
"""Verify is RP is enabled in config."""
35+
@wraps(func)
36+
def wrap(*args, **kwargs):
37+
if args and isinstance(args[0], listener):
38+
if not args[0].service:
39+
return
40+
func(*args, **kwargs)
41+
return wrap
42+
43+
3244
class listener(object):
3345
"""Robot Framework listener interface for reporting to Report Portal."""
3446

@@ -64,6 +76,7 @@ def current_item(self):
6476
if self._items:
6577
return self._items[-1]
6678

79+
@check_rp_enabled
6780
def log_message(self, message):
6881
"""Send log message to the Report Portal.
6982
@@ -73,6 +86,7 @@ def log_message(self, message):
7386
logger.debug('ReportPortal - Log Message: {0}'.format(message))
7487
self.service.log(message=msg)
7588

89+
@check_rp_enabled
7690
def log_message_with_image(self, msg, image):
7791
"""Send log message to the Report Portal.
7892
@@ -98,12 +112,12 @@ def parent_id(self):
98112
@property
99113
def service(self):
100114
"""Initialize instance of the RobotService."""
101-
if self._service is None:
115+
if self.variables.enabled and self._service is None:
102116
self._service = RobotService()
103117
self._service.init_service(
104118
endpoint=self.variables.endpoint,
105119
project=self.variables.project,
106-
uuid=self.variables.uuid,
120+
api_key=self.variables.api_key,
107121
log_batch_size=self.variables.log_batch_size,
108122
pool_size=self.variables.pool_size,
109123
skipped_issue=self.variables.skipped_issue,
@@ -120,6 +134,7 @@ def variables(self):
120134
self._variables = Variables()
121135
return self._variables
122136

137+
@check_rp_enabled
123138
def start_launch(self, attributes, ts=None):
124139
"""Start a new launch at the Report Portal.
125140
@@ -143,6 +158,7 @@ def start_launch(self, attributes, ts=None):
143158
else:
144159
self.service.rp.launch_id = self.variables.launch_id
145160

161+
@check_rp_enabled
146162
def start_suite(self, name, attributes, ts=None):
147163
"""Start a new test suite at the Report Portal.
148164
@@ -167,6 +183,7 @@ def start_suite(self, name, attributes, ts=None):
167183
suite.rp_item_id = self.service.start_suite(suite=suite, ts=ts)
168184
self._items.append(suite)
169185

186+
@check_rp_enabled
170187
def end_suite(self, _, attributes, ts=None):
171188
"""Finish started test suite at the Report Portal.
172189
@@ -188,6 +205,7 @@ def end_suite(self, _, attributes, ts=None):
188205
'ReportPortal - End Suite: {0}'.format(suite.attributes))
189206
self.service.finish_suite(suite=suite, ts=ts)
190207

208+
@check_rp_enabled
191209
def start_test(self, name, attributes, ts=None):
192210
"""Start a new test case at the Report Portal.
193211
@@ -207,6 +225,7 @@ def start_test(self, name, attributes, ts=None):
207225
test.rp_item_id = self.service.start_test(test=test, ts=ts)
208226
self._items.append(test)
209227

228+
@check_rp_enabled
210229
def end_test(self, _, attributes, ts=None):
211230
"""Finish started test case at the Report Portal.
212231
@@ -224,6 +243,7 @@ def end_test(self, _, attributes, ts=None):
224243
self._finish_current_item()
225244
self.service.finish_test(test=test, ts=ts)
226245

246+
@check_rp_enabled
227247
def start_keyword(self, name, attributes, ts=None):
228248
"""Start a new keyword(test step) at the Report Portal.
229249
@@ -238,6 +258,7 @@ def start_keyword(self, name, attributes, ts=None):
238258
kwd.rp_item_id = self.service.start_keyword(keyword=kwd, ts=ts)
239259
self._items.append(kwd)
240260

261+
@check_rp_enabled
241262
def end_keyword(self, _, attributes, ts=None):
242263
"""Finish started keyword at the Report Portal.
243264
@@ -275,6 +296,7 @@ def xunit_file(self, xunit_path):
275296
message = {'message': 'XUnit result file', 'level': 'INFO'}
276297
self.log_message_with_image(message, xunit_path)
277298

299+
@check_rp_enabled
278300
def close(self):
279301
"""Call service terminate when the whole test execution is done."""
280302
self.service.terminate_service()

robotframework_reportportal/post_report.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
2424
Command-line usage:
2525
26-
post_report --variable RP_UUID:"your_user_uuid"
26+
post_report --variable RP_API_KEY:"your_user_api_key"
2727
--variable RP_ENDPOINT:"your_reportportal_url"
2828
--variable RP_PROJECT:"reportportal_project_name"
2929
[--variable RP_LAUNCH:"launch_name"]

robotframework_reportportal/service.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ def _get_launch_attributes(self, cmd_attrs):
6969
'{}|{}'.format(self.agent_name, self.agent_version))
7070
return attributes + dict_to_payload(system_attributes)
7171

72-
def init_service(self, endpoint, project, uuid, log_batch_size, pool_size,
73-
skipped_issue=True, verify_ssl=True,
72+
def init_service(self, endpoint, project, api_key, log_batch_size,
73+
pool_size, skipped_issue=True, verify_ssl=True,
7474
log_batch_payload_size=MAX_LOG_BATCH_PAYLOAD_SIZE,
7575
launch_id=None):
7676
"""Initialize common Report Portal client.
7777
7878
:param endpoint: Report Portal API endpoint
7979
:param project: Report Portal project
80-
:param uuid: API token
80+
:param api_key: API key
8181
:param log_batch_size: Number of logs to be sent within one
8282
batch
8383
:param pool_size: HTTPAdapter max pool size
@@ -92,12 +92,12 @@ def init_service(self, endpoint, project, uuid, log_batch_size, pool_size,
9292
if self.rp is None:
9393
logger.debug(
9494
'ReportPortal - Init service: '
95-
'endpoint={0}, project={1}, uuid={2}'
96-
.format(endpoint, project, uuid))
95+
'endpoint={0}, project={1}, api_key={2}'
96+
.format(endpoint, project, api_key))
9797
self.rp = RPClient(
9898
endpoint=endpoint,
9999
project=project,
100-
token=uuid,
100+
api_key=api_key,
101101
is_skipped_an_issue=skipped_issue,
102102
log_batch_size=log_batch_size,
103103
retries=True,

robotframework_reportportal/service.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class RobotService:
3535

3636
def _get_launch_attributes(self, cmd_attrs: List) -> List: ...
3737

38-
def init_service(self, endpoint: Text, project: Text, uuid: Text,
38+
def init_service(self, endpoint: Text, project: Text, api_key: Text,
3939
log_batch_size: int, pool_size: int, skipped_issue: bool,
4040
verify_ssl: Union[Text, bool],
4141
log_batch_payload_size: int, launch_id: str) -> None: ...

robotframework_reportportal/variables.py

+36-61
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515

1616
from distutils.util import strtobool
1717
from os import path
18+
from warnings import warn
1819

1920
from reportportal_client.logs.log_manager import MAX_LOG_BATCH_PAYLOAD_SIZE
2021
from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
2122

22-
from .exception import RobotServiceException
23-
2423
# This is a storage for the result visitor
2524
_variables = {}
2625

@@ -43,12 +42,12 @@ class Variables(object):
4342

4443
def __init__(self):
4544
"""Initialize instance attributes."""
46-
self._endpoint = None
47-
self._launch_name = None
45+
self.endpoint = get_variable('RP_ENDPOINT')
46+
self.launch_name = get_variable('RP_LAUNCH')
47+
self.project = get_variable('RP_PROJECT')
48+
4849
self._pabot_pool_id = None
4950
self._pabot_used = None
50-
self._project = None
51-
self._uuid = None
5251
self.attach_log = bool(strtobool(get_variable(
5352
'RP_ATTACH_LOG', default='False')))
5453
self.attach_report = bool(strtobool(get_variable(
@@ -74,33 +73,37 @@ def __init__(self):
7473
"RP_LOG_BATCH_PAYLOAD_SIZE",
7574
default=str(MAX_LOG_BATCH_PAYLOAD_SIZE)))
7675

77-
@property
78-
def endpoint(self):
79-
"""Get Report Portal API endpoint.
80-
81-
:raises: RobotServiceException if it is None
82-
:return: Report Portal API endpoint
83-
"""
84-
self._endpoint = self._endpoint or get_variable('RP_ENDPOINT')
85-
if self._endpoint is None:
86-
raise RobotServiceException(
87-
'Missing parameter RP_ENDPOINT for robot run\n'
88-
'You should pass -v RP_ENDPOINT:<endpoint_value>')
89-
return self._endpoint
90-
91-
@property
92-
def launch_name(self):
93-
"""Get Report Portal launch name.
94-
95-
:raises: RobotServiceException if it is None
96-
:return: Report Portal launch name
97-
"""
98-
self._launch_name = self._launch_name or get_variable('RP_LAUNCH')
99-
if self._launch_name is None:
100-
raise RobotServiceException(
101-
'Missing parameter RP_LAUNCH for robot run\n'
102-
'You should pass -v RP_LAUNCH:<launch_name_value>')
103-
return self._launch_name
76+
self.api_key = get_variable('RP_API_KEY')
77+
if not self.api_key:
78+
token = get_variable('RP_UUID')
79+
if token:
80+
warn(
81+
message="Argument `token` is deprecated since 2.0.4 and "
82+
"will be subject for removing in the next major "
83+
"version. Use `api_key` argument instead.",
84+
category=DeprecationWarning,
85+
stacklevel=2
86+
)
87+
self.api_key = token
88+
else:
89+
warn(
90+
message="Argument `api_key` is `None` or empty string, "
91+
"that's not supposed to happen because Report "
92+
"Portal is usually requires an authorization key. "
93+
"Please check your code.",
94+
category=RuntimeWarning,
95+
stacklevel=2
96+
)
97+
98+
cond = (self.endpoint, self.launch_name, self.project, self.api_key)
99+
self.enabled = all(cond)
100+
if not self.enabled:
101+
warn(
102+
'One or required parameter is missing, Report Portal listener '
103+
'will be disabled. Please check agent documentation.',
104+
RuntimeWarning,
105+
2
106+
)
104107

105108
@property
106109
def pabot_pool_id(self):
@@ -122,34 +125,6 @@ def pabot_used(self):
122125
self._pabot_used = get_variable(name='PABOTLIBURI')
123126
return self._pabot_used
124127

125-
@property
126-
def project(self):
127-
"""Get Report Portal project name.
128-
129-
:raises: RobotServiceException if it is None
130-
:return: Report Portal project name
131-
"""
132-
self._project = self._project or get_variable('RP_PROJECT')
133-
if self._project is None:
134-
raise RobotServiceException(
135-
'Missing parameter RP_PROJECT for robot run\n'
136-
'You should pass -v RP_PROJECT:<project_name_value>')
137-
return self._project
138-
139-
@property
140-
def uuid(self):
141-
"""Get Report Portal API token UUID.
142-
143-
:raises: RobotServiceException if it is None
144-
:return: Report Portal token UUID
145-
"""
146-
self._uuid = self._uuid or get_variable('RP_UUID')
147-
if self._uuid is None:
148-
raise RobotServiceException(
149-
'Missing parameter RP_UUID for robot run\n'
150-
'You should pass -v RP_UUID:<uuid_value>')
151-
return self._uuid
152-
153128
@property
154129
def verify_ssl(self):
155130
"""Get value of the verify_ssl parameter for the client."""

0 commit comments

Comments
 (0)