This repository has been archived on 2023-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
python-blog/tasks.py

52 lines
1.1 KiB
Python
Raw Normal View History

from pathlib import Path
from invoke import task
BASE_DIR = Path(__file__).parent.resolve(strict=True)
2021-12-19 21:41:20 +01:00
SRC_DIR = BASE_DIR / "src"
@task
def test(ctx):
2021-12-19 21:41:20 +01:00
with ctx.cd(SRC_DIR):
ctx.run("pytest", pty=True, echo=True)
@task
def test_cov(ctx):
2021-12-19 21:41:20 +01:00
with ctx.cd(SRC_DIR):
ctx.run(
"pytest --cov=. --cov-report term-missing:skip-covered",
pty=True,
echo=True,
)
@task
2021-12-19 21:41:20 +01:00
def build(ctx):
with ctx.cd(BASE_DIR):
ctx.run("docker-compose build django", pty=True, echo=True)
2021-12-19 21:41:20 +01:00
@task
def publish(ctx):
with ctx.cd(BASE_DIR):
ctx.run("docker-compose push django", pty=True, echo=True)
@task
def deploy(ctx):
ctx.run("ssh ubuntu /home/gaugendre/blog/update", pty=True, echo=True)
2021-12-27 11:47:36 +01:00
@task
def download_db(ctx):
with ctx.cd(BASE_DIR):
ctx.run(
"scp ubuntu:/home/gaugendre/blog/db/db.sqlite3 ./db/db.sqlite3",
pty=True,
)
with ctx.cd(SRC_DIR):
ctx.run("./manage.py two_factor_disable gaugendre", pty=True)
ctx.run("./manage.py changepassword gaugendre", pty=True)