Skip to content

Commit

Permalink
Use versions based on cln-version-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikDeSmedt committed Apr 23, 2024
1 parent 4e82d79 commit ff383e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 41 deletions.
21 changes: 9 additions & 12 deletions docker/gl-testing/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ RUN mkdir -p /opt/cln/
ENV CLNVM_CACHE_DIR=/opt/cln

ADD libs/cln-version-manager /repo/libs/cln-version-manager
RUN cd /repo/libs/cln-version-manager; python -m pip install .
RUN cd /repo/libs/cln-version-manager; python -m pip install -e .

# RUN /tmp/venv/bin/python -m clnvm get -all
RUN python -m clnvm get-all

# -------------------------------------
# STAGE: bitcoin-downloader
Expand Down Expand Up @@ -220,12 +220,10 @@ ENV RUST_LOG=gl_client=trace,tracing=warn,gl_signerproxy=trace,gl_plugin=trace,l
ENV GRPC_ENABLE_FORK_SUPPORT=0

# Install cln-versions
COPY --from=cln-downloader /repo/cln-versions/ /opt/cln
RUN ln -s /opt/cln/v23.08gl1 /opt/cln-latest
ENV PATH=/opt/cln-latest/usr/local/bin:$PATH

# Enumerate all versions that gl-testing should find
ENV CLN_PATH=/opt/cln/v0.10.1/usr/local/bin/:/opt/cln/v0.10.2/usr/local/bin/:/opt/cln/v0.11.0.1/usr/local/bin/:/opt/cln/v0.11.2gl2/usr/local/bin/:/opt/cln/v22.11gl1/usr/local/bin/:/opt/cln/v23.05gl1/usr/local/bin/:/opt/cln/v23.08gl1/usr/local/bin/
COPY --from=cln-downloader /opt/cln /opt/cln
ENV CLNVM_CACHE_DIR=/opt/cln
# RUN ln -s /opt/cln/v23.08gl1 /opt/cln-latest
# ENV PATH=/opt/cln-latest/usr/local/bin:$PATH

# Install bitcoin-core
COPY --from=bitcoin-downloader /opt/bitcoin/bin /opt/bitcoin/bin
Expand Down Expand Up @@ -254,10 +252,6 @@ RUN groupadd -g $GID -o $DOCKER_USER &&\
useradd -m -u $UID -g $GID -G sudo -o -s /bin/bash $DOCKER_USER && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Configure clnvm
RUN mkdir -p /opt/clnvm; chmod a+rw /opt/clnvm
ENV CLNVM_CACHE_DIR=/opt/clnvm

# Create the required tmp-dicts
RUN chmod a+rw /tmp
RUN mkdir -p /tmp/gltesting/cargo && mkdir -p /tmp/gltesting/tmp
Expand All @@ -269,6 +263,9 @@ WORKDIR /repo
RUN poetry install
RUN chmod -R a+rw /tmp/venv

# Create a symlink to the latest cln-version and add it to the path
RUN ln -s $(clnvm latest --root-path) /opt/cln-latest
ENV PATH=/opt/cln-latest/usr/local/bin:$PATH



35 changes: 6 additions & 29 deletions libs/gl-testing/gltesting/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from dataclasses import dataclass
from pathlib import Path
from threading import Condition
from typing import List, Optional
from typing import Dict, List, Optional

import anyio
import purerpc
Expand All @@ -26,6 +26,7 @@
from gltesting.node import NodeProcess
from gltesting.utils import Network, NodeVersion, SignerVersion

from clnvm import ClnVersionManager

@dataclass
class Node:
Expand Down Expand Up @@ -59,35 +60,11 @@ class InviteCode:
is_redeemed: bool


def enumerate_cln_versions():
def enumerate_cln_versions() -> Dict[str, NodeVersion]:
"""Search `$PATH` and `$CLN_PATH` for CLN versions."""
path = os.environ["PATH"].split(":")
path += os.environ.get("CLN_PATH", "").split(":")
path = [p for p in path if p != ""]

logging.debug(f"Looking for CLN versions in {path}")

version_paths = [shutil.which("lightningd", path=p) for p in path]
version_paths = [p for p in version_paths if p is not None]

versions = {}
for v in version_paths:
lightningd = Path(v).resolve()
path_parts = lightningd.parts
bin_path = Path(*path_parts[:-1])
root_path = Path(*path_parts[:-4])

logging.debug(f"Detecting version of lightningd at {v}")
vs = subprocess.check_output([v, "--version"]).strip().decode("ASCII")
versions[vs] = NodeVersion(
lightningd=lightningd,
bin_path=bin_path,
root_path=root_path,
name=vs)
logging.debug(f"Determined version {vs} for executable {v}")

logging.info(f"Found {len(versions)} versions: {versions}")
return versions
manager = ClnVersionManager()
return manager.get_all()


def generate_secret(len=5):
return "".join(random.choices(string.ascii_uppercase, k=len))
Expand Down

0 comments on commit ff383e3

Please sign in to comment.