ofx-processor/tasks.py

59 lines
1.4 KiB
Python
Raw Normal View History

2021-11-20 15:23:42 +01:00
import os
2021-11-18 19:04:43 +01:00
from pathlib import Path
from invoke import task
BASE_DIR = Path(__file__).parent.resolve(strict=True)
@task
def test(ctx):
with ctx.cd(BASE_DIR):
ctx.run(f"pytest", pty=True, echo=True)
@task
def test_cov(ctx):
2021-11-18 19:04:43 +01:00
with ctx.cd(BASE_DIR):
2021-11-20 15:13:26 +01:00
ctx.run(
f"pytest --cov=. --cov-report term-missing:skip-covered",
pty=True,
echo=True,
)
2021-11-20 13:03:49 +01:00
@task
def full_test(ctx):
with ctx.cd(BASE_DIR):
ctx.run(f"tox", pty=True, echo=True)
@task
def publish(ctx):
2021-11-20 15:23:42 +01:00
username = os.getenv("PYPI_USERNAME")
password = os.getenv("PYPI_TOKEN")
2021-11-20 13:03:49 +01:00
with ctx.cd(BASE_DIR):
2021-11-20 15:23:42 +01:00
args = ""
if username and password:
args = f"--username {username} --password {password}"
2021-11-20 16:00:30 +01:00
ctx.run(f"poetry publish --build {args}", pty=True, echo=False)
2021-11-20 16:59:12 +01:00
@task
def publish_docker(ctx):
with ctx.cd(BASE_DIR):
2022-03-13 11:27:30 +01:00
docker_image = "crocmagnon/ynab"
2021-11-20 16:59:12 +01:00
ctx.run(
2022-03-13 11:27:30 +01:00
f"docker build --platform linux/amd64 --build-arg OFX_VERSION=$(poetry version -s) -t {docker_image} .",
2021-11-20 16:59:12 +01:00
pty=True,
echo=True,
)
ctx.run(f"docker push {docker_image}", pty=True, echo=True)
2021-11-20 17:08:46 +01:00
@task
def tag(ctx, tag_name):
with ctx.cd(BASE_DIR):
ctx.run(f'git tag {tag_name} -am "{tag_name}"', pty=True, echo=True)
ctx.run(f"git push origin {tag_name}", pty=True, echo=True)