diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index b859c1b..4bcb997 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -7,21 +7,35 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v2 + + - name: Set up WSL + if: matrix.os == 'windows-latest' + uses: Vampire/setup-wsl@v2 + with: + distribution: 'Ubuntu-20.04' + use-cache: 'true' + update: 'true' + additional-packages: 'python3-pip' + wsl-shell-user: 'root' + - 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 ".[test,docs]" + - name: Run pytest run: pytest + - name: Upload coverage reports to Codecov if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' uses: codecov/codecov-action@v3 diff --git a/rsync_time_machine.py b/rsync_time_machine.py index 5bc46a0..08f8e0a 100755 --- a/rsync_time_machine.py +++ b/rsync_time_machine.py @@ -8,8 +8,9 @@ import sys import time from datetime import datetime +from pathlib import Path from types import FrameType -from typing import Dict, List, NamedTuple, Optional, Tuple +from typing import Dict, List, NamedTuple, Optional, Tuple, Union APPNAME = "rsync-time-machine.py" VERBOSE = False @@ -322,12 +323,12 @@ def expire_backups( break -def backup_marker_path(folder: str) -> str: +def backup_marker_path(folder: Union[str, Path]) -> Path: """Return the path to the backup marker file.""" - return os.path.join(folder, "backup.marker") + return Path(folder) / "backup.marker" -def find_backup_marker(folder: str, ssh: Optional[SSH]) -> Optional[str]: +def find_backup_marker(folder: str, ssh: Optional[SSH]) -> Optional[Union[str, Path]]: """Find the backup marker file in the given folder.""" marker_path = backup_marker_path(folder) output = find(marker_path, ssh) @@ -375,7 +376,7 @@ def run_cmd( return CmdResult(result.stdout.strip(), result.stderr.strip(), result.returncode) -def find(path: str, ssh: Optional[SSH]) -> str: +def find(path: Union[str, Path], ssh: Optional[SSH]) -> str: """Find files in the given path, using the `find` command.""" return run_cmd(f"find '{path}'", ssh).stdout diff --git a/tests/test_app.py b/tests/test_app.py index 0ed82f9..713a8a1 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -178,7 +178,8 @@ def test_find_backups(tmp_path: Path) -> None: def test_backup_marker_path() -> None: """Test the backup_marker_path function.""" - assert backup_marker_path("/path/to/folder") == "/path/to/folder/backup.marker" + folder = Path("path") / "to" / "folder" + assert backup_marker_path(folder) == folder / "backup.marker" def test_find_backup_marker(tmp_path: Path) -> None: