Skip to content

Commit

Permalink
Testing new Python workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
vkottler committed Aug 3, 2023
1 parent 4542c5a commit 605de61
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ htmlcov
*-stubs
coverage*.xml
tags
mklocal
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ test = [
"mypy",
"isort",
"yamllint",
"yambs",
"vmklib",
"pytest-asyncio",
"setuptools-wrapper",
"types-setuptools"
Expand Down
2 changes: 2 additions & 0 deletions runtimepy/dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ ruff
mypy
isort
yamllint
yambs
vmklib
pytest-asyncio
setuptools-wrapper
types-setuptools
64 changes: 35 additions & 29 deletions tasks/conf.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,53 @@
# =====================================
# generator=datazen
# version=3.1.2
# hash=9f62028523c3b5a953733ca89dcc3018
# =====================================
"""
A module for project-specific task registration.
"""

# built-in
from pathlib import Path
from subprocess import run
from typing import Dict

# third-party
from vcorelib.task import Inbox, Outbox, Phony
from vcorelib.task.manager import TaskManager
from vcorelib.task.subprocess.run import SubprocessLogMixin, is_windows


class ArbiterTask(SubprocessLogMixin):
"""A task for running the runtime arbiter."""
def audit_local_tasks() -> None:
"""Ensure that shared task infrastructure is present."""

default_requirements = {"vmklib.init", "venv", "python-editable"}
local = Path(__file__).parent.joinpath("mklocal")

async def run(self, inbox: Inbox, outbox: Outbox, *args, **kwargs) -> bool:
"""Generate ninja configuration files."""
# Also link a top-level file.
top_level = local.parent.parent.joinpath("mklocal")
if not top_level.is_symlink():
assert not top_level.exists()
top_level.symlink_to(local)

cwd: Path = args[0]
if local.is_symlink():
return

configs = cwd.joinpath("local", "arbiter")
# If it's not a symlink, it shouldn't be any other kind of file.
assert not local.exists()

config = configs.joinpath(kwargs.get("config", "test") + ".yaml")
# Ensure sub-module implementation is present.
config = local.parent.parent.joinpath("config")
assert config.is_dir()

return await self.exec(
str(
inbox["venv"]["venv{python_version}"]["bin"].joinpath(
"runtimepy"
)
),
"arbiter",
str(config),
# Initialize submodules if we don't see the directory we're looking for.
vmklib = config.joinpath("python", "mklocal")
if not vmklib.is_dir():
run(
["git", "-C", str(config.parent), "submodule", "update", "--init"],
check=True,
)

# Create the link.
local.symlink_to(vmklib)


def register(
manager: TaskManager,
Expand All @@ -45,16 +57,10 @@ def register(
) -> bool:
"""Register project tasks to the manager."""

# Don't run yamllint on Windows because it will fail on newlines.
manager.register(
Phony("yaml"),
[] if is_windows() else ["yaml-lint-local", "yaml-lint-manifest.yaml"],
)

manager.register(ArbiterTask("r", cwd))
audit_local_tasks()

del project
del cwd
del substitutions
from mklocal.python import ( # pylint: disable=import-outside-toplevel
register_python,
)

return True
return register_python(manager, project, cwd, substitutions)

0 comments on commit 605de61

Please sign in to comment.