From 0a8320230a6dec08b5c4c38a271a0f378ac6b9d9 Mon Sep 17 00:00:00 2001 From: Daniel Tomlinson Date: Tue, 9 Nov 2021 23:55:19 +0000 Subject: [PATCH] adding latest duties --- TODO.todo | 6 ++++-- duties.py | 42 ++++++++++++++++++++++++++++++++++++------ pyproject.toml | 2 +- tembo/_version.py | 1 + 4 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 tembo/_version.py diff --git a/TODO.todo b/TODO.todo index ee9180a..fae7b13 100644 --- a/TODO.todo +++ b/TODO.todo @@ -1,5 +1,7 @@ Priority: - ☐ Version duty + ✔ Version duty @done(21-11-09 23:54) + ☐ Duty to `poetry build` and extract + copy `setup.py` to root + ☐ Duty to run tests in isolation ☐ Docstrings ☐ Update trilium with latest docstrings (documenting __init__ at class level etc) Make sure the gist is updated for prospector with the right ignores @@ -25,7 +27,7 @@ Functionality: ☐ Update poetry ☐ Build docs ☐ Document using Duty - ☐ Duty for auto insert version from `poetry version`. + ✔ Duty for auto insert version from `poetry version`. @done(21-11-09 23:53) Need to decide what file to place `__version__` in. VSCode: diff --git a/duties.py b/duties.py index 4f23051..554adb6 100644 --- a/duties.py +++ b/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)}") diff --git a/pyproject.toml b/pyproject.toml index 3c83e09..f4d5667 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tembo" -version = "0.1.0" +version = "0.0.1" description = "" authors = ["dtomlinson "] diff --git a/tembo/_version.py b/tembo/_version.py new file mode 100644 index 0000000..f102a9c --- /dev/null +++ b/tembo/_version.py @@ -0,0 +1 @@ +__version__ = "0.0.1"