Skip to content

Commit

Permalink
add rust projects to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
daywalker90 committed Feb 6, 2024
1 parent 9218629 commit 988dd60
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .ci/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def enumerate_plugins(basedir: Path) -> Generator[Plugin, None, None]:
]
print(poetry_pytest)

rust_pytest = [
x for x in plugins if (x / Path("Cargo.toml")).exists()
]

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

for p in sorted(rust_pytest):
yield Plugin(
name=p.name,
path=p,
language="rust",
framework="cargo",
details={
"cargo": p / Path("Cargo.toml"),
}
)

def prepare_env(p: Plugin, directory: Path) -> bool:
""" Returns whether we can run at all. Raises error if preparing failed.
"""
Expand All @@ -91,6 +106,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 == "cargo":
return prepare_env_cargo(p, directory)
else:
raise ValueError(f"Unknown framework {p.framework}")

Expand Down Expand Up @@ -163,6 +180,21 @@ def prepare_env_pip(p: Plugin, directory: Path):
return True


def prepare_env_cargo(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,
)

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
cln_path = os.environ['CLN_PATH']
Expand Down

0 comments on commit 988dd60

Please sign in to comment.