adding latest duties

This commit is contained in:
2021-11-09 23:55:19 +00:00
parent 6efec7fbc4
commit 0a8320230a
4 changed files with 42 additions and 9 deletions

View File

@@ -1,5 +1,7 @@
Priority: 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 ☐ Docstrings
☐ Update trilium with latest docstrings (documenting __init__ at class level etc) ☐ Update trilium with latest docstrings (documenting __init__ at class level etc)
Make sure the gist is updated for prospector with the right ignores Make sure the gist is updated for prospector with the right ignores
@@ -25,7 +27,7 @@ Functionality:
☐ Update poetry ☐ Update poetry
☐ Build docs ☐ Build docs
☐ Document using Duty ☐ 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. Need to decide what file to place `__version__` in.
VSCode: VSCode:

View File

@@ -1,14 +1,17 @@
from __future__ import annotations
from duty import duty from duty import duty
import pathlib
import re
@duty PACKAGE_NAME = "tembo"
def test(ctx):
ctx.run(["echo", "test"], title="test command")
@duty @duty
def update_deps(ctx, dry: bool = False): def update_deps(ctx, dry: bool = False):
"""Update the dependencies using Poetry. """
Update the dependencies using Poetry.
Example: Example:
`duty update_deps dry=False` `duty update_deps dry=False`
@@ -22,10 +25,37 @@ def update_deps(ctx, dry: bool = False):
@duty @duty
def coverage(ctx): def coverage(ctx):
"""Generate a coverage HTML report. """
Generate a coverage HTML report.
Example: Example:
`duty coverage` `duty coverage`
""" """
ctx.run(["coverage", "run", "--source", "tembo", "-m", "pytest"]) ctx.run(["coverage", "run", "--source", PACKAGE_NAME, "-m", "pytest"])
ctx.run(["coverage", "html"]) 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)}")

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "tembo" name = "tembo"
version = "0.1.0" version = "0.0.1"
description = "" description = ""
authors = ["dtomlinson <dtomlinson@panaetius.co.uk>"] authors = ["dtomlinson <dtomlinson@panaetius.co.uk>"]

1
tembo/_version.py Normal file
View File

@@ -0,0 +1 @@
__version__ = "0.0.1"