Skip to content

Commit

Permalink
Apply black and isort
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Dec 20, 2024
1 parent c280471 commit 88d21ad
Show file tree
Hide file tree
Showing 40 changed files with 963 additions and 1,015 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[flake8]
ignore = E203, W503, E701
exclude = .git,venv,env
max-line-length = 119
24 changes: 12 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ on:
- '.github/**'
- CHANGELOG.md
- README.md
- CONTRIBUTING.rst
- ../../CONTRIBUTING.md

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

Expand All @@ -38,6 +38,13 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -55,13 +62,6 @@ jobs:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}

- name: Generate versions
uses: HardNorth/github-version-generate@v1
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-latest
with:
Expand Down Expand Up @@ -119,8 +119,8 @@ jobs:
- 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 }}/"`
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 }}
Expand Down
52 changes: 23 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.0.0
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
# Temporary exclude files in which are in charge of offline reporting
- id: pydocstyle
exclude: |
(?x)^(
tests/*|
robotframework_reportportal/result_visitor.py|
robotframework_reportportal/post_report.py|
robotframework_reportportal/time_visitor.py
)
- repo: https://github.com/Lucas-C/pre-commit-hooks-markup
rev: v1.0.1
(?x)^(
tests/.*
)
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: rst-linter
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
- id: black
args: [ 'reportportal_client', 'tests' ]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: flake8
# Temporary exclude files in which are in charge of offline reporting
exclude: |
(?x)^(
robotframework_reportportal/result_visitor.py|
robotframework_reportportal/post_report.py|
robotframework_reportportal/time_visitor.py
)$
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
136 changes: 136 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Contribution

Contributions are highly welcomed and appreciated.

## Contents

- [Feature requests](#feature-requests)
- [Bug reports](#bug-reports)
- [Bug fixes](#bug-fixes)
- [Implement features](#implement-features)
- [Preparing Pull Requests](#preparing-pull-requests)

## Feature requests

We'd also like to hear about your thoughts and suggestions. Feel free to [submit them as issues](https://github.com/reportportal/agent-Python-RobotFramework/issues) and:

* Explain in detail how they should work.
* Keep the scope as narrow as possible. It will make it easier to implement.

## Bug reports

Report bugs for the agent in the [issue tracker](https://github.com/reportportal/agent-Python-RobotFramework/issues).

If you are reporting a new bug, please include:

* Your operating system name and version.
* Python interpreter version, installed libraries, reportportal-client, and agent-Python-RobotFramework version.
* Detailed steps to reproduce the bug.

## Bug fixes

Look through the [GitHub issues for bugs](https://github.com/reportportal/agent-Python-RobotFramework/labels/bug).

If you are going to fix any of existing bugs, assign that bug to yourself and specify preliminary milestones. Talk to [contributors](https://github.com/reportportal/agent-Python-RobotFramework/graphs/contributors) in case you need a consultancy regarding implementation.

## Implement features

Look through the [GitHub issues for enhancements](https://github.com/reportportal/agent-Python-RobotFramework/labels/enhancement).

Talk to [contributors](https://github.com/reportportal/agent-Python-RobotFramework/graphs/contributors) in case you need a consultancy regarding implementation.

## Preparing Pull Requests

What is a "pull request"? It informs the project's core developers about the changes you want to review and merge. Pull requests are stored on [GitHub servers](https://github.com/reportportal/agent-Python-RobotFramework/pulls). Once you send a pull request, we can discuss its potential modifications and even add more commits to it later on. There's an excellent tutorial on how Pull Requests work in the [GitHub Help Center](https://help.github.com/articles/using-pull-requests/).

Here is a simple overview below:

1. Fork the [agent-Python-RobotFramework GitHub repository](https://github.com/reportportal/agent-Python-RobotFramework).

2. Clone your fork locally using [git](https://git-scm.com/) and create a branch:

```sh
$ git clone [email protected]:YOUR_GITHUB_USERNAME/agent-Python-RobotFramework.git
$ cd agent-Python-RobotFramework
# now, create your own branch off the "master":
$ git checkout -b your-bugfix-branch-name
```

If you need some help with Git, follow this quick start guide: https://git.wiki.kernel.org/index.php/QuickStart

3. Install [pre-commit](https://pre-commit.com) and its hook on the agent-Python-RobotFramework repo:

**Note: pre-commit must be installed as admin, as it will not function otherwise**:

```sh
$ pip install --user pre-commit
$ pre-commit install
```

Afterward `pre-commit` will run whenever you commit.

[https://pre-commit.com](https://pre-commit.com) is a framework for managing and maintaining multi-language pre-commit hooks to ensure code-style and code formatting is consistent.

4. Install tox

Tox is used to run all the tests and will automatically set up virtualenvs to run the tests in. (will implicitly use http://www.virtualenv.org/en/latest/):

```sh
$ pip install tox
```

5. Run all the tests

You need to have Python 3.10 available in your system. Now running tests is as simple as issuing this command:

```sh
$ tox -e pep,py310
```

This command will run tests via the "tox" tool against Python 3.10 and also perform code style checks.

6. You can now edit your local working copy and run the tests again as necessary. Please follow PEP-8 recommendations.

You can pass different options to `tox`. For example, to run tests on Python 3.10 and pass options to pytest (e.g. enter pdb on failure) to pytest you can do:

```sh
$ tox -e py310 -- --pdb
```

Or to only run tests in a particular test module on Python 3.10:

```sh
$ tox -e py310 -- tests/test_service.py
```

When committing, `pre-commit` will re-format the files if necessary.

7. If instead of using `tox` you prefer to run the tests directly, then we suggest to create a virtual environment and use an editable installation with the `testing` extra:

```sh
$ python3 -m venv .venv
$ source .venv/bin/activate # Linux
$ .venv/Scripts/activate.bat # Windows
$ pip install -e ".[testing]"
```

Afterwards, you can edit the files and run pytest normally:

```sh
$ pytest tests/test_service.py
```

8. Commit and push once your tests pass and you are happy with your change(s):

```sh
$ git commit -m "<commit message>"
$ git push -u
```

9. Finally, submit a pull request through the GitHub website using this data:

head-fork: YOUR_GITHUB_USERNAME/agent-Python-RobotFramework
compare: your-branch-name

base-fork: reportportal/agent-Python-RobotFramework
base: master
Loading

0 comments on commit 88d21ad

Please sign in to comment.