-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
95 lines (90 loc) · 3.73 KB
/
Taskfile.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
### @file ###
#
# This is a "Taskfile", for use with the `task` (aka `go-task`) runner.
# It supports cross-platform scripting, task dependency / fingerprinting, and more.
# See: https://github.com/go-task/task
#
# Many tasks are automatically run together, via dependency arrays, so you don't
# have to remember to manually do things like install dependencies, re-build, etc.
#
# Tips:
# - Use `task TASK_NAME` to run a specific task
# - Use `task --list-all` in the project root to list all tasks.
# - For a given task:
# - Use `--summary` to show the description / help.
# - Use `--force` to force the task to re-run, even if computed deps haven't changed.
#############
version: '3'
silent: true
env:
PACKAGE_DIR: django_utils_lib
tasks:
#============================================================#
#======================= Help ===============================#
#============================================================#
default: task --list-all
#============================================================#
#==================== Internal Use ==========================#
#============================================================#
_verify_python_venv: |
if [[ -n "$CI" ]]; then
exit 0
fi
DETECTED_PYTHON_PATH=$(which python)
if [[ $DETECTED_PYTHON_PATH != *"/envs/"* && $DETECTED_PYTHON_PATH != $PWD/* ]]; then
echo "Python path (${DETECTED_PYTHON_PATH}) is not scoped to project; please make sure you have activated your virtual environment."
exit 1
fi
#============================================================#
#================= Setup / install ==========================#
#============================================================#
install:
deps: [_verify_python_venv]
sources:
- pyproject.toml
cmd: poetry install
#============================================================#
#================= Linting / Testing ========================#
#============================================================#
lint:ruff:
deps: [_verify_python_venv, install]
cmd: poetry run ruff check "$PACKAGE_DIR"
lint:types:
deps: [_verify_python_venv, install]
cmd: poetry run mypy "$PACKAGE_DIR"
lint:all:
deps: [_verify_python_venv, install]
cmds:
- task: lint:ruff
- task: lint:types
test:
deps: [_verify_python_venv, install]
cmd: |
# Clear cache files
rm -rf $PACKAGE_DIR/testing/.pytest_run_cache
# Run pytest
poetry run pytest -n auto {{.CLI_ARGS}}
#============================================================#
#================= Docs ==========================#
#============================================================#
docs:pytest_plugin_table:
desc: Generates a Markdown table with Pytest plugin config options
deps: [_verify_python_venv]
cmd: |
poetry run python << "EOF"
from django_utils_lib.testing.pytest_plugin import PluginConfigItems
def generate_markdown_table(config_items):
table_header = "| Config Key | Type | Default | Help | Env Var? |\n"
table_header += "|------------|------|---------|------|---------------|\n"
table_rows = []
for key, item in config_items.items():
env_override = item.get("env_var_override", None)
env_override_text = f"`{env_override['name']}`: {env_override['help']}" if env_override else "N/A"
help = item['help'].replace("\n", "<br/>")
table_rows.append(
f"| `{key}` | `{item['type']}` | `{item['default']}` | {help} | {env_override_text} |"
)
return table_header + "\n".join(table_rows)
markdown_table = generate_markdown_table(PluginConfigItems)
print(markdown_table)
EOF