Skip to content
35 changes: 32 additions & 3 deletions .github/workflows/auto-init-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,39 @@ jobs:
sudo apt-get update
sudo apt-get install -y google-chrome-stable xvfb

# Install ChromeDriver
# Install ChromeDriver with fallback logic
CHROME_VERSION=$(google-chrome --version | awk '{print $3}' | cut -d. -f1)
CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}")
wget -O /tmp/chromedriver.zip "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip"
echo "Chrome version: $CHROME_VERSION"

# Try to get ChromeDriver for the exact Chrome version
CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}" 2>/dev/null || echo "")

# If that fails, try the previous major version
if [ -z "$CHROMEDRIVER_VERSION" ] || [ "$CHROMEDRIVER_VERSION" = "Not Found" ]; then
echo "ChromeDriver for Chrome $CHROME_VERSION not found, trying previous version..."
CHROME_VERSION=$((CHROME_VERSION - 1))
CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}" 2>/dev/null || echo "")
fi

# If still not found, use a stable fallback version
if [ -z "$CHROMEDRIVER_VERSION" ] || [ "$CHROMEDRIVER_VERSION" = "Not Found" ]; then
echo "Using fallback ChromeDriver version..."
CHROMEDRIVER_VERSION="121.0.6167.85" # Known stable version
fi

echo "Using ChromeDriver version: $CHROMEDRIVER_VERSION"

# Download and install ChromeDriver
wget -O /tmp/chromedriver.zip "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" || {
echo "Failed to download ChromeDriver, trying alternative approach..."
# Alternative: use system package as fallback
echo "Using system ChromeDriver package..."
sudo apt-get install -y chromium-chromedriver
sudo ln -sf /usr/bin/chromedriver /usr/local/bin/chromedriver
chromedriver --version
exit 0
}

sudo unzip /tmp/chromedriver.zip -d /usr/local/bin/
sudo chmod +x /usr/local/bin/chromedriver

Expand Down
38 changes: 36 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,45 @@ jobs:
sudo apt-get update
sudo apt-get install -y google-chrome-stable xvfb

# Install ChromeDriver
# Install ChromeDriver with fallback logic
CHROME_VERSION=$(google-chrome --version | awk '{print $3}' | cut -d. -f1)
wget -O /tmp/chromedriver.zip "https://chromedriver.storage.googleapis.com/$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION})/chromedriver_linux64.zip"
echo "Chrome version: $CHROME_VERSION"

# Try to get ChromeDriver for the exact Chrome version
CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}" 2>/dev/null || echo "")

# If that fails, try the previous major version
if [ -z "$CHROMEDRIVER_VERSION" ] || [ "$CHROMEDRIVER_VERSION" = "Not Found" ]; then
echo "ChromeDriver for Chrome $CHROME_VERSION not found, trying previous version..."
CHROME_VERSION=$((CHROME_VERSION - 1))
CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}" 2>/dev/null || echo "")
fi

# If still not found, use a stable fallback version
if [ -z "$CHROMEDRIVER_VERSION" ] || [ "$CHROMEDRIVER_VERSION" = "Not Found" ]; then
echo "Using fallback ChromeDriver version..."
CHROMEDRIVER_VERSION="121.0.6167.85" # Known stable version
fi

echo "Using ChromeDriver version: $CHROMEDRIVER_VERSION"

# Download and install ChromeDriver
wget -O /tmp/chromedriver.zip "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" || {
echo "Failed to download ChromeDriver, trying alternative approach..."
# Alternative: use system package as fallback
echo "Using system ChromeDriver package..."
sudo apt-get install -y chromium-chromedriver
sudo ln -sf /usr/bin/chromedriver /usr/local/bin/chromedriver
chromedriver --version
exit 0
}

sudo unzip /tmp/chromedriver.zip -d /usr/local/bin/
sudo chmod +x /usr/local/bin/chromedriver

# Verify installation
google-chrome --version
chromedriver --version

- name: Lint with flake8
run: |
Expand Down
18 changes: 9 additions & 9 deletions ssh_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,40 +432,40 @@ def test_connection(self, server_name: str) -> bool:
if server_name not in self.config["servers"]:
self.logger.error(f"Server {server_name} not found in configuration")
return False

server_config = self.config["servers"][server_name]

# Create SSH client
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

# Connection parameters
connect_params = {
"hostname": server_config["host"],
"port": server_config.get("port", 22),
"username": server_config["username"],
"timeout": self.config.get("ssh_settings", {}).get("timeout", 30),
}

# Add authentication
if "password" in server_config:
connect_params["password"] = server_config["password"]
elif "ssh_key" in server_config:
key_path = os.path.expanduser(server_config["ssh_key"])
if os.path.exists(key_path):
connect_params["key_filename"] = key_path

# Test connection
ssh.connect(**connect_params)

# Test with a simple command
stdin, stdout, stderr = ssh.exec_command("echo 'test'")
result = stdout.read().decode().strip()

ssh.close()

return result == "test"

except Exception as e:
self.logger.error(f"Connection test failed for {server_name}: {e}")
return False
Expand Down
Loading
Loading