Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSH Runner: Fix several issues and refactor code #17357

Open
wants to merge 17 commits into
base: develop2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions .github/workflows/linux-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ jobs:
tests: test/${{ matrix.test-type }}
duration: 20

linux_docker_tests:
linux_runner_tests:
needs: build_container
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12, 3.9]
name: Docker Runner Tests (${{ matrix.python-version }})
name: Runner Tests (${{ matrix.python-version }})
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand All @@ -113,12 +113,26 @@ jobs:
pip install -r conans/requirements_dev.txt
pip install -r conans/requirements_server.txt
pip install -r conans/requirements_runner.txt
sudo apt-get update && sudo apt-get install -y openssh-server

- name: Run tests
- name: Install OpenSSH Server
run: sudo apt-get update && sudo apt-get install -y openssh-server

- name: Configure SSH Daemon, Generate SSH Keys & Configure Access
run: |
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo systemctl restart ssh
mkdir -p ~/.ssh
ssh-keygen -t rsa -b 4096 -N "" -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

- name: Run runner tests
uses: ./.github/actions/test-coverage
with:
python-version: ${{ matrix.python-version }}
test-type: docker
tests: '-m docker_runner -rs'
test-type: runners
tests: '-m docker_runner -m ssh_runner -rs'
duration: 20
workers: 1
7 changes: 5 additions & 2 deletions conan/api/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def rewrite_line(self, line):
self.stream.flush()
self._color = tmp_color

def _write_message(self, msg, fg=None, bg=None):
def _write_message(self, msg, fg=None, bg=None, newline=True):
if isinstance(msg, dict):
# For traces we can receive a dict already, we try to transform then into more natural
# text
Expand All @@ -206,8 +206,11 @@ def _write_message(self, msg, fg=None, bg=None):
else:
ret += "{}".format(msg)

if newline:
ret = "%s\n" % ret

with self.lock:
self.stream.write("{}\n".format(ret))
self.stream.write(ret)
self.stream.flush()

def trace(self, msg):
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def create(conan_api, parser, *args):
raise ConanException(f"Invalid runner configuration. 'type' must be defined")
runner_instances_map = {
'docker': DockerRunner,
# 'ssh': SSHRunner,
'ssh': SSHRunner,
# 'wsl': WSLRunner,
}
try:
Expand Down
4 changes: 4 additions & 0 deletions conan/internal/model/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@
"tools.build:linker_scripts": "List of linker script files to pass to the linker used by different toolchains like CMakeToolchain, AutotoolsToolchain, and MesonToolchain",
# Package ID composition
"tools.info.package_id:confs": "List of existing configuration to be part of the package ID",
# Runners
"runner.type": "Type of runner to use. Possible values: docker, ssh",
"runner.ssh.host": "Hostname of the remote machine to connect to",
"runner.ssh.configfile": "(boolean/str) Enable the use of the SSH configuration file (False by default). If a string is provided, it will be used as the path to the SSH configuration file.",
}

BUILT_IN_CONFS = {key: value for key, value in sorted(BUILT_IN_CONFS.items())}
Expand Down
18 changes: 18 additions & 0 deletions conan/internal/runner/output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from conan.api.output import Color, ConanOutput

class RunnerOutput(ConanOutput):
def __init__(self, runner_info: str):
super().__init__()
self.set_warnings_as_errors(True) # Make log errors blocker
self._prefix = f"{runner_info} | "

def _write_message(self, msg, fg=None, bg=None, newline=True):
for line in msg.splitlines():
super()._write_message(self._prefix, Color.BLACK, Color.BRIGHT_YELLOW, newline=False)
super()._write_message(line, fg, bg, newline)

@property
def padding(self):
return len(self._prefix) + 1


Loading
Loading