Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Unit Tests

on:
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
test-suite:
- { name: "core", mark: "core" }
- { name: "ps-actions", mark: "ps" }
- { name: "net-actions", mark: "net" }
- { name: "sys-actions", mark: "sys" }
- { name: "device-actions", mark: "device" }
- { name: "docker-actions", mark: "docker" }
- { name: "git-actions", mark: "git" }
- { name: "errors", mark: "errors" }
- { name: "integration", mark: "integration" }
- { name: "logging", mark: "logging" }

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run ${{ matrix.test-suite.name }} tests
run: |
pytest -m ${{ matrix.test-suite.mark }} --cov=remote_machine --cov-report=xml --cov-report=term-missing
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: ${{ matrix.test-suite.name }}
name: ${{ matrix.test-suite.name }}-tests
16 changes: 15 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,21 @@ strict_optional = true
[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
addopts = "-v --cov=remote_machine --cov-report=term-only"
addopts = "-v"
markers = [
"core: Core functionality tests",
"actions: Action module tests",
"protocols: Protocol tests",
"errors: Error handling tests",
"integration: Integration tests",
"ps: Process action tests",
"net: Network action tests",
"sys: System action tests",
"device: Device action tests",
"docker: Docker action tests",
"git: Git action tests",
"logging: Logging and telemetry tests",
]

[dependency-groups]
dev = [
Expand Down
2 changes: 2 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Unit tests for RemoteState and PathResolver."""

import pytest
pytestmark = pytest.mark.core

from remote_machine.types import RemoteState, CommandResult
from remote_machine.utils import PathResolver

Expand Down
3 changes: 3 additions & 0 deletions tests/test_device_actions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Tests for DeviceAction linux_parsers usage."""

import pytest
pytestmark = [pytest.mark.actions, pytest.mark.device]

import sys
import types

Expand Down
2 changes: 2 additions & 0 deletions tests/test_docker_actions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Tests for Docker actions."""

import pytest
pytestmark = [pytest.mark.actions, pytest.mark.docker]

from unittest.mock import Mock
from datetime import datetime

Expand Down
2 changes: 2 additions & 0 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Error mapping and exception tests."""

import pytest
pytestmark = pytest.mark.errors

from remote_machine.types import CommandResult
from remote_machine.errors import (
CommandError,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_git_actions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Tests for Git actions."""

import pytest
pytestmark = [pytest.mark.actions, pytest.mark.git]

from unittest.mock import Mock
from datetime import datetime

Expand Down
3 changes: 3 additions & 0 deletions tests/test_linux_parsers_integration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Tests that SYSAction prefers linux_parsers when available."""

import pytest
pytestmark = pytest.mark.integration

import sys
import types

Expand Down
3 changes: 3 additions & 0 deletions tests/test_net_actions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Tests for NETAction linux_parsers usage."""

import pytest
pytestmark = [pytest.mark.actions, pytest.mark.net]

import sys
import types

Expand Down
3 changes: 3 additions & 0 deletions tests/test_ps_actions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Tests for PSAction linux_parsers usage."""

import pytest
pytestmark = [pytest.mark.actions, pytest.mark.ps]

import sys
import types

Expand Down
3 changes: 3 additions & 0 deletions tests/test_sys_actions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Unit tests for SYSAction parsing behavior."""

import pytest
pytestmark = [pytest.mark.actions, pytest.mark.sys]

import os
import sys

Expand Down
Loading