Skip to content

Add system utils CI workflow and integration tests#16

Merged
jhd3197 merged 7 commits intomainfrom
dev
Feb 10, 2026
Merged

Add system utils CI workflow and integration tests#16
jhd3197 merged 7 commits intomainfrom
dev

Conversation

@jhd3197
Copy link
Owner

@jhd3197 jhd3197 commented Feb 10, 2026

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.

jhd3197 and others added 2 commits February 10, 2026 08:25
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.
Copilot AI review requested due to automatic review settings February 10, 2026 13:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py to avoid Flask dependencies.
  • Bumped project version from 1.2.81 to 1.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.

Comment on lines +3 to +5
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.
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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 CIskipped 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 CIskipped on Windows/macOS.

Copilot uses AI. Check for mistakes.

import os
import platform
import subprocess
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
import subprocess

Copilot uses AI. Check for mistakes.
PackageManager = _module.PackageManager
ServiceControl = _module.ServiceControl
is_command_available = _module.is_command_available
run_privileged = _module.run_privileged
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
run_privileged = _module.run_privileged

Copilot uses AI. Check for mistakes.
Comment on lines 92 to 96
python3 -c "
import importlib, os, sys, types

# Direct import to avoid Flask deps
mod_path = os.path.join('app', 'utils', 'system.py')
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +16
pull_request:
branches: [main, dev]
paths:
- 'backend/app/utils/system.py'
- 'backend/app/services/**'
- 'backend/tests/test_utils_system*.py'
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
jhd3197 and others added 5 commits February 10, 2026 16:03
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.
@jhd3197 jhd3197 merged commit dee0355 into main Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant