Skip to content

Commit

Permalink
Setup github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
A committed Jul 15, 2024
1 parent 57001eb commit 726e2b3
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 4 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test

on:
push:
branches:
- '*'
- '!master'

env:
PYTHON_VERSION: 3.12.4


jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.12']

name: Python ${{ matrix.python-version }} test

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: install poetry
run: pip install poetry

- name: install deps
run: poetry install

- name: test
run: poetry run pytest --cache-clear --cov=zapusk | tee pytest-coverage.txt

- name: Pytest coverage comment
if: matrix.python-version == '3.12'
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Zapusk is a job runner for desktop environments. It helps you manage background tasks with features like pre-configured job execution, background shell commands, scheduling with cron-like syntax, log tailing, and notifications. It also provides detailed JSON output for easy data manipulation and analysis.


## Key Features

- **Preconfigured Jobs:** Run jobs defined in your configuration files.
Expand Down
4 changes: 2 additions & 2 deletions zapusk/client/command_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
class CommandManager:
def __init__(
self,
config_service=ConfigService(),
config_service=None,
output=Output(),
colors=None,
api_client: Optional[ApiClient] = None,
) -> None:
self.output = output
self.config_service = config_service
self.config_service = config_service if config_service else ConfigService()
config = self.config_service.get_config()

self.api_client = (
Expand Down
15 changes: 15 additions & 0 deletions zapusk/client/command_testcase.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
from unittest import TestCase
from unittest.mock import MagicMock
from zapusk.client.api_client import ApiClient
from testfixtures import TempDirectory

from zapusk.services.config.service import ConfigService

from .output import Output
from .command_manager import CommandManager


CONFIG_DATA = ""


class CommandTestCase(TestCase):
def setUp(self) -> None:
self.temp_dir = TempDirectory()
self.config_file = self.temp_dir / "config.yml"
self.config_file.write_text(CONFIG_DATA)
self.config_service = ConfigService(
config_path=f"{self.temp_dir.path}/config.yml"
)

self.printer = MagicMock()
self.output = Output(
printer=self.printer,
Expand All @@ -18,9 +31,11 @@ def setUp(self) -> None:
output=self.output,
api_client=self.api_client,
colors=False,
config_service=self.config_service,
)
return super().setUp()

def tearDown(self) -> None:
self.temp_dir.cleanup()
self.printer.reset_mock()
return super().tearDown()
3 changes: 1 addition & 2 deletions zapusk/services/scheduler_service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


logger = logging.getLogger(__name__)
config_service = ConfigService()


class SchedulerService:
Expand All @@ -22,7 +21,7 @@ def __init__(
interval: float = 1,
) -> None:
self.__interval = interval
self.__config_service = config_service
self.__config_service = config_service if config_service else ConfigService()
self.__executor_manager_service = executor_manager_service
self.__scheduled_jobs = [j for j in config_service.list_jobs() if j.schedule]
logger.info(f"Scheduled jobs detected {[i.id for i in self.__scheduled_jobs]}")
Expand Down

0 comments on commit 726e2b3

Please sign in to comment.