Skip to content

Commit

Permalink
Only run when docker running and on ubuntu on runners.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeZiminski committed Apr 22, 2024
1 parent 77dfa09 commit b49073e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/code_test_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
"""

name: tests

on:
Expand Down Expand Up @@ -45,13 +48,14 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Shutdown Ubuntu MySQL (SUDO) # free up port 3306 for ssh tests: https://github.com/orgs/community/discussions/25550
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo service mysql stop
fi
- name: Test
run: pytest -k test_combinations_ssh_transfer
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo service mysql stop # free up port 3306 for ssh tests: https://github.com/orgs/community/discussions/25550
pytest
else
pytest -k "not test_combinations_ssh_transfer and not test_ssh_setup"
fi
build_sdist_wheels:
name: Build source distribution
Expand Down
32 changes: 25 additions & 7 deletions tests/ssh_test_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
"""

import builtins
import copy
import os
Expand Down Expand Up @@ -93,8 +97,8 @@ def setup_ssh_connection(project, setup_ssh_key_pair=True):

def setup_project_and_container_for_ssh(project):
""""""
assert is_docker_installed(), (
"docker not installed, "
assert docker_is_running(), (
"docker is not running, "
"this should be checked at the top of test script"
)

Expand Down Expand Up @@ -171,21 +175,35 @@ def recursive_search_central(project):

def get_test_ssh():
""""""
docker_installed = is_docker_installed()
docker_installed = docker_is_running()
if not docker_installed:
warnings.warn("SSH tests are not run as docker is not installed.")
warnings.warn(
"SSH tests are not run as docker either not installed or running."
)
return docker_installed


def docker_is_running():
""""""
if not is_docker_installed():
return False

is_running = check_sys_command_returns_0("docker stats --no-stream")
return is_running


def is_docker_installed():
""""""
check_install = (
lambda command: subprocess.run(
return check_sys_command_returns_0("docker -v")


def check_sys_command_returns_0(command):
return (
subprocess.run(
command,
shell=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
).returncode
== 0
)
return check_install("docker -v")

0 comments on commit b49073e

Please sign in to comment.