Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -50,7 +50,7 @@ jobs:
TG_BOT_USERNAME: ${{ secrets.TG_BOT_USERNAME }}
DOC_VERSION: ${{ env.DOC_VERSION }}
run: |
python -m poetry run poe docs
python -m poetry run poe docs --docker

- name: deploy website
uses: JamesIves/github-pages-deploy-action@v4
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: |
python -m poetry run poe lint
python -m poetry run poe lint --no-modify
43 changes: 0 additions & 43 deletions .github/workflows/test_coverage.yml

This file was deleted.

53 changes: 44 additions & 9 deletions .github/workflows/test_full.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test_full
name: test

on:
push:
Expand All @@ -16,12 +16,12 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/dev' && github.ref != 'refs/heads/master' }}

jobs:
test_full:
test_coverage:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [macOS-latest, windows-latest, ubuntu-latest]
python-version: "3.13"
os: ubuntu-latest

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -42,17 +42,23 @@ jobs:
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
TG_BOT_USERNAME: ${{ secrets.TG_BOT_USERNAME }}
run: |
python -m poetry run poe test_no_cov
python -m poetry run poe test --docker --no-skip --coverage

test_no_deps:
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
python-version: "3.13"
os: ubuntu-latest

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: set up python 3.9
- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: ${{ matrix.python-version }}

- name: install dependencies
run: |
Expand All @@ -64,4 +70,33 @@ jobs:
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
TG_BOT_USERNAME: ${{ secrets.TG_BOT_USERNAME }}
run: |
python -m poetry run poe test_no_deps
python -m poetry run poe test

test_other_os:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.13"]
os: [macOS-latest, windows-latest]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: install dependencies
run: |
python -m pip install --upgrade pip poetry==1.8.5
python -m poetry install --with test,tutorials --all-extras --no-ansi --no-interaction

- name: run pytest
env:
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
TG_BOT_USERNAME: ${{ secrets.TG_BOT_USERNAME }}
run: |
python -m poetry run poe test

79 changes: 65 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,71 @@ default_task_type = "script"

[tool.poe.tasks]
info = "scripts.misc:info"
flake = "scripts.codestyle:_run_flake"
black = "scripts.codestyle:_run_black(modify=False)"
lint.sequence = ["flake", "black"]
lint.ignore_fail = "return_non_zero"
format = "scripts.codestyle:_run_black(modify=True)"
clean_docs = "scripts.clean:clean_docs"
clean = "scripts.clean:clean"
quick_test = "scripts.test:quick_test"
quick_test_coverage = "scripts.test:quick_test_coverage"
test_no_cov = "scripts.test:test_no_cov"
test_no_deps = "scripts.test:test_no_deps"
test_all = "scripts.test:test_all"
docs = "scripts.doc:docs"
docs_no_docker = "scripts.doc:docs_no_docker"

[tool.poe.tasks.clean_docs]
script = "scripts.clean:clean_docs"

[tool.poe.tasks.clean]
script = "scripts.clean:clean"

[tool.poe.tasks.docs]
help = "Config docs"
script = "scripts.doc:docs"
[tool.poe.tasks.docs.args.use_docker]
options = ["-d", "--docker", "--use-docker"]
help = "Allow docker usage"
default = false
required = false
type = "boolean"

[tool.poe.tasks.flake]
script = "scripts.codestyle:_run_flake"

[tool.poe.tasks.black]
script = "scripts.codestyle:_run_black(no_modify=no_modify)"
args =[{name = "no_modify", options = ["--no-modify"], type = "boolean", default = false}]

[tool.poe.tasks.lint]
script = "scripts.codestyle:_run_lint(no_modify=no_modify)"
args =[{name = "no_modify", options = ["--no-modify"], type = "boolean", default = false}]

[tool.poe.tasks.test]
help = "Tests setup"
script = "scripts.test:run_tests"
[tool.poe.tasks.test.args.quick]
options = ["-q", "--quick"]
help = "Run only quick tests"
default = false
required = false
type = "boolean"

[tool.poe.tasks.test.args.coverage]
options = ["-c", "--cov", "--coverage"]
help = "Enable coverage report"
default = false
required = false
type = "boolean"

[tool.poe.tasks.test.args.use_docker]
options = ["-d", "--docker", "--use-docker"]
help = "Allow docker usage"
default = false
required = false
type = "boolean"

[tool.poe.tasks.test.args.no_skip]
options = ["--no-skip"]
help = "Allow skipping tests with dependencies"
default = false
required = false
type = "boolean"

[tool.poe.tasks.test.args.path]
help = "Path to file or folder to test"
positional = true
required = false
type = "string"
default = "tests/"



Expand Down
30 changes: 23 additions & 7 deletions scripts/codestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _get_paths(paths: List[str]) -> List[pathlib.Path]:


def _run_flake():
lint_result = 0
exit_code = 0
flake8_configs = [
"--select=E,W,F",
# black formats binary operators after line breaks
Expand All @@ -27,19 +27,35 @@ def _run_flake():
# patches that execute code before imports
"**3_load_testing_with_locust.py:E402 **4_streamlit_chat.py:E402",
]
lint_result += flake_main([f"--max-line-length={_STANDARD_PATHS_LEN}"] + flake8_configs + _STANDARD_PATHS)
lint_result += flake_main([f"--max-line-length={_SHORT_PATHS_LEN}"] + flake8_configs + _SHORT_PATHS)
exit_code += flake_main([f"--max-line-length={_STANDARD_PATHS_LEN}"] + flake8_configs + _STANDARD_PATHS)
exit_code += flake_main([f"--max-line-length={_SHORT_PATHS_LEN}"] + flake8_configs + _SHORT_PATHS)

exit(lint_result)
return exit_code


def _run_black(modify: bool):
report = black.Report(check=not modify, quiet=False)
write = black.WriteBack.YES if modify else black.WriteBack.CHECK
def run_flake():
exit(_run_flake())


def _run_black(no_modify: bool):
report = black.Report(check=no_modify, quiet=False)
write = black.WriteBack.YES if not no_modify else black.WriteBack.CHECK
for path in _get_paths(_STANDARD_PATHS):
mode = black.Mode(line_length=_STANDARD_PATHS_LEN)
black.reformat_one(path, False, write, mode, report)
for path in _get_paths(_SHORT_PATHS):
mode = black.Mode(line_length=_SHORT_PATHS_LEN)
black.reformat_one(path, False, write, mode, report)
exit(report.return_code)


def run_black(no_modify: bool):
exit(_run_black(no_modify))


def _run_lint(no_modify: bool):
print("Flake running")
result = _run_flake()
print("Black running")
result += _run_black(no_modify)
exit(result)
28 changes: 6 additions & 22 deletions scripts/doc.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import os
from pathlib import Path
import shutil
from typing import Optional

import dotenv
import scripts.patch_sphinx # noqa: F401
import sphinx.ext.apidoc as apidoc
import sphinx.cmd.build as build
from colorama import init, Fore, Style
from colorama import init
from python_on_whales import DockerClient

from .utils import docker_client
Expand Down Expand Up @@ -43,30 +42,15 @@ def _build_drawio(docker: DockerClient):
print(f"Drawio images built from {path.parent} to {target}")


@docker_client
def docs(docker: Optional[DockerClient]):
init()
if docker is not None:
def docs(use_docker: bool = False):
with docker_client(use_docker) as client:
init()
clean_docs()
dotenv.load_dotenv(".env_file")
os.environ["DISABLE_INTERACTIVE_MODE"] = "1"
_build_drawio(docker)
if use_docker is True:
_build_drawio(client)
result = apidoc.main(["-e", "-E", "-f", "-o", "docs/source/apiref", "chatsky"])
result += build.make_main(["-M", "clean", "docs/source", "docs/build"])
result += build.build_main(["-b", "html", "-W", "--keep-going", "docs/source", "docs/build"])
exit(result)
else:
print(f"{Fore.RED}Docs can be built on Linux platform only!{Style.RESET_ALL}")
exit(1)


def docs_no_docker():
init()
clean_docs()
dotenv.load_dotenv(".env_file")
os.environ["DISABLE_INTERACTIVE_MODE"] = "1"
os.environ["NBSPHINX_ALLOW_ERRORS"] = "true"
result = apidoc.main(["-e", "-E", "-f", "-o", "docs/source/apiref", "chatsky"])
result += build.make_main(["-M", "clean", "docs/source", "docs/build"])
result += build.build_main(["-b", "html", "-W", "--keep-going", "docs/source", "docs/build"])
exit(result)
Loading
Loading