Conversation
Introduce a new GitHub Actions workflow (.github/workflows/test-system-utils.yml) that runs unit tests, distro-based integration tests in container images (ubuntu, debian, fedora, rocky) to validate package manager and systemctl detection, and an audit job that greps migrated service files for raw subprocess patterns. Add backend/tests/test_utils_system_integration.py: Linux-only integration smoke tests that directly import backend/app/utils/system.py (avoiding Flask deps) to verify PackageManager detection, command availability, and basic ServiceControl behavior. Designed for CI verification of system utilities across real distros.
There was a problem hiding this comment.
Pull request overview
Adds CI coverage to validate backend/app/utils/system.py behavior across real Linux distros and introduces Linux-only integration smoke tests to exercise package manager detection and basic systemctl behavior.
Changes:
- Added a new GitHub Actions workflow to run unit tests, distro-matrix integration tests (Ubuntu/Debian/Fedora/Rocky), and a service audit grep job.
- Added Linux-only integration smoke tests that directly import
backend/app/utils/system.pyto avoid Flask dependencies. - Bumped project version from
1.2.81to1.2.82.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
backend/tests/test_utils_system_integration.py |
Adds Linux-only, no-mock integration smoke tests for PackageManager, is_command_available, and ServiceControl. |
VERSION |
Version bump to reflect the added CI/tests. |
.github/workflows/test-system-utils.yml |
Introduces new CI workflow with unit tests, multi-distro container integration tests, and a subprocess-pattern audit job. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| These run WITHOUT mocks inside actual distro containers (Ubuntu, Fedora, | ||
| Rocky Linux) to verify detection logic works against real package managers | ||
| and systemctl. Designed for CI — skipped on Windows/macOS. |
There was a problem hiding this comment.
Docstring lists the distros as “Ubuntu, Fedora, Rocky Linux” but the workflow matrix also runs Debian. Update the docstring (or the workflow) so the documented set of distros matches what CI actually tests.
| These run WITHOUT mocks inside actual distro containers (Ubuntu, Fedora, | |
| Rocky Linux) to verify detection logic works against real package managers | |
| and systemctl. Designed for CI — skipped on Windows/macOS. | |
| These run WITHOUT mocks inside actual distro containers (Ubuntu, Debian, | |
| Fedora, Rocky Linux) to verify detection logic works against real package | |
| managers and systemctl. Designed for CI — skipped on Windows/macOS. |
|
|
||
| import os | ||
| import platform | ||
| import subprocess |
There was a problem hiding this comment.
subprocess is imported but never used in this test module. Remove the unused import to keep the integration test minimal and avoid confusing readers about intended coverage.
| import subprocess |
| PackageManager = _module.PackageManager | ||
| ServiceControl = _module.ServiceControl | ||
| is_command_available = _module.is_command_available | ||
| run_privileged = _module.run_privileged |
There was a problem hiding this comment.
run_privileged is assigned from _module but never used in this file. Drop the unused alias (or add a smoke test that exercises it) to avoid dead code in the test module.
| run_privileged = _module.run_privileged |
| python3 -c " | ||
| import importlib, os, sys, types | ||
|
|
||
| # Direct import to avoid Flask deps | ||
| mod_path = os.path.join('app', 'utils', 'system.py') |
There was a problem hiding this comment.
The python3 -c snippet is indented inside the quoted string (e.g., leading spaces before import ...), which will raise IndentationError: unexpected indent. Use a heredoc (python3 - <<'PY' ... PY) or a one-line -c string without leading whitespace.
| pull_request: | ||
| branches: [main, dev] | ||
| paths: | ||
| - 'backend/app/utils/system.py' | ||
| - 'backend/app/services/**' | ||
| - 'backend/tests/test_utils_system*.py' |
There was a problem hiding this comment.
on.pull_request.paths does not include .github/workflows/test-system-utils.yml, so PRs that only adjust this workflow file may not trigger the workflow. Add the workflow path to the pull_request path filter to ensure workflow changes are validated in PRs.
Remove the inline "Verify expected package manager" step from the GitHub Actions workflow and add a pytest in backend/tests/test_utils_system_integration.py. The new test (test_matches_expected_manager_from_ci) reads EXPECTED_MANAGER from the environment, skips when not set, and asserts PackageManager.detect() matches the expected value. This consolidates the CI verification into the test suite and simplifies the workflow.
Set DEBIAN_FRONTEND=noninteractive to prevent interactive prompts during image package installs, add shell: bash for the Install step, and normalize command -v checks/redirection so package manager detection and installs behave more reliably. Also remove excessive suppression of apt-get update/install output to surface failures; the pip3 pytest install fallback remains unchanged.
Bump distro images (ubuntu:22.04 -> ubuntu:24.04, fedora:40 -> fedora:41) in the system utils test workflow. Make package installation commands less quiet and more robust: clear /var/lib/apt/lists/* before apt-get update and remove -q flags from apt-get/dnf/yum installs so logs are more informative and apt updates won't fail on stale lists.
Introduce a new GitHub Actions workflow (.github/workflows/test-system-utils.yml) that runs unit tests, distro-based integration tests in container images (ubuntu, debian, fedora, rocky) to validate package manager and systemctl detection, and an audit job that greps migrated service files for raw subprocess patterns. Add backend/tests/test_utils_system_integration.py: Linux-only integration smoke tests that directly import backend/app/utils/system.py (avoiding Flask deps) to verify PackageManager detection, command availability, and basic ServiceControl behavior. Designed for CI verification of system utilities across real distros.