Commit Graph
39 Commits
Author SHA1 Message Date
Emil Simeonov 3d943b57dc GRM-19: refactor: resolve_runner returns gitea_url, add --url CLI option, force remove improvements, code quality fixes
- _resolve_runner now returns gitea_url from registry so disable/remove
  can reuse the URL stored at install time without requiring env vars.
- Added --url option to install, disable, and remove CLI commands.
- remove(force=True) no longer requires gitea_url or token.
- Moved _parse_status outside the for loop in list_runners.
- Updated all translations and tests to match.
2026-06-19 03:12:04 +02:00
Emil Simeonov a9adb71a08 GRM-17: fix docker inspect Jinja2 conflict and add per-iteration exception handling
- docker inspect -f "{{.State.Status}}" used Go template braces that
  conflicted with Ansible Jinja2 templating in the shell module.
  Ansible tried to parse {{.State.Status}} as a Jinja2 variable (which
  starts with a dot, making it invalid), causing a local template error.
  The outer except Exception caught this immediately, so the fallback
  loop never reached the legacy container name or systemctl checks.

- Replaced with: docker inspect <name> | python3 -c JSON parsing,
  which avoids any brace syntax and uses python3 (already required by
  Ansible on managed nodes).

- Added per-iteration try/except inside the fallback loop so a failure
  on one container name continues to the next fallback instead of
  aborting the entire check.

- Added tests for fallback behavior and binary mode exception path.

128 tests, 100% coverage, ruff + pyright clean
2026-06-19 02:53:26 +02:00
Emil Simeonov 1bbe3b4f43 GRM-17: fix docker mode status detection and systemd template
- systemd template for docker mode now uses Type=oneshot + RemainAfterExit=yes
  so that systemctl is-active returns active when the container is running.
  Previously docker run -d exited immediately, causing systemd to mark the
  service as inactive even though the container was still up.
- grm list now tries multiple container name fallbacks for docker mode:
  1. gitea-runner-{name} (current naming)
  2. gitea-runner-{host} (legacy installs where name defaulted to host)
  3. systemctl is-active gitea-runner@{name} (for installs with fixed template)
- All tests pass, 100% coverage, ruff + pyright clean
2026-06-19 02:47:14 +02:00
Emil Simeonov 12e6ce1601 GRM-17: fix grm list status — use docker inspect for docker mode, add host/user context
- Docker mode runners now check container status via docker inspect
  instead of systemctl is-active, avoiding false unknown when systemd
  service is missing or stderr output is discarded
- Binary mode still uses systemctl is-active with stderr suppressed
- Both modes now show a translated context message before the check so
  users know which host/user each BECOME password prompt belongs to
- Better ansible output filtering: strip CHANGED/FAILED/UNREACHABLE
  header lines and separator noise
- Map Docker container states (running/exited/dead) to systemd vocabulary
- All new user-facing messages fully translated (en/bg/de/ru/zh)
- 125 tests, 100% coverage, pyright clean, ruff clean
2026-06-19 02:35:53 +02:00
Emil Simeonov 51f204f90a GRM-17: fix grm list still showing unknown status for active runners
- run_ad_hoc() now accepts ask_become_pass and check parameters
- list_runners() passes ask_become_pass=True so --ask-become-pass is
  added when running in a TTY, matching playbook behavior
- list_runners() passes check=False so systemctl is-active non-zero
  exit codes (inactive=3, unknown=4) don't raise exceptions; the
  actual status string is parsed from stdout instead
- TTY guard prevents --ask-become-pass from hanging in non-interactive
  environments (CI, scripts)
- 123 tests, 100% coverage, pyright clean, ruff clean
2026-06-19 02:24:03 +02:00
Emil Simeonov ebb1088a8c GRM-18: feat: make --ask-become-pass the default behavior
- Change --ask-become-pass from opt-in to opt-out across all commands
  (install, update, start, stop, enable, disable, status, remove)
- Use Click toggle pattern: --ask-become-pass/--no-ask-become-pass with
  default=True so users are always prompted for sudo unless they
  explicitly opt out
- Update i18n translations for both help texts
- Update all CLI tests to expect ask_become_pass=True as default and
  add test for --no-ask-become-pass
- Update README: remove --ask-become-pass from examples, document
  --no-ask-become-pass for passwordless-sudo setups
- 120 tests, 100% coverage, pyright clean, ruff clean
2026-06-19 02:11:38 +02:00
Emil Simeonov 18760f6a2a GRM-17: fix: make grm list retrieve runner status correctly
- run_ad_hoc() now raises AnsibleError on non-zero exit, surfacing
  stderr instead of silently returning empty stdout
- list_runners() passes become=True to run_ad_hoc since systemctl
  is-active requires root privileges
- Add i18n translations for ad-hoc failure messages
- Add unit test for run_ad_hoc failure case
- Update list_runners test to expect become=True
- 119 tests, 100% coverage, pyright clean, ruff clean
2026-06-19 02:05:06 +02:00
Emil Simeonov 677745ac99 GRM-16: feat: add --force flag to grm remove for unreachable runners
- Add force parameter to RunnerManager.remove() — skips remote Ansible
  playbook and only removes the local registry entry
- Add --force/-f CLI flag to grm remove command
- Add translations for --force help text across all 5 languages
- Add unit tests for force skip and CLI flag propagation
- 118 tests, 100% coverage, pyright clean, ruff clean
2026-06-19 02:00:45 +02:00
Emil Simeonov 6ede871054 GRM-15: fix: eliminate duplicate console output, restore GRM_LOG_LEVEL filtering
- Remove console StreamHandler from get_logger() — say() already handles
  console output via click.echo(); having both caused every message to
  appear twice
- Move GRM_LOG_LEVEL filtering into ui.say() via _console_level() so
  console verbosity is still user-controllable while the log file always
  captures everything at DEBUG
- Remove [GRM] prefix from say() calls — no longer needed without
  duplicate logger output, giving cleaner user-facing messages
- Update test_logging_config.py: remove console handler tests and
  _level_from_env tests (now in test_ui.py), expect 1 handler only
- Add test_ui.py coverage for _console_level and say() level filtering
- Update README to document single-path console output via click.echo
- 116 tests, 100% coverage, pyright clean, ruff clean
2026-06-19 01:54:05 +02:00
Emil Simeonov 47d5df0aed GRM-15: feat: add colorized output for better visual feedback
- Extend ui.say() with optional color parameter using click.style()
- Console output gets tinted; log file always stores plain text (no ANSI)
- executor.py: cyan for start, yellow for status, green for done, red for errors
- report.py: bright_cyan header, green completed, red failed, yellow in-progress,
  white pending
- Update README with colorized output documentation
- 117 tests, 100% coverage, pyright clean, ruff clean
2026-06-19 01:32:45 +02:00
Emil Simeonov 3f7507500b GRM-14: feat: use click.echo() for user-facing messages with dual logging
- Create ui.py with say() helper that routes messages to both click.echo()
  (console/stdout, user-facing) and logging.getLogger('grm') (file audit trail)
- Update executor.py: replace logger.info() with say() for start, status, done
  messages; use say(level=ERROR, err=True) before raising AnsibleError
- Update report.py: replace logger.info() with say() for operation report lines
- Update all unit tests to patch say() instead of using capsys or get_logger
- Add test_ui.py with coverage for say() calling both click.echo and logging
- 117 tests, 100% coverage, pyright clean, ruff clean
2026-06-19 01:30:14 +02:00
Emil Simeonov 3b3e002f7f GRM-13: feat: replace print() with stdlib logging module
- Create logging_config.py with get_logger() providing dual handlers:
  - Console handler (stderr) controlled by GRM_LOG_LEVEL env var (default INFO)
  - File handler (~/.local/state/grm/logs/grm.log) capturing everything at DEBUG
- Replace all print() calls in executor.py and report.py with logger.info()/error()
- Add error logging before raising AnsibleError in executor.run()
- Add GRM_LOG_LEVEL to README configuration table and logging documentation
- Update all unit tests to mock logger instead of using capsys
- 114 tests, 100% coverage, pyright clean, ruff clean
2026-06-19 01:24:35 +02:00
Emil Simeonov 815b59c537 GRM-12: feat: add translated operation report for success and failure cases
- Create StepTracker context manager in new report.py module
- Track each step of lifecycle operations (install, update, start, stop, enable,
  disable, status, remove) with begin/done markers
- On success: report lists all completed steps with ✓ icons
- On failure: report shows failed step (✗), completed steps before failure (✓),
  and pending steps that never started (○)
- Add translations for report header, status labels, and registry step names
  in all 5 supported languages (EN/BG/DE/RU/ZH)
- 105 tests, 100% coverage, pyright clean, ruff clean
2026-06-19 01:16:39 +02:00
Emil Simeonov 3b68302274 GRM-11: i18n: translate all remaining user-facing strings 2026-06-19 00:57:26 +02:00
Emil Simeonov b3ac955515 GRM-10: refactor: deduplicate CLI, remove dead code, move validation to business layer 2026-06-19 00:57:26 +02:00
Emil Simeonov 4c08606d0c GRM-9: feat: add runner registry for simplified CLI UX 2026-06-19 00:57:26 +02:00
Emil Simeonov a575a89026 GRM-16: test: add molecule lifecycle scenarios, integration tests, and docs
- Add multi-instance molecule scenario verifying isolated data/config dirs
- Add lifecycle molecule scenario testing stop/disable/enable/start sequence
- Update default and binary verify playbooks for template unit assertions
- Add integration tests for full CLI lifecycle and multi-instance support
- Add pytest integration marker and --no-cov Makefile target
- Update README with lifecycle commands, multi-instance examples, and architecture
- Update Makefile with start/stop/enable/disable/status/remove targets
- Update .env.example with GRM_LANG documentation
2026-06-18 23:14:02 +02:00
Emil Simeonov adb758f5f5 GRM-15: feat: add lifecycle CLI commands and RunnerManager extensions
- Add start, stop, enable, disable, status, remove methods to RunnerManager
- Add corresponding CLI subcommands: grm start/stop/enable/disable/status/remove
- Add i18n translations for lifecycle commands across all supported languages
- Add comprehensive unit tests for lifecycle methods and CLI commands
- Fix environment variable leakage in CLI tests for GITEA_URL
2026-06-18 22:59:50 +02:00
Emil Simeonov e5964ca5a9 GRM-14: feat: add systemd template units and multi-instance Ansible support
- Add instance-scoped base data/config directories in defaults
- Create gitea-runner@.service.j2 template supporting Docker and binary modes
- Refactor service.yml to install systemd template unit instances
- Remove direct container lifecycle from docker_mode.yml (delegate to systemd)
- Add deregister.yml for runner deregistration on disable/remove
- Create lifecycle playbooks: start, stop, enable, disable, status, remove
- Update handlers, integration_test, docker_update, binary_update for template units
2026-06-18 22:59:04 +02:00
Emil Simeonov 047ee05fa1 GRM-7: feat: integrate AnsibleExecutor and i18n into CLI and RunnerManager 2026-06-18 20:17:07 +02:00
Emil Simeonov 564c12e782 GRM-8: feat: add AnsibleExecutor and i18n modules 2026-06-18 20:16:50 +02:00
Emil Simeonov 6414f2306c GRM-13: fix: rewrite integration test to verify .runner file and container health instead of unreliable API checks 2026-06-18 09:34:45 +02:00
Emil Simeonov 1ad7c0a816 GRM-12: fix: convert runner config from TOML to YAML format 2026-06-18 04:47:41 +02:00
Emil Simeonov 68dcbc9b16 GRM-12: docs: update .env.example with GITEA_ADMIN_TOKEN and scope requirements 2026-06-18 04:41:09 +02:00
Emil Simeonov 9378451a12 GRM-12: fix: remove recursive var definitions from install-runner.yml 2026-06-18 04:40:11 +02:00
Emil Simeonov e08c11ea83 GRM-12: feat: add GITEA_ADMIN_TOKEN support for integration test 2026-06-18 04:37:05 +02:00
Emil Simeonov 81dd11e720 GRM-12: fix: make integration test conditional on admin API accessibility 2026-06-18 04:34:28 +02:00
Emil Simeonov a05cd1c7ee GRM-12: fix: set Docker working dir to /data for .runner persistence 2026-06-18 04:29:24 +02:00
Emil Simeonov 55fee77c91 GRM-11: fix: override Docker container entrypoint to bypass run.sh wrapper 2026-06-18 04:23:14 +02:00
Emil Simeonov b48038a3a9 GRM-10: fix: add timeout to runner registration to prevent indefinite hangs 2026-06-18 04:11:43 +02:00
Emil Simeonov 994c30da57 GRM-9: test: add parameterized multi-platform Molecule testing (Arch, Ubuntu 24/26, Debian 12/13) 2026-06-18 04:09:27 +02:00
Emil Simeonov aef24352c1 GRM-8: fix: remove recursive variable definitions in install and update playbooks 2026-06-18 03:50:08 +02:00
Emil Simeonov 8c385dcbdc GRM-7: docs: overhaul README and add project documentation 2026-06-18 03:36:20 +02:00
Emil Simeonov 2530ec54cc GRM-6: fix: resolve idempotence issues and testing infrastructure 2026-06-18 03:36:20 +02:00
Emil Simeonov cc000c226c GRM-5: feat: parameterize all hardcoded configuration values as Ansible variables 2026-06-18 03:36:20 +02:00
Emil Simeonov 0cea9b9490 GRM-4: refactor: consolidate systemd checks and deduplicate role structure 2026-06-18 03:36:19 +02:00
Emil Simeonov b3838eb180 GRM-3: refactor: migrate source terminology from act_runner to gitea_runner 2026-06-18 03:36:19 +02:00
Emil Simeonov 3c8654342f GRM-2: refactor: remove dead code and legacy artifacts 2026-06-18 03:36:19 +02:00
Emil Simeonov 170b53ad28 GRM-1: feat: initial implementation of Gitea Runner Manager v0.1.0 2026-06-17 18:15:28 +02:00