Skip to content

Commit

Permalink
WIP: testing CI
Browse files Browse the repository at this point in the history
  • Loading branch information
perseoGI committed Jan 30, 2025
1 parent 0987d24 commit 758e768
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 22 deletions.
40 changes: 35 additions & 5 deletions .github/workflows/linux-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
17 changes: 9 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion conan/internal/runner/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions test/functional/command/ssh_runner_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
import pytest
import textwrap
from conan.test.utils.tools import TestClient
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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() }}}}
Expand All @@ -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

0 comments on commit 758e768

Please sign in to comment.