-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use
doit
(instead of Makefile and ad-hoc shell scripts)
- Loading branch information
Showing
11 changed files
with
204 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | ||
], | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.