You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.6 KiB
Python

import sys
from invoke import Failure
1 year ago
from invoke import task
@task
def update_deps(c):
"""Resolves production requirements."""
c.run("pip-compile requirements.in", pty=True)
@task
def install_deps(c):
"""Installs dev and production requirements."""
c.run("pip-sync requirements.txt dev-requirements.txt", pty=True)
1 year ago
@task
def serve_dev(c, debugger=True, reload=True, threads=True, port=8888, host="0.0.0.0"):
"""Serves the htmx_contact.app locally"""
cmd = "flask --app=./ ./htmx_contact run"
1 year ago
cmd += " --debug" if debugger else ""
cmd += " --reload" if reload else ""
cmd += " --with-threads" if threads else ""
cmd += f" --host {host}" if host else ""
cmd += f" --port {port}" if port else ""
print(cmd)
c.run(cmd, pty=True)
@task
def test(c):
"""executes test suite"""
c.run("pytest -vvv --cov tests/", pty=True)
@task
def lint(c, verbose=False):
"""Executes linter checks"""
exit_code = 0
c.run("echo 'Checking isort'")
try:
c.run(f"isort {'-v' if verbose else ''} --check .", pty=True)
except Failure:
exit_code = 1
c.run("echo 'Lint check black'")
try:
c.run(f"black {'-v' if verbose else ''} --check .", pty=True)
except Failure:
exit_code = 1
c.run("echo 'Lint check with ruff'")
try:
c.run(f"ruff check {'-v' if verbose else ''} .", pty=True)
except Failure:
exit_code = 1
if exit_code:
c.run("echo 'ERROR: failed lint checks' >&2 ")
sys.exit(exit_code)
@task
def delint(c):
"""Runs code formaters isort, black"""
c.run("isort .", pty=True)
c.run("black .", pty=True)