Skip to content

Commit 4917899

Browse files
authored
Merge pull request #306 from reportportal/develop
Release
2 parents 4eaa3cd + 8b1f1a0 commit 4917899

File tree

7 files changed

+174
-24
lines changed

7 files changed

+174
-24
lines changed

.github/workflows/release.yml

Lines changed: 111 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,119 @@
11
name: Release Pytest agent
22

33
on:
4-
release:
5-
types: [published]
4+
push:
5+
branches: ['master']
6+
paths-ignore:
7+
- '.github/**'
8+
- CHANGELOG.md
9+
- README.rst
10+
- CONTRIBUTING.rst
11+
12+
env:
13+
VERSION_FILE: setup.py
14+
VERSION_EXTRACT_PATTERN: >-
15+
__version__\s*=\s*'([^']+)
16+
VERSION_REPLACE_PATTERN: >-
17+
__version__ = '\1'
18+
TMP_SUFFIX: _updated
19+
CHANGE_LOG_FILE: CHANGELOG.md
620

721
jobs:
822
deploy:
923
runs-on: ubuntu-latest
1024
steps:
11-
- uses: actions/checkout@v2
12-
- name: Set up Python
13-
uses: actions/setup-python@v2
14-
with:
15-
python-version: '3.6'
16-
- name: Install dependencies
17-
run: python -m pip install --upgrade pip setuptools wheel
18-
- name: Build package
19-
run: python setup.py sdist bdist_wheel
20-
- name: Publish package
21-
uses: pypa/gh-action-pypi-publish@release/v1
22-
with:
23-
user: ${{ secrets.PYPI_USERNAME }}
24-
password: ${{ secrets.PYPI_PASSWORD }}
25+
- uses: actions/checkout@v2
26+
27+
- name: Generate versions
28+
uses: HardNorth/[email protected]
29+
with:
30+
version-source: file
31+
version-file: ${{ env.VERSION_FILE }}
32+
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }}
33+
34+
- name: Setup git credentials
35+
uses: oleksiyrudenko/gha-git-credentials@v2
36+
with:
37+
name: 'reportportal.io'
38+
39+
token: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Tagging new version
42+
id: newVersionTag
43+
run: |
44+
git tag -a ${{ env.RELEASE_VERSION }} -m "Release ${{ env.RELEASE_VERSION }}"
45+
git push --tags
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v2
49+
with:
50+
python-version: '3.6'
51+
52+
- name: Install dependencies
53+
run: python -m pip install --upgrade pip setuptools wheel
54+
55+
- name: Build package
56+
run: python setup.py sdist bdist_wheel
57+
58+
- name: Publish package
59+
uses: pypa/gh-action-pypi-publish@release/v1
60+
with:
61+
user: ${{ secrets.PYPI_USERNAME }}
62+
password: ${{ secrets.PYPI_PASSWORD }}
63+
64+
- name: Checkout develop branch
65+
uses: actions/checkout@v2
66+
with:
67+
ref: 'develop'
68+
fetch-depth: 0
69+
70+
- name: Update CHANGELOG.md
71+
id: changelogUpdate
72+
run: |
73+
sed '/\[Unreleased\]/q' ${{ env.CHANGE_LOG_FILE }} >> ${{ env.CHANGE_LOG_FILE }}${{ env.TMP_SUFFIX }}
74+
sed -E '1,/#?#\s*\[Unreleased\]/d' ${{ env.CHANGE_LOG_FILE }} | sed -E '/#?#\s*\[/q' | \
75+
{ echo -e '\n## [${{ env.RELEASE_VERSION }}]'; sed '$d'; } >> ${{ env.CHANGE_LOG_FILE }}${{ env.TMP_SUFFIX }}
76+
grep -E '#?#\s*\[[0-9]' ${{ env.CHANGE_LOG_FILE }} | head -n1 >> ${{ env.CHANGE_LOG_FILE }}${{ env.TMP_SUFFIX }}
77+
sed -E '1,/#?#\s*\[[0-9]/d' ${{ env.CHANGE_LOG_FILE }} >> ${{ env.CHANGE_LOG_FILE }}${{ env.TMP_SUFFIX }}
78+
rm ${{ env.CHANGE_LOG_FILE }}
79+
mv ${{ env.CHANGE_LOG_FILE }}${{ env.TMP_SUFFIX }} ${{ env.CHANGE_LOG_FILE }}
80+
git add ${{ env.CHANGE_LOG_FILE }}
81+
git commit -m "Changelog update"
82+
83+
- name: Read changelog Entry
84+
id: readChangelogEntry
85+
uses: mindsers/[email protected]
86+
with:
87+
version: ${{ env.RELEASE_VERSION }}
88+
path: ./${{ env.CHANGE_LOG_FILE }}
89+
90+
- name: Create Release
91+
id: createRelease
92+
uses: actions/create-release@v1
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
with:
96+
tag_name: ${{ env.RELEASE_VERSION }}
97+
release_name: Release ${{ env.RELEASE_VERSION }}
98+
body: ${{ steps.readChangelogEntry.outputs.log_entry }}
99+
draft: false
100+
prerelease: false
101+
102+
- name: Merge release branch into develop
103+
id: mergeIntoDevelop
104+
run: |
105+
git merge -m 'Merge master branch into develop after a release' origin/master
106+
git status | (! grep -Fq 'both modified:') || git status | grep -F 'both modified:' \
107+
| { echo -e 'Unable to merge master into develop, merge conflicts:'; (! grep -Eo '[^ ]+$') }
108+
109+
- name: Update version file
110+
id: versionFileUpdate
111+
run: |
112+
export CURRENT_VERSION_VALUE=`echo '${{ env.CURRENT_VERSION }}' | sed -E 's/(.*)/${{ env.VERSION_REPLACE_PATTERN }}/'`
113+
export NEXT_VERSION_VALUE=`echo '${{ env.NEXT_VERSION }}' | sed -E 's/(.*)/${{ env.VERSION_REPLACE_PATTERN }}/'`
114+
sed "s/${CURRENT_VERSION_VALUE}/${NEXT_VERSION_VALUE}/g" ${{ env.VERSION_FILE }} > ${{ env.VERSION_FILE }}${{ env.TMP_SUFFIX }}
115+
rm ${{ env.VERSION_FILE }}
116+
mv ${{ env.VERSION_FILE }}${{ env.TMP_SUFFIX }} ${{ env.VERSION_FILE }}
117+
git add ${{ env.VERSION_FILE }}
118+
git commit -m "Version update"
119+
git push

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
10+
python-version: [2.7, 3.6, 3.7, 3.8, 3.9, '3.10']
1111
steps:
1212
- uses: actions/checkout@v2
1313
- name: Set up Python ${{ matrix.python-version }}

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
## [Unreleased]
4+
### Fixed
5+
- Issue [#304](https://github.com/reportportal/agent-python-pytest/issues/304):
6+
SSL certificate flag handling issue, by @HardNorth
7+
8+
## [5.1.0]
9+
### Changed
10+
- Agent complete rewrite, by @HardNorth

pytest_reportportal/config.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""This module contains class that stores RP agent configuration data."""
22

3+
from distutils.util import strtobool
34
from os import getenv
45

56
try:
@@ -64,7 +65,11 @@ def __init__(self, pytest_config):
6465
'true', '1', 'yes', 'y')
6566
self.rp_uuid = getenv('RP_UUID') or self.find_option(pytest_config,
6667
'rp_uuid')
67-
self.rp_verify_ssl = self.find_option(pytest_config, 'rp_verify_ssl')
68+
rp_verify_ssl = self.find_option(pytest_config, 'rp_verify_ssl', True)
69+
try:
70+
self.rp_verify_ssl = bool(strtobool(rp_verify_ssl))
71+
except (ValueError, AttributeError):
72+
self.rp_verify_ssl = rp_verify_ssl
6873

6974
# noinspection PyMethodMayBeStatic
7075
def find_option(self, pytest_config, option_name, default=None):
@@ -85,4 +90,6 @@ def find_option(self, pytest_config, option_name, default=None):
8590
getattr(pytest_config.option, option_name, None) or
8691
pytest_config.getini(option_name)
8792
)
93+
if isinstance(value, bool):
94+
return value
8895
return value if value else default

pytest_reportportal/config.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from _pytest.config import Config as Config
2-
from typing import List, Optional, Text, Union
2+
from typing import List, Optional, Text, Union, Any
33

44
class AgentConfig:
55
rp_rerun: Optional[bool] = ...
@@ -28,8 +28,9 @@ class AgentConfig:
2828
rp_retries: int = ...
2929
rp_skip_connection_test: bool = ...
3030
rp_uuid: Text = ...
31-
rp_verify_ssl: bool = ...
31+
rp_verify_ssl: Union[bool, Text] = ...
3232

3333
def __init__(self, pytest_config: Config) -> None: ...
3434

35-
def find_option(self, pytest_config, param: Text) -> Union[Text, bool, list]: ...
35+
def find_option(self, pytest_config, param: Text,
36+
default: Any = ...) -> Union[Text, bool, list]: ...

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from setuptools import setup
66

77

8-
__version__ = '5.1.0'
8+
__version__ = '5.1.1'
99

1010

1111
def read_file(fname):
@@ -33,10 +33,11 @@ def read_file(fname):
3333
classifiers=[
3434
'Framework :: Pytest',
3535
'Programming Language :: Python :: 2.7',
36-
'Programming Language :: Python :: 3.5',
3736
'Programming Language :: Python :: 3.6',
3837
'Programming Language :: Python :: 3.7',
39-
'Programming Language :: Python :: 3.8'
38+
'Programming Language :: Python :: 3.8',
39+
'Programming Language :: Python :: 3.9',
40+
'Programming Language :: Python :: 3.10'
4041
],
4142
entry_points={
4243
'pytest11': [

tests/unit/test_config.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright (c) 2022 https://reportportal.io .
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# https://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License
13+
14+
import pytest
15+
from pytest_reportportal.config import AgentConfig
16+
17+
18+
@pytest.mark.parametrize(
19+
['verify_ssl', 'expected_result'],
20+
[
21+
('True', True),
22+
('False', False),
23+
('true', True),
24+
('false', False),
25+
(True, True),
26+
(False, False),
27+
('path/to/certificate', 'path/to/certificate'),
28+
(None, True)
29+
]
30+
)
31+
def test_verify_ssl_true(mocked_config, verify_ssl, expected_result):
32+
mocked_config.getini.side_effect = \
33+
lambda x: verify_ssl if x == 'rp_verify_ssl' else None
34+
config = AgentConfig(mocked_config)
35+
36+
assert config.rp_verify_ssl == expected_result

0 commit comments

Comments
 (0)