Skip to content

Commit

Permalink
chore: use doit (instead of Makefile and ad-hoc shell scripts)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdmit11 committed Mar 22, 2024
1 parent 6164bf2 commit e21632e
Show file tree
Hide file tree
Showing 11 changed files with 204 additions and 90 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,9 @@ cython_debug/

# Flycheck (Emacs) temporary files
.flycheck__*

# DoIt DB and other temporary files
/.doit.*

# my personal scratchpad
/playground.py
24 changes: 0 additions & 24 deletions docs/Makefile

This file was deleted.

96 changes: 96 additions & 0 deletions dodo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import os.path
from doit.tools import Interactive
from typing import List, Iterable

DOIT_CONFIG = {
"default_tasks": [
"lint",
"test_multi",
]
}


SRC_DIRS = [
"contextvars_registry",
"tests",
"docs",
]


def _find_src_files(src_dirs: Iterable[str]) -> List[str]:
# Find .py/.pyi/.rst/etc (files that may contain Python code).
# Needed for watching the files and auto-running tasks on change (using doit auto).
def _is_src_file(directory: str, filename: str) -> bool:
return (
(
filename.endswith(".py")
or filename.endswith(".pyi")
or filename.endswith(".rst")
)
and not filename.startswith(".")
and not directory.startswith(".")
)

return [
os.path.join(directory, filename)
for src_dir in SRC_DIRS
for directory, _, filenames in os.walk(src_dir)
for filename in filenames
if _is_src_file(directory, filename)
]


SRC_FILES = _find_src_files(SRC_DIRS)

# whitespace-separated lists, needed for composing shell commands
SRC_FILES_STR = " ".join(SRC_FILES)
SRC_DIRS_STR = " ".join(SRC_DIRS)


def task_fix():
return {
"file_dep": SRC_FILES,
"actions": [
Interactive("ruff format {SRC_DIRS_STR}"),
Interactive(f"ruff check --fix {SRC_DIRS_STR}"),
],
}


def task_lint():
return {
"file_dep": SRC_FILES,
"actions": [
Interactive(f"ruff check {SRC_DIRS_STR}"),
Interactive(f"mypy {SRC_DIRS_STR}"),
],
}


def task_test():
return {
"file_dep": SRC_FILES,
"actions": [
Interactive(
f"pytest --cov=contextvars_registry --cov-fail-under=100 {SRC_DIRS_STR}"
),
],
}


def task_test_multi():
return {
"file_dep": SRC_FILES,
"actions": [
Interactive("tox -p -r"),
],
}


def task_docs():
return {
"file_dep": SRC_FILES,
"actions": [
Interactive("sphinx-build docs docs/_build"),
],
}
134 changes: 99 additions & 35 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ sentinel-value = "^1.0.0"
[tool.poetry.group.dev.dependencies]
Flask = {extras = ["async"], version = "^3.0.2"}
Sphinx = "^7.1.2"
doit = "^0.36.0"
doit-auto1 = "^0.1.0"
gevent = "^24.2.1"
mypy = "^1.9.0"
pytest = "^8.1.1"
Expand Down
1 change: 0 additions & 1 deletion run_docs_build_loop.sh

This file was deleted.

7 changes: 0 additions & 7 deletions run_formatters.sh

This file was deleted.

3 changes: 0 additions & 3 deletions run_tdd_loop.sh

This file was deleted.

Loading

0 comments on commit e21632e

Please sign in to comment.