mirror of
https://github.com/dtomlinson91/tembo.git
synced 2025-12-22 09:45:44 +00:00
adding latest duties
This commit is contained in:
42
duties.py
42
duties.py
@@ -1,14 +1,17 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from duty import duty
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
|
||||
@duty
|
||||
def test(ctx):
|
||||
ctx.run(["echo", "test"], title="test command")
|
||||
PACKAGE_NAME = "tembo"
|
||||
|
||||
|
||||
@duty
|
||||
def update_deps(ctx, dry: bool = False):
|
||||
"""Update the dependencies using Poetry.
|
||||
"""
|
||||
Update the dependencies using Poetry.
|
||||
|
||||
Example:
|
||||
`duty update_deps dry=False`
|
||||
@@ -22,10 +25,37 @@ def update_deps(ctx, dry: bool = False):
|
||||
|
||||
@duty
|
||||
def coverage(ctx):
|
||||
"""Generate a coverage HTML report.
|
||||
"""
|
||||
Generate a coverage HTML report.
|
||||
|
||||
Example:
|
||||
`duty coverage`
|
||||
"""
|
||||
ctx.run(["coverage", "run", "--source", "tembo", "-m", "pytest"])
|
||||
ctx.run(["coverage", "run", "--source", PACKAGE_NAME, "-m", "pytest"])
|
||||
ctx.run(["coverage", "html"])
|
||||
|
||||
|
||||
@duty
|
||||
def version(ctx, bump: str = "patch"):
|
||||
"""
|
||||
Bump the version using Poetry and update _version.py.
|
||||
|
||||
Args:
|
||||
bump (str, optional) = poetry version flag. Available options are:
|
||||
patch, minor, major, prepatch, preminor, premajor, prerelease.
|
||||
Defaults to patch.
|
||||
|
||||
Example:
|
||||
`duty version bump=major`
|
||||
"""
|
||||
|
||||
# bump with poetry
|
||||
result = ctx.run(["poetry", "version", bump])
|
||||
new_version = re.search(r"(?:.*)(?:\s)(\d+\.\d+\.\d+)$", result)
|
||||
print(new_version.group(0))
|
||||
|
||||
# update _version.py
|
||||
version_file = pathlib.Path(PACKAGE_NAME) / "_version.py"
|
||||
with version_file.open("w", encoding="utf-8") as version_file:
|
||||
version_file.write(f'__version__ = "{new_version.group(1)}"\n')
|
||||
print(f"Bumped _version.py to {new_version.group(1)}")
|
||||
|
||||
Reference in New Issue
Block a user