tasks.py 861 B

123456789101112131415161718192021222324252627282930313233343536
  1. from datetime import datetime
  2. from invoke import task
  3. @task
  4. def test(c):
  5. """Run all the provided tests"""
  6. c.run("poetry run python -m pytest tests/*.py")
  7. @task
  8. def run(c, port=8080, host="127.0.0.1"):
  9. """Run a debug server locally"""
  10. c.run(
  11. f"poetry run python -m flask run -p {port} -h {host}",
  12. env={"FLASK_APP": "lc/main.py"},
  13. )
  14. @task
  15. def install(c):
  16. """Install the listed dependencies into a virtualenv"""
  17. c.run("poetry install")
  18. @task
  19. def fmt(c):
  20. status = c.run("git status --porcelain", hide="stdout")
  21. is_clean = status.stdout.strip() == ""
  22. c.run("poetry run black $(find . -name '*.py')")
  23. if is_clean:
  24. date = datetime.now().isoformat()
  25. c.run(f"git commit -a -m 'Automatic formatting commit: {date}'")
  26. else:
  27. print("Uncommitted change exist; skipping commit")