Three major improvements: 1. Rootless Docker refactor: Removes docker/binary modes, unifies to rootless Docker with per-runner system users. Each runner gets its own rootless Docker daemon, systemd user service, and isolated environment. Simplifies CLI (removes --mode option), Ansible role (single code path), and molecule scenarios (removes binary scenario). 2. Auto-merge fix: Fixes status check context mismatch in branch protection (was requiring "lint", "unit-tests", "molecule-tests" but actual contexts are "CI / quality", "CI / molecule-tests*"). Adds retry/wait logic to auto_merge.py that polls commit statuses for up to 15 minutes before attempting merge, eliminating the chicken-and-egg problem where auto-merge would fail because CI hadn't completed yet. 3. Molecule platform matrix: Adds OS platform matrix to CI — all 6 scenarios now run on all 4 supported OSes (ubuntu-2204, ubuntu-2404, debian-12, archlinux) = 24 test pairs distributed across 3 parallel runners. Updates distribute_molecule.py to distribute (scenario, platform) pairs. Updates Makefile with molecule-all target for local multi-platform testing. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
82 lines
2.8 KiB
Python
82 lines
2.8 KiB
Python
"""Integration tests for Gitea Runner lifecycle commands."""
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
from click.testing import CliRunner
|
|
|
|
from gitea_runner_manager.cli import cli
|
|
|
|
|
|
@pytest.mark.integration
|
|
class TestLifecycleCLI:
|
|
"""Test the full lifecycle CLI commands end-to-end."""
|
|
|
|
@patch("gitea_runner_manager.cli.RunnerManager")
|
|
def test_install_start_status_stop_disable_remove(self, mock_manager_class: MagicMock) -> None:
|
|
"""Exercise the full lifecycle via CLI."""
|
|
mock_manager = MagicMock()
|
|
mock_manager_class.return_value = mock_manager
|
|
|
|
env = {"GITEA_URL": "https://git.example.com", "GITEA_REGISTRATION_TOKEN": "tok"}
|
|
runner = CliRunner(env=env)
|
|
|
|
# Install
|
|
result = runner.invoke(cli, ["install", "host1", "--user", "ubuntu", "--name", "r1"])
|
|
assert result.exit_code == 0
|
|
mock_manager.install.assert_called_once()
|
|
|
|
# Start
|
|
result = runner.invoke(cli, ["start", "r1", "--host", "host1", "--user", "ubuntu", "--no-ask-become-pass"])
|
|
assert result.exit_code == 0
|
|
mock_manager.start.assert_called_once_with(
|
|
host="host1", user="ubuntu", name="r1", key=None, ask_become_pass=False
|
|
)
|
|
|
|
# Status
|
|
result = runner.invoke(cli, ["status", "r1", "--host", "host1", "--user", "ubuntu", "--no-ask-become-pass"])
|
|
assert result.exit_code == 0
|
|
mock_manager.status.assert_called_once_with(
|
|
host="host1", user="ubuntu", name="r1", key=None, ask_become_pass=False
|
|
)
|
|
|
|
# Stop
|
|
result = runner.invoke(cli, ["stop", "r1", "--host", "host1", "--user", "ubuntu", "--no-ask-become-pass"])
|
|
assert result.exit_code == 0
|
|
mock_manager.stop.assert_called_once_with(
|
|
host="host1", user="ubuntu", name="r1", key=None, ask_become_pass=False
|
|
)
|
|
|
|
# Disable
|
|
result = runner.invoke(
|
|
cli,
|
|
["disable", "r1", "--host", "host1", "--user", "ubuntu", "--token", "tok", "--no-ask-become-pass"],
|
|
)
|
|
assert result.exit_code == 0
|
|
mock_manager.disable.assert_called_once_with(
|
|
host="host1",
|
|
user="ubuntu",
|
|
name="r1",
|
|
key=None,
|
|
token="tok",
|
|
gitea_url="https://git.example.com",
|
|
ask_become_pass=False,
|
|
)
|
|
|
|
# Remove
|
|
result = runner.invoke(
|
|
cli,
|
|
["remove", "r1", "--host", "host1", "--user", "ubuntu", "--token", "tok", "--no-ask-become-pass"],
|
|
)
|
|
assert result.exit_code == 0
|
|
mock_manager.remove.assert_called_once_with(
|
|
host="host1",
|
|
user="ubuntu",
|
|
name="r1",
|
|
key=None,
|
|
token="tok",
|
|
gitea_url="https://git.example.com",
|
|
ask_become_pass=False,
|
|
force=False,
|
|
)
|