Skip to content

Commit

Permalink
generic plugin support
Browse files Browse the repository at this point in the history
  • Loading branch information
daywalker90 committed Feb 9, 2024
1 parent 636f4e8 commit d86caf2
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .ci/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def enumerate_plugins(basedir: Path) -> Generator[Plugin, None, None]:
]
print(poetry_pytest)

other_plugins = [x for x in plugins if x not in pip_pytest and x not in poetry_pytest]

for p in sorted(pip_pytest):
yield Plugin(
name=p.name,
Expand All @@ -79,6 +81,18 @@ def enumerate_plugins(basedir: Path) -> Generator[Plugin, None, None]:
}
)

for p in sorted(other_plugins):
yield Plugin(
name=p.name,
path=p,
language="other",
framework="generic",
details={
"requirements": p / Path("tests/requirements.txt"),
"setup": p / Path("tests/setup.sh"),
}
)

def prepare_env(p: Plugin, directory: Path) -> bool:
""" Returns whether we can run at all. Raises error if preparing failed.
"""
Expand All @@ -91,6 +105,8 @@ def prepare_env(p: Plugin, directory: Path) -> bool:
return prepare_env_pip(p, directory)
elif p.framework == "poetry":
return prepare_env_poetry(p, directory)
elif p.framework == "generic":
return prepare_generic(p, directory)
else:
raise ValueError(f"Unknown framework {p.framework}")

Expand Down Expand Up @@ -162,6 +178,34 @@ def prepare_env_pip(p: Plugin, directory: Path):
install_pyln_testing(pip_path)
return True

def prepare_generic(p: Plugin, directory: Path):
pip_path = directory / 'bin' / 'pip3'

# Install pytest (eventually we'd want plugin authors to include
# it in their requirements-dev.txt, but for now let's help them a
# bit).
subprocess.check_call(
[pip_path, 'install', *pip_opts, *global_dependencies],
stderr=subprocess.STDOUT,
)

# Now install all the requirements
if p.details['requirements'].exists():
print(f"Installing requirements from {p.details['requirements']}")
subprocess.check_call(
[pip_path, 'install', '-U', *pip_opts, '-r', p.details['requirements']],
stderr=subprocess.STDOUT,
)

if p.details['setup'].exists():
print(f"Running setup script from {p.details['setup']}")
subprocess.check_call(
['bash', p.details['setup']],
stderr=subprocess.STDOUT,
)
install_pyln_testing(pip_path)
return True


def install_pyln_testing(pip_path):
# Many plugins only implicitly depend on pyln-testing, so let's help them
Expand Down

0 comments on commit d86caf2

Please sign in to comment.