forked from TrueCloudLab/frostfs-testcases
Add black formatter and isort into a precommit hook
Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
parent
9eb33465f9
commit
589197ba72
4 changed files with 52 additions and 21 deletions
11
.pre-commit-config.yaml
Normal file
11
.pre-commit-config.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 22.8.0
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
language_version: python3.9
|
||||||
|
- repo: https://github.com/pycqa/isort
|
||||||
|
rev: 5.10.1
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
name: isort (python)
|
50
README.md
50
README.md
|
@ -52,26 +52,34 @@ libssl-dev
|
||||||
As we use neofs-dev-env, you'll also need to install
|
As we use neofs-dev-env, you'll also need to install
|
||||||
[prerequisites](https://github.com/nspcc-dev/neofs-dev-env#prerequisites) of this repository.
|
[prerequisites](https://github.com/nspcc-dev/neofs-dev-env#prerequisites) of this repository.
|
||||||
|
|
||||||
### Run and get report
|
6. Prepare virtualenv
|
||||||
|
|
||||||
1. Prepare virtualenv
|
```shell
|
||||||
|
|
||||||
```
|
|
||||||
$ make venv.local-pytest
|
$ make venv.local-pytest
|
||||||
$ . venv.local-pytest/bin/activate
|
$ . venv.local-pytest/bin/activate
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Install Allure CLI
|
7. Setup pre-commit hooks to run code formatters on staged files before you run a `git commit` command:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ pre-commit install
|
||||||
|
```
|
||||||
|
|
||||||
|
Optionally you might want to integrate code formatters with your code editor to apply formatters to code files as you go:
|
||||||
|
* isort is supported by [PyCharm](https://plugins.jetbrains.com/plugin/15434-isortconnect), [VS Code](https://cereblanco.medium.com/setup-black-and-isort-in-vscode-514804590bf9). Plugins exist for other IDEs/editors as well.
|
||||||
|
* black can be integrated with multiple editors, please, instructions are available [here](https://black.readthedocs.io/en/stable/integrations/editors.html).
|
||||||
|
|
||||||
|
8. Install Allure CLI
|
||||||
|
|
||||||
Allure CLI installation is not an easy task, so a better option might be to run allure from
|
Allure CLI installation is not an easy task, so a better option might be to run allure from
|
||||||
docker container (please, refer to p.4 of this section for instructions).
|
docker container (please, refer to p.2 of the next section for instructions).
|
||||||
|
|
||||||
To install Allure CLI you may select one of the following ways:
|
To install Allure CLI you may take one of the following ways:
|
||||||
|
|
||||||
- Follow the [instruction](https://docs.qameta.io/allure/#_linux) from the official website
|
- Follow the [instruction](https://docs.qameta.io/allure/#_linux) from the official website
|
||||||
- Consult [the thread](https://github.com/allure-framework/allure2/issues/989)
|
- Consult [the thread](https://github.com/allure-framework/allure2/issues/989)
|
||||||
- Download release from the Github
|
- Download release from the Github
|
||||||
```
|
```shell
|
||||||
$ wget https://github.com/allure-framework/allure2/releases/download/2.18.1/allure_2.18.1-1_all.deb
|
$ wget https://github.com/allure-framework/allure2/releases/download/2.18.1/allure_2.18.1-1_all.deb
|
||||||
$ sudo apt install ./allure_2.18.1-1_all.deb
|
$ sudo apt install ./allure_2.18.1-1_all.deb
|
||||||
```
|
```
|
||||||
|
@ -79,35 +87,37 @@ You also need the `default-jre` package installed.
|
||||||
|
|
||||||
If none of the options worked for you, please complete the instruction with your approach.
|
If none of the options worked for you, please complete the instruction with your approach.
|
||||||
|
|
||||||
3. Run tests
|
### Run and get report
|
||||||
|
|
||||||
In the activated virtualenv, execute the following command(s) to run a singular testsuite or all the suites in the directory
|
1. Run tests
|
||||||
```
|
|
||||||
|
Make sure that the virtualenv is activated, then execute the following command to run a singular test suite or all the suites in the directory
|
||||||
|
```shell
|
||||||
$ pytest --alluredir my-allure-123 pytest_tests/testsuites/object/test_object_api.py
|
$ pytest --alluredir my-allure-123 pytest_tests/testsuites/object/test_object_api.py
|
||||||
$ pytest --alluredir my-allure-123 pytest_tests/testsuites/
|
$ pytest --alluredir my-allure-123 pytest_tests/testsuites/
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Generate report
|
2. Generate report
|
||||||
|
|
||||||
If you opted to install Allure CLI, you can generate a report using the command `allure generate`. The web representation of the report will be under `allure-report` directory:
|
If you opted to install Allure CLI, you can generate a report using the command `allure generate`. The web representation of the report will be under `allure-report` directory:
|
||||||
```
|
```shell
|
||||||
$ allure generate my-allure-123
|
$ allure generate my-allure-123
|
||||||
$ ls allure-report/
|
$ ls allure-report/
|
||||||
app.js data export favicon.ico history index.html plugins styles.css widgets
|
app.js data export favicon.ico history index.html plugins styles.css widgets
|
||||||
```
|
```
|
||||||
|
|
||||||
To inspect the report in a browser, run
|
To inspect the report in a browser, run
|
||||||
```
|
```shell
|
||||||
$ allure serve my-allure-123
|
$ allure serve my-allure-123
|
||||||
```
|
```
|
||||||
|
|
||||||
If you prefer to run allure from Docker, you can use the following command:
|
If you prefer to run allure from Docker, you can use the following command:
|
||||||
```
|
```shell
|
||||||
mkdir -p $PWD/allure-reports
|
$ mkdir -p $PWD/allure-reports
|
||||||
docker run -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=30 -e KEEP_HISTORY=1 \
|
$ docker run -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=30 -e KEEP_HISTORY=1 \
|
||||||
-v $PWD/my-allure-123:/app/allure-results \
|
-v $PWD/my-allure-123:/app/allure-results \
|
||||||
-v $PWD/allure-reports:/app/default-reports \
|
-v $PWD/allure-reports:/app/default-reports \
|
||||||
frankescobar/allure-docker-service
|
frankescobar/allure-docker-service
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, you can check the allure report in your browser [by this link](http://localhost:5050/allure-docker-service/projects/default/reports/latest/index.html?redirect=false)
|
Then, you can check the allure report in your browser [by this link](http://localhost:5050/allure-docker-service/projects/default/reports/latest/index.html?redirect=false)
|
||||||
|
|
8
pyproject.toml
Normal file
8
pyproject.toml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[tool.isort]
|
||||||
|
profile = "black"
|
||||||
|
src_paths = ["reporter", "shell", "tests"]
|
||||||
|
line_length = 100
|
||||||
|
|
||||||
|
[tool.black]
|
||||||
|
line-length = 100
|
||||||
|
target-version = ["py39"]
|
|
@ -8,6 +8,7 @@ asynctest==0.13.0
|
||||||
attrs==21.4.0
|
attrs==21.4.0
|
||||||
base58==2.1.0
|
base58==2.1.0
|
||||||
bitarray==2.3.4
|
bitarray==2.3.4
|
||||||
|
black==22.8.0
|
||||||
boto3==1.16.33
|
boto3==1.16.33
|
||||||
botocore==1.19.33
|
botocore==1.19.33
|
||||||
certifi==2022.5.18
|
certifi==2022.5.18
|
||||||
|
@ -37,8 +38,10 @@ neo3vm-stubs==0.9.0
|
||||||
netaddr==0.8.0
|
netaddr==0.8.0
|
||||||
orjson==3.6.8
|
orjson==3.6.8
|
||||||
packaging==21.3
|
packaging==21.3
|
||||||
|
paramiko==2.10.3
|
||||||
pexpect==4.8.0
|
pexpect==4.8.0
|
||||||
pluggy==1.0.0
|
pluggy==1.0.0
|
||||||
|
pre-commit==2.20.0
|
||||||
ptyprocess==0.7.0
|
ptyprocess==0.7.0
|
||||||
py==1.11.0
|
py==1.11.0
|
||||||
pybiginteger==1.2.6
|
pybiginteger==1.2.6
|
||||||
|
@ -61,4 +64,3 @@ typing-extensions==4.2.0
|
||||||
urllib3==1.26.9
|
urllib3==1.26.9
|
||||||
websocket-client==1.3.2
|
websocket-client==1.3.2
|
||||||
yarl==1.7.2
|
yarl==1.7.2
|
||||||
paramiko==2.10.3
|
|
||||||
|
|
Loading…
Reference in a new issue