-
Notifications
You must be signed in to change notification settings - Fork 8
/
tasks.py
65 lines (53 loc) · 1.83 KB
/
tasks.py
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
# Copyright (c) 2019-2025 Sequentia Developers.
# Distributed under the terms of the MIT License (see the LICENSE file).
# SPDX-License-Identifier: MIT
# This source code is part of the Sequentia project (https://github.com/eonu/sequentia).
"""Main invoke task collection."""
from __future__ import annotations
from invoke.collection import Collection
from invoke.config import Config
from invoke.tasks import task
from make import cov, docs, lint, release, tests
@task
def install(c: Config) -> None:
"""Install package with pre-commit hooks and core, dev, docs, & test
dependencies.
"""
# install dependencies
# NOTE: only including docs/tests dependencies to please editors
c.run("poetry install --sync --only base,main,dev,docs,tests")
# install pre-commit hooks
c.run("pre-commit install --install-hooks")
@task
def clean(c: Config) -> None:
"""Clean temporary files, local cache and build artifacts."""
commands: list[str] = [
"rm -rf `find . -name __pycache__`",
"rm -f `find . -type f -name '*.py[co]'`",
"rm -f `find . -type f -name '*~'`",
"rm -f `find . -type f -name '.*~'`",
"rm -rf .cache",
"rm -rf .pytest_cache",
"rm -rf .ruff_cache",
"rm -rf .tox",
"rm -rf htmlcov",
"rm -rf *.egg-info",
"rm -f .coverage",
"rm -f .coverage.*",
"rm -rf build",
"rm -rf dist",
"rm -rf site",
"rm -rf docs/build",
"rm -rf coverage.xml",
]
for command in commands:
c.run(command)
# create top-level namespace
namespace = Collection()
# register top-level commands
for t in (install, clean):
namespace.add_task(t)
# register namespaces
for module in (docs, tests, cov, lint, release):
collection = Collection.from_module(module)
namespace.add_collection(collection)