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 25 commits into
base: develop2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fb4bda4
Fix several issues on SSH runner and refactor code
perseoGI Nov 20, 2024
bf5e761
Log errors blocking and some improvements
perseoGI Nov 21, 2024
e6ee256
Fixed '&' bug and more refactors
perseoGI Nov 22, 2024
16f746a
Private import
perseoGI Nov 22, 2024
777db28
Follow issue reference
perseoGI Nov 22, 2024
25ba67f
Protect possible exception
perseoGI Dec 5, 2024
bb9e378
Update remote and improve logging
perseoGI Dec 9, 2024
ddd7ae2
Apply suggestions from code review
perseoGI Dec 20, 2024
123764e
Change includes after rebase
perseoGI Jan 28, 2025
2557acc
Added ssh runner config list info
perseoGI Jan 28, 2025
c26ccf6
Refactor runner profile structure
perseoGI Jan 28, 2025
20b97e5
WIP
perseoGI Jan 29, 2025
53447aa
Fixed bugs and added functional tests to ssh
perseoGI Jan 30, 2025
2c84cec
WIP: testing CI
perseoGI Jan 30, 2025
41347b6
Fix conflict and updated logger
perseoGI Jan 30, 2025
7f81c22
Add skip_if for ssh runner tests
perseoGI Jan 31, 2025
6231e3d
Improved logs
perseoGI Jan 31, 2025
918f18f
Fix issue when build profile is not present and added tests
perseoGI Feb 4, 2025
5c1c5c9
Removed ssh. prefix on runner config
perseoGI Feb 6, 2025
923d369
Applied changes requested in threads
perseoGI Feb 6, 2025
0545b32
Fix missing import
perseoGI Feb 7, 2025
14a1c6d
Fix https://github.com/conan-io/conan/issues/17746
perseoGI Feb 13, 2025
009d87a
Fix conflict
perseoGI Feb 20, 2025
0c1a03e
Fix merge issue
perseoGI Feb 20, 2025
de318b1
Merge and fix develop2 conflicts
perseoGI Feb 21, 2025
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.host": "Hostname of the remote machine to connect to",
"runner.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