mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
PTY all the tasks
This commit is contained in:
parent
d1a874e580
commit
eab67f7634
1 changed files with 19 additions and 17 deletions
36
tasks.py
36
tasks.py
|
|
@ -8,6 +8,7 @@ PKG_NAME = "pelican"
|
|||
PKG_PATH = Path(PKG_NAME)
|
||||
DOCS_PORT = os.environ.get("DOCS_PORT", 8000)
|
||||
BIN_DIR = "bin" if os.name != "nt" else "Scripts"
|
||||
PTY = True if os.name != "nt" else False
|
||||
ACTIVE_VENV = os.environ.get("VIRTUAL_ENV", None)
|
||||
VENV_HOME = Path(os.environ.get("WORKON_HOME", "~/virtualenvs"))
|
||||
VENV_PATH = Path(ACTIVE_VENV) if ACTIVE_VENV else (VENV_HOME / PKG_NAME)
|
||||
|
|
@ -16,15 +17,13 @@ VENV_BIN = Path(VENV) / Path(BIN_DIR)
|
|||
|
||||
TOOLS = ["poetry", "pre-commit", "psutil"]
|
||||
POETRY = which("poetry") if which("poetry") else (VENV_BIN / "poetry")
|
||||
PRECOMMIT = (
|
||||
which("pre-commit") if which("pre-commit") else (VENV_BIN / "pre-commit")
|
||||
)
|
||||
PRECOMMIT = which("pre-commit") if which("pre-commit") else (VENV_BIN / "pre-commit")
|
||||
|
||||
|
||||
@task
|
||||
def docbuild(c):
|
||||
"""Build documentation"""
|
||||
c.run(f"{VENV_BIN}/sphinx-build -W docs docs/_build")
|
||||
c.run(f"{VENV_BIN}/sphinx-build -W docs docs/_build", pty=PTY)
|
||||
|
||||
|
||||
@task(docbuild)
|
||||
|
|
@ -42,7 +41,6 @@ def docserve(c):
|
|||
@task
|
||||
def tests(c):
|
||||
"""Run the test suite"""
|
||||
PTY = True if os.name != "nt" else False
|
||||
c.run(f"{VENV_BIN}/pytest", pty=PTY)
|
||||
|
||||
|
||||
|
|
@ -54,7 +52,7 @@ def black(c, check=False, diff=False):
|
|||
check_flag = "--check"
|
||||
if diff:
|
||||
diff_flag = "--diff"
|
||||
c.run(f"{VENV_BIN}/black {check_flag} {diff_flag} {PKG_PATH} tasks.py")
|
||||
c.run(f"{VENV_BIN}/black {check_flag} {diff_flag} {PKG_PATH} tasks.py", pty=PTY)
|
||||
|
||||
|
||||
@task
|
||||
|
|
@ -64,14 +62,12 @@ def isort(c, check=False, diff=False):
|
|||
check_flag = "-c"
|
||||
if diff:
|
||||
diff_flag = "--diff"
|
||||
c.run(
|
||||
f"{VENV_BIN}/isort {check_flag} {diff_flag} ."
|
||||
)
|
||||
c.run(f"{VENV_BIN}/isort {check_flag} {diff_flag} .", pty=PTY)
|
||||
|
||||
|
||||
@task
|
||||
def flake8(c):
|
||||
c.run(f"git diff HEAD | {VENV_BIN}/flake8 --diff --max-line-length=88")
|
||||
c.run(f"git diff HEAD | {VENV_BIN}/flake8 --diff --max-line-length=88", pty=PTY)
|
||||
|
||||
|
||||
@task
|
||||
|
|
@ -84,20 +80,20 @@ def tools(c):
|
|||
"""Install tools in the virtual environment if not already on PATH"""
|
||||
for tool in TOOLS:
|
||||
if not which(tool):
|
||||
c.run(f"{VENV_BIN}/python -m pip install {tool}")
|
||||
c.run(f"{VENV_BIN}/python -m pip install {tool}", pty=PTY)
|
||||
|
||||
|
||||
@task
|
||||
def precommit(c):
|
||||
"""Install pre-commit hooks to .git/hooks/pre-commit"""
|
||||
c.run(f"{PRECOMMIT} install")
|
||||
c.run(f"{PRECOMMIT} install", pty=PTY)
|
||||
|
||||
|
||||
@task
|
||||
def setup(c):
|
||||
c.run(f"{VENV_BIN}/python -m pip install -U pip")
|
||||
c.run(f"{VENV_BIN}/python -m pip install -U pip", pty=PTY)
|
||||
tools(c)
|
||||
c.run(f"{POETRY} install")
|
||||
c.run(f"{POETRY} install", pty=PTY)
|
||||
precommit(c)
|
||||
|
||||
|
||||
|
|
@ -105,11 +101,17 @@ def setup(c):
|
|||
def update_functional_tests(c):
|
||||
"""Update the generated functional test output"""
|
||||
c.run(
|
||||
f"bash -c 'LC_ALL=en_US.utf8 pelican -o {PKG_PATH}/tests/output/custom/ -s samples/pelican.conf.py samples/content/'"
|
||||
f"bash -c 'LC_ALL=en_US.utf8 pelican -o {PKG_PATH}/tests/output/custom/ \
|
||||
-s samples/pelican.conf.py samples/content/'",
|
||||
pty=PTY,
|
||||
)
|
||||
c.run(
|
||||
f"bash -c 'LC_ALL=fr_FR.utf8 pelican -o {PKG_PATH}/tests/output/custom_locale/ -s samples/pelican.conf_FR.py samples/content/'"
|
||||
f"bash -c 'LC_ALL=fr_FR.utf8 pelican -o {PKG_PATH}/tests/output/custom_locale/ \
|
||||
-s samples/pelican.conf_FR.py samples/content/'",
|
||||
pty=PTY,
|
||||
)
|
||||
c.run(
|
||||
f"bash -c 'LC_ALL=en_US.utf8 pelican -o {PKG_PATH}/tests/output/basic/ samples/content/'"
|
||||
f"bash -c 'LC_ALL=en_US.utf8 pelican -o \
|
||||
{PKG_PATH}/tests/output/basic/ samples/content/'",
|
||||
pty=PTY,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue