Gab's Notes backend https://gabnotes.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
blog/tasks.py

63 lines
1.4 KiB

from pathlib import Path
from invoke import task
BASE_DIR = Path(__file__).parent.resolve(strict=True)
10 months ago
SRC_DIR = BASE_DIR / "src"
@task
def test(ctx):
10 months ago
with ctx.cd(SRC_DIR):
ctx.run("pytest", pty=True, echo=True)
@task
def test_cov(ctx):
10 months ago
with ctx.cd(SRC_DIR):
ctx.run(
"pytest --cov=. --cov-report term-missing:skip-covered",
pty=True,
echo=True,
)
9 months ago
@task(post=[test_cov])
def check(ctx):
with ctx.cd(BASE_DIR):
ctx.run("pre-commit run --all-files", pty=True)
ctx.run("mypy src", pty=True)
@task
10 months ago
def build(ctx):
with ctx.cd(BASE_DIR):
ctx.run("docker-compose build django", pty=True, echo=True)
10 months ago
@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)
9 months ago
@task(pre=[check, build, publish, deploy])
def beam(ctx):
pass
@task
def download_db(ctx):
with ctx.cd(BASE_DIR):
ctx.run("scp ubuntu:/home/gaugendre/blog/db/db.sqlite3 ./db/db.sqlite3")
ctx.run("rm -rf src/media/")
ctx.run("scp -r ubuntu:/home/gaugendre/blog/media/ ./src/media")
with ctx.cd(SRC_DIR):
ctx.run("./manage.py two_factor_disable gaugendre", pty=True)
ctx.run("./manage.py changepassword gaugendre", pty=True)