|
| 1 | +name: Test ssh |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - ipyparallel/cluster/launcher.py |
| 7 | + - ipyparallel/cluster/shellcmd* |
| 8 | + - ipyparallel/tests/test_ssh.py |
| 9 | + - ipyparallel/tests/test_shellcmd.py |
| 10 | + - ci/ssh/** |
| 11 | + - .github/workflows/test-ssh.yml |
| 12 | + push: |
| 13 | + paths: |
| 14 | + - ipyparallel/cluster/launcher.py |
| 15 | + - ipyparallel/cluster/shellcmd* |
| 16 | + - ipyparallel/tests/test_ssh.py |
| 17 | + - ipyparallel/tests/test_shellcmd.py |
| 18 | + - ci/ssh/** |
| 19 | + - .github/workflows/test-ssh.yml |
| 20 | + branches-ignore: |
| 21 | + - "pre-commit-ci*" |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: >- |
| 25 | + ${{ github.workflow }}- |
| 26 | + ${{ github.ref_type }}- |
| 27 | + ${{ github.event.pull_request.number || github.sha }} |
| 28 | + cancel-in-progress: true |
| 29 | + |
| 30 | +env: |
| 31 | + # UTF-8 content may be interpreted as ascii and causes errors without this. |
| 32 | + LANG: C.UTF-8 |
| 33 | + IPP_DISABLE_JS: "1" |
| 34 | + JUPYTER_PLATFORM_DIRS: "1" |
| 35 | + |
| 36 | +jobs: |
| 37 | + test: |
| 38 | + runs-on: ${{ matrix.runs_on || 'ubuntu-22.04' }} |
| 39 | + timeout-minutes: 45 |
| 40 | + |
| 41 | + strategy: |
| 42 | + # Keep running even if one variation of the job fail |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + include: |
| 46 | + - python: "3.9" |
| 47 | + - python: "3.12" |
| 48 | + runs_on: windows-2022 |
| 49 | + |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - name: Get Docker infos |
| 54 | + run: | |
| 55 | + docker version |
| 56 | + docker images |
| 57 | +
|
| 58 | + - name: Set up docker-compose for ssh linux launcher |
| 59 | + if: ${{ !contains(matrix.runs_on, 'windows') }} |
| 60 | + run: | |
| 61 | + export DOCKER_BUILDKIT=1 |
| 62 | + export COMPOSE_DOCKER_CLI_BUILD=1 |
| 63 | + cd ci/ssh |
| 64 | + docker compose up -d --build |
| 65 | +
|
| 66 | + # retrieve id_rsa file for public key authentication |
| 67 | + mkdir ~/.ssh/ |
| 68 | + docker cp ssh-sshd-1:/home/ciuser/.ssh/id_rsa ~/.ssh/id_rsa |
| 69 | + cat ~/.ssh/id_rsa |
| 70 | +
|
| 71 | + #check ssh connection and accept host key (for future ssh commands) |
| 72 | + ssh -o "StrictHostKeyChecking no" [email protected] -p 2222 -v echo "ssh connection to container succeeded" |
| 73 | +
|
| 74 | + - name: Set up docker-compose for ssh windows launcher |
| 75 | + if: ${{ contains(matrix.runs_on, 'windows') }} |
| 76 | + env: |
| 77 | + |
| 78 | + SSH_PORT: 2222 |
| 79 | + CODE_ROOT: c:\src\ipyparallel |
| 80 | + run: | |
| 81 | + cd ci/ssh |
| 82 | + # determine host ip and place it as 'static' env variables in corresponding docker compose file (win_Dockerfile_template -> win_Dockerfile) |
| 83 | + $env:docker_host_ip=(Get-NetIPConfiguration -InterfaceAlias "Ethernet*").IPv4Address.IPAddress.Trim() |
| 84 | + $content = Get-Content "win_Dockerfile_template" |
| 85 | + $content | ForEach-Object { |
| 86 | + $_ -replace '\${docker_host_ip}', $env:docker_host_ip -replace '\${docker_host_name}', $env:computername |
| 87 | + } | Set-Content "win_Dockerfile" |
| 88 | + docker compose -f win_docker-compose.yaml up -d --build |
| 89 | +
|
| 90 | + # retrieve id_rsa file for public key authentication |
| 91 | + mkdir $env:USERPROFILE/.ssh/ |
| 92 | + docker run ipyparallel-sshd powershell.exe -Command "type C:\Users\ciuser\.ssh\id_rsa" | out-file -encoding ascii $env:USERPROFILE/.ssh/id_rsa |
| 93 | +
|
| 94 | + #check ssh connection and accept host key (with arbitrary windows command) |
| 95 | + ssh -o "StrictHostKeyChecking no" $env:SSH_HOST -p $env:SSH_PORT -v echo "ssh connection to container succeeded" |
| 96 | +
|
| 97 | + # copy ipyparallel code to docker container (use zip, scp and unzip) |
| 98 | + ssh $env:SSH_HOST -p $env:SSH_PORT mkdir $env:CODE_ROOT |
| 99 | +
|
| 100 | + # zip ipyparallel files (excluding files probably not needed) |
| 101 | + cd ../.. |
| 102 | + $exclude = @("__pycache__", "node_modules", ".yarn") |
| 103 | + $files = Get-ChildItem -Path "." -Exclude $exclude |
| 104 | + Compress-Archive -Path $files -DestinationPath ipyparallel.zip -CompressionLevel Fastest |
| 105 | + # copy file into docker (we need to do it over ssh since docker copy or mount doesn't work in Hyper-V) |
| 106 | + scp -P $env:SSH_PORT ipyparallel.zip ${env:SSH_HOST}:${env:CODE_ROOT} |
| 107 | + # deflate ipyparallel files |
| 108 | + ssh $env:SSH_HOST -p $env:SSH_PORT powershell.exe -Command "Expand-Archive -Path $env:CODE_ROOT\ipyparallel.zip -DestinationPath $env:CODE_ROOT" |
| 109 | +
|
| 110 | + # pip install ipyparallel files |
| 111 | + #ssh $env:SSH_HOST -p $env:SSH_PORT "echo IPP_DISABLE_JS=$env:IPP_DISABLE_JS" |
| 112 | + ssh $env:SSH_HOST -p $env:SSH_PORT "pip install -e file://c:/src/ipyparallel#egg=ipyparallel[test]" |
| 113 | +
|
| 114 | + # we need to disable the windows firewall for github runners otherwise the ipyparallel engines cannot connect to the controller. |
| 115 | + # obviously, a more precautious adaption of the firewall would be desirable. since an adaption of the firewall is NOT necessary |
| 116 | + # for a local standard windows environment, no further improvements were made. |
| 117 | + echo "Disable Firewall:" |
| 118 | + Set-NetFirewallProfile -Profile Domain, Public, Private -Enabled False |
| 119 | +
|
| 120 | + # just see were pip is installed and what libraries are install |
| 121 | + echo "Check pip inside container" |
| 122 | + ssh $env:SSH_HOST -p $env:SSH_PORT "where pip" |
| 123 | + ssh $env:SSH_HOST -p $env:SSH_PORT "pip list" |
| 124 | +
|
| 125 | + echo "Check if container can ping the docker host (requires adapted hosts file and firewall disabled)" |
| 126 | + docker run ipyparallel-sshd ping -n 1 $env:computername |
| 127 | +
|
| 128 | + - name: Install Python ${{ matrix.python }} |
| 129 | + uses: actions/setup-python@v4 |
| 130 | + with: |
| 131 | + python-version: ${{ matrix.python }} |
| 132 | + cache: pip |
| 133 | + |
| 134 | + - name: Install ipyparallel itself |
| 135 | + run: | |
| 136 | + pip install --upgrade pip |
| 137 | + pip install --no-deps . |
| 138 | +
|
| 139 | + - name: Install Python dependencies |
| 140 | + run: | |
| 141 | + pip install --upgrade ipyparallel[test] |
| 142 | +
|
| 143 | + - name: Show environment |
| 144 | + run: pip freeze |
| 145 | + |
| 146 | + - name: Run shellcmd tests |
| 147 | + run: | |
| 148 | + pytest -v --maxfail=2 --cov=ipyparallel ipyparallel/tests/test_shellcmd.py |
| 149 | +
|
| 150 | + - name: Run ssh tests |
| 151 | + run: | |
| 152 | + pytest -v --maxfail=2 --cov=ipyparallel ipyparallel/tests/test_ssh.py |
| 153 | +
|
| 154 | + - name: Submit codecov report |
| 155 | + uses: codecov/codecov-action@v4 |
0 commit comments