Skip to content

Commit

Permalink
Merge pull request #83 from vkottler/dev/workflow-update
Browse files Browse the repository at this point in the history
Testing new Python workflow
  • Loading branch information
vkottler authored Aug 3, 2023
2 parents 4542c5a + 0893620 commit 66c4516
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ jobs:
env:
PY_LINT_MYPY_EXTRA_ARGS: --no-incremental

- run: mk docs
if: |
matrix.python-version == '3.11'
&& matrix.system == 'ubuntu-latest'
- run: mk python-test
env:
PY_TEST_EXTRA_ARGS: --cov-report=xml
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ htmlcov
*-stubs
coverage*.xml
tags
mklocal
docs
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
known_first_party=runtimepy
known_first_party=runtimepy,vmklib
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 66c4516

Please sign in to comment.