Skip to content

Commit

Permalink
poethepoet introduced
Browse files Browse the repository at this point in the history
  • Loading branch information
pseusys committed Nov 10, 2023
1 parent 506ec20 commit a4ccca1
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
TG_API_HASH: ${{ secrets.TG_API_HASH }}
TG_BOT_USERNAME: ${{ secrets.TG_BOT_USERNAME }}
run: |
poetry run docs
poe docs
- name: remove jekyll theming
run: touch docs/build/.nojekyll
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
- name: run codestyle
run: |
poetry run lint
poe lint
2 changes: 1 addition & 1 deletion .github/workflows/test_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:
TG_API_HASH: ${{ secrets.TG_API_HASH }}
TG_BOT_USERNAME: ${{ secrets.TG_BOT_USERNAME }}
run: |
poetry run test_all
poe test_all
4 changes: 2 additions & 2 deletions .github/workflows/test_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
TG_API_HASH: ${{ secrets.TG_API_HASH }}
TG_BOT_USERNAME: ${{ secrets.TG_BOT_USERNAME }}
run: |
poetry run test_no_cov
poe test_no_cov
test_no_deps:
runs-on: "ubuntu-latest"
Expand All @@ -68,4 +68,4 @@ jobs:
TG_API_HASH: ${{ secrets.TG_API_HASH }}
TG_BOT_USERNAME: ${{ secrets.TG_BOT_USERNAME }}
run: |
poetry run test_no_deps
poe test_no_deps
23 changes: 12 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ We ask that you adhere to the following
[commit message format](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716).

## Managing your workflow
We use `poetry` as handy automation tool, which reads `pyproject.toml` to get specification for commands.
`poetry` is a tool for command running automatization. Usage signature of the `poetry` is `poetry run COMMAND`.
We use `poetry` and `poethepoet` as handy automation tools, which reads `pyproject.toml` to get specification for commands.
`poetry` is a tool for command running automatization. Usage signature of the `poetry` is `poe COMMAND`.
If your environment does not support `poetry`, it can be installed as a regular python package with `pip install poetry`.
`poethepoet` will be automatically installed upon installation of `devel` dependency group.

### Platforms

Expand Down Expand Up @@ -55,7 +56,7 @@ to annotate your modules and objects. You can easily build the Sphinx documentat
by activating the virtual environment and then running

```bash
poetry run docs
poe docs
```

After that `docs/build` dir will be created and you can open index file `docs/build/index.html` in your browser of choice.
Expand Down Expand Up @@ -106,28 +107,28 @@ It doesn't take previous formatting into account. See more about [black](https:/
To format your code, run

```bash
poetry run format
poe format
```

### Test
We use `black`, `mypy`, `flake8` as code style checkers and `pytest` as unit-test runner.
To run unit-tests only, use
```bash
poetry run test_no_cov
poe test_no_cov
```
To execute all tests, including integration with DBs and APIs tests, run
```bash
poetry run test_all
poe test_all
```
for successful execution of this command `Docker` and `docker-compose` are required.

To make sure that the code satisfies only the style requirements, run
```bash
poetry run lint
poe lint
```
And if it doesn't, to automatically fix whatever is possible with `black`, run
```bash
poetry run format
poe format
```

Tests are configured via [`.env_file`](.env_file).
Expand Down Expand Up @@ -158,11 +159,11 @@ To launch both groups run
docker-compose --profile context_storage --profile stats up
```

This will be done automatically when running `poetry run test_all`.
This will be done automatically when running `poe test_all`.

### Other provided features
You can get more info about `poetry` commands by `help`:
You can get more info about `poetry` commands by `info`:

```bash
poetry run help
poe info
```
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ optional = true
[tool.poetry.group.devel.dependencies]
python-on-whales = "0.64.3"
python-dotenv = "0.21.1"
poethepoet = "0.24.2"


[tool.poetry.group.tutorials]
Expand Down Expand Up @@ -176,6 +177,11 @@ jupyter = "1.0.0"


[tool.poetry.scripts]
"dff.stats" = { callable = "dff.stats.__main__:main", extras = ["stats"] }



[tool.poe.tasks]
info = "scripts.misc:info"
lint = "scripts.codestyle:lint"
format = "scripts.codestyle:format"
Expand All @@ -186,8 +192,6 @@ test_no_deps = "scripts.test:test_no_deps"
test_all = "scripts.test:test_all"
docs = "scripts.doc:docs"

"dff.stats" = { callable = "dff.stats.__main__:main", extras = ["stats"] }



[build-system]
Expand Down
2 changes: 1 addition & 1 deletion scripts/codestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def lint() -> int:
lint_result = _run_lint_and_mypy()
would_format = _run_black(False)
if would_format == 1:
print(("=" * 38) + "\nBad formatting? Run: poetry run format\n" + ("=" * 38))
print(("=" * 38) + "\nBad formatting? Run: poe format\n" + ("=" * 38))
return lint_result or would_format


Expand Down
18 changes: 9 additions & 9 deletions scripts/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ def info():
+ "Install development-ready version of framework"
)
print(f"{Fore.BLUE}poetry env remove --all{Style.RESET_ALL}: Remove all virtual environments\n")
print(f"{Fore.BLUE}poetry run info{Style.RESET_ALL}: Display this message again")
print(f"{Fore.BLUE}poetry run lint{Style.RESET_ALL}: Run linters")
print(f"{Fore.BLUE}poetry run format{Style.RESET_ALL}: Run formatters")
print(f"{Fore.BLUE}poe info{Style.RESET_ALL}: Display this message again")
print(f"{Fore.BLUE}poe lint{Style.RESET_ALL}: Run linters")
print(f"{Fore.BLUE}poe format{Style.RESET_ALL}: Run formatters")
print(
f"{Fore.BLUE}poetry run test_no_cov{Style.RESET_ALL}:"
f"{Fore.BLUE}poe test_no_cov{Style.RESET_ALL}:"
+ " Run tests without coverage, skipping all tests for unavailable services,"
+ " this is the most complete testing without Docker"
)
print(
f"{Fore.BLUE}poetry run test_no_deps{Style.RESET_ALL}:"
f"{Fore.BLUE}poe test_no_deps{Style.RESET_ALL}:"
+ " Run tests without any dependencies, allowing skipping everything"
)
print(
f"{Fore.BLUE}poetry run test_all{Style.RESET_ALL}:"
f"{Fore.BLUE}poe test_all{Style.RESET_ALL}:"
+ " Run ALL tests, prohibit skipping, run Docker (slow, closest to CI)"
)
print(
f"{Fore.BLUE}poetry run docs{Style.RESET_ALL}:"
f"{Fore.BLUE}poe docs{Style.RESET_ALL}:"
+ " Build Sphinx docs; activate your virtual environment before execution"
)
print(f"{Fore.BLUE}poetry run clean_docs{Style.RESET_ALL}: Remove all documentation build roots")
print(f"{Fore.BLUE}poetry run clean{Style.RESET_ALL}: Clean all build artifacts\n")
print(f"{Fore.BLUE}poe clean_docs{Style.RESET_ALL}: Remove all documentation build roots")
print(f"{Fore.BLUE}poen clean{Style.RESET_ALL}: Clean all build artifacts\n")

0 comments on commit a4ccca1

Please sign in to comment.