Skip to content

Commit 41347b6

Browse files
committed
Fix conflict and updated logger
1 parent 2c84cec commit 41347b6

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

.github/workflows/linux-tests.yml

-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ jobs:
4444
linux_tests:
4545
needs: build_container
4646
runs-on: ubuntu-latest
47-
if: false
4847
container:
4948
image: ghcr.io/${{ github.repository_owner }}/conan-tests:${{ needs.build_container.outputs.image_tag }}
5049
options: --user conan
@@ -128,10 +127,6 @@ jobs:
128127
ssh-keygen -t rsa -b 4096 -N "" -f ~/.ssh/id_rsa
129128
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
130129
chmod 600 ~/.ssh/authorized_keys
131-
ssh-keyscan localhost >> ~/.ssh/known_hosts
132-
133-
- name: Test SSH Connection
134-
run: ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no localhost "echo 'SSH Connection Successful!'"
135130
136131
- name: Run runner tests
137132
uses: ./.github/actions/test-coverage

.github/workflows/main.yml

+8-9
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,19 @@ jobs:
2020
uses: ./.github/workflows/linux-tests.yml
2121
name: Linux test suite
2222

23-
# osx_suite:
24-
# uses: ./.github/workflows/osx-tests.yml
25-
# name: OSX test suite
26-
#
27-
# windows_suite:
28-
# uses: ./.github/workflows/win-tests.yml
29-
# name: Windows test suite
23+
osx_suite:
24+
uses: ./.github/workflows/osx-tests.yml
25+
name: OSX test suite
26+
27+
windows_suite:
28+
uses: ./.github/workflows/win-tests.yml
29+
name: Windows test suite
3030

3131
code_coverage:
3232
runs-on: ubuntu-latest
3333
name: Code coverage
3434
if: github.ref == 'refs/heads/develop2' # Only measure code coverage on main branch
35-
# needs: [linux_suite, osx_suite, windows_suite]
36-
needs: [linux_suite]
35+
needs: [linux_suite, osx_suite, windows_suite]
3736
steps:
3837
- name: Checkout code
3938
uses: actions/checkout@v4

conan/internal/runner/output.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
from conan.api.output import Color, ConanOutput
22

33
class RunnerOutput(ConanOutput):
4-
def __init__(self, hostname: str):
4+
def __init__(self, runner_info: str):
55
super().__init__()
66
self.set_warnings_as_errors(True) # Make log errors blocker
7-
self._prefix = f"{hostname} | "
7+
self._prefix = f"{runner_info} | "
88

99
def _write_message(self, msg, fg=None, bg=None, newline=True):
10-
super()._write_message(self._prefix, Color.BLACK, Color.BRIGHT_YELLOW, newline=False)
11-
super()._write_message(msg, fg, bg, newline)
10+
for line in msg.splitlines():
11+
super()._write_message(self._prefix, Color.BLACK, Color.BRIGHT_YELLOW, newline=False)
12+
super()._write_message(line, fg, bg, newline)
1213

1314
@property
1415
def padding(self):
1516
return len(self._prefix) + 1
1617

18+

conan/internal/runner/ssh.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import tempfile
55

66
from conan.api.conan_api import ConanAPI
7-
from conan.api.output import Color
7+
from conan.api.output import Color, ConanOutput
88
from conan.errors import ConanException
99

1010
import os
@@ -38,9 +38,11 @@ def __init__(
3838
hostname = self._create_ssh_connection()
3939
except Exception as e:
4040
raise ConanException(f"Error creating SSH connection: {e}")
41-
self.logger = RunnerOutput(hostname)
41+
self.logger = ConanOutput()
42+
self.logger.set_warnings_as_errors(True)
43+
self.runner_logger = RunnerOutput(hostname)
4244
self.logger.status(f"Connected to {hostname}", fg=Color.BRIGHT_MAGENTA)
43-
self.remote_conn = RemoteConnection(self.client, self.logger)
45+
self.remote_conn = RemoteConnection(self.client, self.runner_logger)
4446

4547
def run(self):
4648
self._ensure_runner_environment()
@@ -136,7 +138,7 @@ def _ensure_runner_environment(self):
136138
self.logger.error(f"Unable to create remote venv: {result.stderr}")
137139
self._install_conan_remotely(python_command, requested_conan_version)
138140
else:
139-
version = self.remote_conn.run_command(f"{conan_cmd} --version").stdout
141+
version = self.remote_conn.run_command(f"{conan_cmd} --version", verbose=True).stdout
140142
remote_conan_version = Version(version[version.rfind(" ")+1:])
141143
if requested_conan_version == "dev" and remote_conan_version.bump(1) == str(conan_version).replace("-dev", ""):
142144
pass
@@ -172,8 +174,7 @@ def _create_remote_conan_wrapper(self, remote_conan_home: str, remote_folder: st
172174
conan_wrapper_contents = f"""{env_lines}\n{conan_cmd} $@\n"""
173175

174176
self.remote_conan = self.remote_conn.create_remote_script(conan_wrapper_contents, remote_folder + "/conan", self.is_remote_windows)
175-
conan_config_home = self.remote_conn.run_command(f"{self.remote_conan} config home").stdout
176-
self.logger.verbose(f"Remote conan config home returned: {conan_config_home}")
177+
self.remote_conn.run_command(f"{self.remote_conan} config home", verbose=True)
177178
if not self.remote_conn.run_command(f"{self.remote_conan} profile detect --force"):
178179
self.logger.error("Error creating default profile in remote machine")
179180

@@ -319,11 +320,15 @@ def __init__(self, success, stdout, stderr):
319320
self.stdout = stdout
320321
self.stderr = stderr
321322

322-
def run_command(self, command: str) -> RunResult:
323+
def run_command(self, command: str, verbose: bool = False) -> RunResult:
323324
_, stdout, stderr = self.client.exec_command(command)
324-
return RemoteConnection.RunResult(stdout.channel.recv_exit_status() == 0,
325-
stdout.read().decode().strip(),
326-
stderr.read().decode().strip())
325+
log = self.logger.status if verbose else self.logger.verbose
326+
log(f'$ {command}', fg=Color.BLUE)
327+
result = RemoteConnection.RunResult(stdout.channel.recv_exit_status() == 0,
328+
stdout.read().decode().strip(),
329+
stderr.read().decode().strip())
330+
log(f"{result.stdout}")
331+
return result
327332

328333
def run_interactive_command(self, command: str, is_remote_windows: bool) -> bool:
329334
''' Run a command in an SSH session.
@@ -366,6 +371,5 @@ def replace_cursor_match(match):
366371
# sys.stdout.buffer.write(line)
367372
# sys.stdout.buffer.flush()
368373
line = remove_cursor_movements(line.replace(b'\r', b'').decode(errors='ignore').strip())
369-
for l in line.splitlines():
370-
self.logger.status(l)
374+
self.logger.status(line)
371375
return stdout.channel.recv_exit_status() == 0

0 commit comments

Comments
 (0)