From 758e7683dfd1f87f7a68e976cca7fa38abc495e5 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Thu, 30 Jan 2025 13:37:34 +0100 Subject: [PATCH] WIP: testing CI --- .github/workflows/linux-tests.yml | 40 +++++++++++++++++++--- .github/workflows/main.yml | 17 ++++----- conan/internal/runner/ssh.py | 2 +- test/functional/command/ssh_runner_test.py | 16 ++++----- 4 files changed, 53 insertions(+), 22 deletions(-) diff --git a/.github/workflows/linux-tests.yml b/.github/workflows/linux-tests.yml index 1df2d43d13d..f41d0ca25b0 100644 --- a/.github/workflows/linux-tests.yml +++ b/.github/workflows/linux-tests.yml @@ -44,6 +44,7 @@ jobs: linux_tests: needs: build_container runs-on: ubuntu-latest + if: false container: image: ghcr.io/${{ github.repository_owner }}/conan-tests:${{ needs.build_container.outputs.image_tag }} options: --user conan @@ -90,13 +91,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 @@ -114,11 +115,40 @@ jobs: pip install -r conans/requirements_server.txt pip install -r conans/requirements_runner.txt - - name: Run tests + - name: Install OpenSSH Server + run: sudo apt-get update && sudo apt-get install -y openssh-server + + - name: Configure SSH Daemon + 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 + + - name: Generate SSH Keys & Configure Access + run: | + 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 + ssh-keyscan localhost >> ~/.ssh/known_hosts + + - name: Test SSH Connection + run: ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no localhost "echo 'SSH Connection Successful!'" + + # - name: Run docker tests + # uses: ./.github/actions/test-coverage + # with: + # python-version: ${{ matrix.python-version }} + # test-type: docker + # tests: '-m docker_runner -rs' + # duration: 20 + # workers: 1 + + - name: Run ssh tests uses: ./.github/actions/test-coverage with: python-version: ${{ matrix.python-version }} - test-type: docker - tests: '-m docker_runner -rs' + test-type: ssh + tests: '-m ssh_runner -rs' duration: 20 workers: 1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 02a8ad19907..1a820b27192 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,19 +20,20 @@ jobs: uses: ./.github/workflows/linux-tests.yml name: Linux test suite - osx_suite: - uses: ./.github/workflows/osx-tests.yml - name: OSX test suite - - windows_suite: - uses: ./.github/workflows/win-tests.yml - name: Windows test suite + # osx_suite: + # uses: ./.github/workflows/osx-tests.yml + # name: OSX test suite + # + # windows_suite: + # uses: ./.github/workflows/win-tests.yml + # name: Windows test suite code_coverage: runs-on: ubuntu-latest name: Code coverage if: github.ref == 'refs/heads/develop2' # Only measure code coverage on main branch - needs: [linux_suite, osx_suite, windows_suite] + # needs: [linux_suite, osx_suite, windows_suite] + needs: [linux_suite] steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/conan/internal/runner/ssh.py b/conan/internal/runner/ssh.py index 35c52f2133a..512063dbe3b 100644 --- a/conan/internal/runner/ssh.py +++ b/conan/internal/runner/ssh.py @@ -259,7 +259,7 @@ def _update_local_cache(self, json_result: str): if stdout.channel.recv_exit_status() != 0: raise ConanException("Unable to save remote conan cache state") - with tempfile.TemporaryDirectory(delete=False) as tmp: + with tempfile.TemporaryDirectory() as tmp: local_cache_tgz = os.path.join(tmp, 'cache.tgz') self.remote_conn.get(conan_cache_tgz, local_cache_tgz) self.logger.verbose("Retrieved local cache: " + local_cache_tgz) diff --git a/test/functional/command/ssh_runner_test.py b/test/functional/command/ssh_runner_test.py index 77233a1085d..c26609c5d46 100644 --- a/test/functional/command/ssh_runner_test.py +++ b/test/functional/command/ssh_runner_test.py @@ -1,3 +1,4 @@ +from pathlib import Path import pytest import textwrap from conan.test.utils.tools import TestClient @@ -40,8 +41,8 @@ def test_create_ssh_runner_only_host(): assert "[100%] Built target example" in client.out assert "Restore: pkg/1.0 in pkgc8bc87152b946" in client.out - assert "Restore: pkg/1.0:746e4557a2789d2071a4b9fb6b4960d7d548ced9 in b/pkg8070ba4308584/p" in client.out - assert "Restore: pkg/1.0:746e4557a2789d2071a4b9fb6b4960d7d548ced9 metadata in b/pkg8070ba4308584/d/metadata" in client.out + assert "Restore: pkg/1.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe" in client.out + assert "Restore: pkg/1.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata" in client.out @pytest.mark.ssh_runner def test_create_ssh_runner_with_config(): @@ -88,11 +89,10 @@ def test_create_ssh_runner_with_config(): assert "[100%] Built target example" in client.out assert "Restore: pkg/2.0 in pkgc6abef0178849" in client.out - assert "Restore: pkg/2.0:746e4557a2789d2071a4b9fb6b4960d7d548ced9 in b/pkgc1542b12b96fb/p" in client.out - assert "Restore: pkg/2.0:746e4557a2789d2071a4b9fb6b4960d7d548ced9 metadata in b/pkgc1542b12b96fb/d/metadata" in client.out + assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe" in client.out + assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata" in client.out - - client.save({".ssh/config": ssh_config}, path='~') + client.save({"config": ssh_config}, path=Path.home() / ".ssh") profile_host = textwrap.dedent(f"""\ [settings] arch={{{{ detect_api.detect_arch() }}}} @@ -113,5 +113,5 @@ def test_create_ssh_runner_with_config(): assert "[100%] Built target example" in client.out assert "Restore: pkg/2.0 in pkgc6abef0178849" in client.out - assert "Restore: pkg/2.0:746e4557a2789d2071a4b9fb6b4960d7d548ced9 in b/pkgc1542b12b96fb/p" in client.out - assert "Restore: pkg/2.0:746e4557a2789d2071a4b9fb6b4960d7d548ced9 metadata in b/pkgc1542b12b96fb/d/metadata" in client.out + assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe" in client.out + assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata" in client.out