Skip to content

Add Windows in the tests #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 15 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 6 additions & 5 deletions rsync_time_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down