Skip to content

Commit

Permalink
Merge pull request #181 from reportportal/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
HardNorth committed Apr 26, 2022
2 parents 1ba5894 + d3853af commit 6fc043d
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 9 deletions.
99 changes: 97 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,121 @@
name: Upload Python Package

on:
release:
types: [published]
push:
branches: ['master']
paths-ignore:
- '.github/**'
- CHANGELOG.md
- README.rst
- CONTRIBUTING.rst

env:
VERSION_FILE: setup.py
VERSION_EXTRACT_PATTERN: >-
__version__\s*=\s*'([^']+)
VERSION_REPLACE_PATTERN: >-
__version__ = '\1'
TMP_SUFFIX: _updated
CHANGE_LOG_FILE: CHANGELOG.md

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Generate versions
uses: HardNorth/github-version-generate@v1.1.2
with:
version-source: file
version-file: ${{ env.VERSION_FILE }}
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }}

- name: Setup git credentials
uses: oleksiyrudenko/gha-git-credentials@v2
with:
name: 'reportportal.io'
email: 'support@reportportal.io'
token: ${{ secrets.GITHUB_TOKEN }}

- name: Tagging new version
id: newVersionTag
run: |
git tag -a ${{ env.RELEASE_VERSION }} -m "Release ${{ env.RELEASE_VERSION }}"
git push --tags
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.6'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Update CHANGELOG.md
id: changelogUpdate
run: |
sed '/\[Unreleased\]/q' ${{ env.CHANGE_LOG_FILE }} >> ${{ env.CHANGE_LOG_FILE }}${{ env.TMP_SUFFIX }}
sed -E '1,/#?#\s*\[Unreleased\]/d' ${{ env.CHANGE_LOG_FILE }} | sed -E '/#?#\s*\[/q' | \
{ echo -e '\n## [${{ env.RELEASE_VERSION }}]'; sed '$d'; } >> ${{ env.CHANGE_LOG_FILE }}${{ env.TMP_SUFFIX }}
grep -E '#?#\s*\[[0-9]' ${{ env.CHANGE_LOG_FILE }} | head -n1 >> ${{ env.CHANGE_LOG_FILE }}${{ env.TMP_SUFFIX }}
sed -E '1,/#?#\s*\[[0-9]/d' ${{ env.CHANGE_LOG_FILE }} >> ${{ env.CHANGE_LOG_FILE }}${{ env.TMP_SUFFIX }}
rm ${{ env.CHANGE_LOG_FILE }}
mv ${{ env.CHANGE_LOG_FILE }}${{ env.TMP_SUFFIX }} ${{ env.CHANGE_LOG_FILE }}
git add ${{ env.CHANGE_LOG_FILE }}
git commit -m "Changelog update"
git push
- name: Read changelog Entry
id: readChangelogEntry
uses: mindsers/changelog-reader-action@v1.3.1
with:
version: ${{ env.RELEASE_VERSION }}
path: ./${{ env.CHANGE_LOG_FILE }}

- name: Create Release
id: createRelease
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
release_name: Release ${{ env.RELEASE_VERSION }}
body: ${{ steps.readChangelogEntry.outputs.log_entry }}
draft: false
prerelease: false

- name: Checkout develop branch
uses: actions/checkout@v2
with:
ref: 'develop'
fetch-depth: 0

- name: Merge release branch into develop
id: mergeIntoDevelop
run: |
git merge -m 'Merge master branch into develop after a release' origin/master
git status | (! grep -Fq 'both modified:') || git status | grep -F 'both modified:' \
| { echo -e 'Unable to merge master into develop, merge conflicts:'; (! grep -Eo '[^ ]+$') }
- name: Update version file
id: versionFileUpdate
run: |
export CURRENT_VERSION_VALUE=`echo '${{ env.CURRENT_VERSION }}' | sed -E 's/(.*)/${{ env.VERSION_REPLACE_PATTERN }}/'`
export NEXT_VERSION_VALUE=`echo '${{ env.NEXT_VERSION }}' | sed -E 's/(.*)/${{ env.VERSION_REPLACE_PATTERN }}/'`
sed "s/${CURRENT_VERSION_VALUE}/${NEXT_VERSION_VALUE}/g" ${{ env.VERSION_FILE }} > ${{ env.VERSION_FILE }}${{ env.TMP_SUFFIX }}
rm ${{ env.VERSION_FILE }}
mv ${{ env.VERSION_FILE }}${{ env.TMP_SUFFIX }} ${{ env.VERSION_FILE }}
git add ${{ env.VERSION_FILE }}
git commit -m "Version update"
git push origin develop
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## [Unreleased]
### Fixed
- Issue [#180](https://github.com/reportportal/client-Python/issues/180):
logger crash on attachments, by @HardNorth
### Changed
- Log processing does not stop on the first error now.

## [5.2.0]
### Changed
- Client fixes, by @HardNorth
4 changes: 3 additions & 1 deletion reportportal_client/core/rp_file.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""This module contains classes representing RP file object."""

import uuid


class RPFile(object):
"""Class representation for a file that will be attached to the log."""
Expand All @@ -20,7 +22,7 @@ def __init__(self,
"""
self.content = content or data
self.content_type = content_type or mime
self.name = name
self.name = name if name and name.strip() else str(uuid.uuid4())

@property
def payload(self):
Expand Down
3 changes: 1 addition & 2 deletions reportportal_client/core/rp_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import json
import logging
import uuid

from reportportal_client.core.rp_file import RPFile
from reportportal_client.core.rp_issues import Issue
Expand Down Expand Up @@ -440,7 +439,7 @@ def __init__(self, log_reqs):

def __get_file(self, rp_file):
"""Form a tuple for the single file."""
return ('file', (rp_file.name or uuid.uuid4(),
return ('file', (rp_file.name,
rp_file.content,
rp_file.content_type or self.default_content))

Expand Down
1 change: 0 additions & 1 deletion reportportal_client/core/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def _request_process(self, request):
except Exception as err:
logger.exception('[%s] Unknown exception has occurred. Terminating'
' the worker.', err)
self.stop_immediate()
self._queue.task_done()

def _stop(self):
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import setup, find_packages

__version__ = '5.2.0'
__version__ = '5.2.1'

with open('requirements.txt') as f:
requirements = f.read().splitlines()
Expand All @@ -20,10 +20,11 @@
keywords=['testing', 'reporting', 'reportportal'],
classifiers=[
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8'
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10'
],
install_requires=requirements
)
32 changes: 32 additions & 0 deletions tests/logs/test_rp_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2022 https://reportportal.io .
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

import pytest

from reportportal_client.core.rp_file import RPFile


@pytest.mark.parametrize(
['name'],
[
[''],
[None],
[' ']
]
)
def test_rp_file_name_should_not_be_empty(name):
file = RPFile(name, '{"test": true}', 'application/json')

payload = file.payload
assert payload['name']
assert len(payload['name']) > 10

0 comments on commit 6fc043d

Please sign in to comment.