Skip to content

Commit

Permalink
add github actions to run tests
Browse files Browse the repository at this point in the history
phernandez committed Nov 24, 2024
1 parent 8f0d1d5 commit 18aeecb
Showing 5 changed files with 54 additions and 3 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# .github/workflows/test.yml
name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

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

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
uv pip install '.[dev]'
- name: Run tests
run: |
pytest tests/ -v -m "not integration"
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -56,3 +56,6 @@ python_files = [
]
addopts = "-ra -q"

markers = [
"integration: marks tests as integration tests"
]
16 changes: 13 additions & 3 deletions tests/test_git.py
Original file line number Diff line number Diff line change
@@ -8,8 +8,14 @@
@pytest.fixture
def git_repo(tmp_path):
"""Create a temporary git repository with initial commit."""
# Create and init repo
# Create source and remote repo paths
repo_path = tmp_path / "test_repo"
remote_path = tmp_path / "remote_repo"

# Initialize remote repo first (bare repository)
remote_repo = pygit2.init_repository(str(remote_path), bare=True)

# Create and init source repo
repo_path.mkdir()
repo = pygit2.init_repository(str(repo_path))

@@ -29,6 +35,9 @@ def git_repo(tmp_path):
[] # No parent commits
)

# Add remote
repo.remotes.create("origin", str(remote_path))

# Create and return Git instance
config = GitConfig(repo_path)
return Git(config)
@@ -39,10 +48,11 @@ def test_create_hello_world(git_repo):
from basic_factory.git import create_hello_world

# Create hello world files
create_hello_world(git_repo)
create_hello_world(git_repo, stay_on_branch=True) # Stay on the new branch

# Verify branch was created
assert git_repo.repo.head.shorthand == "feature/hello-world"
current_branch = git_repo.get_current_branch()
assert current_branch == "feature/hello-world"

# Verify files exist
hello_path = git_repo.config.repo_path / "src/basic_factory/hello.py"
1 change: 1 addition & 0 deletions tests/test_github.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import pytest
from basic_factory.github import GitHubConfig, GitHubOps

pytestmark = pytest.mark.integration

@pytest.fixture
def github_ops():
1 change: 1 addition & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import pytest
from basic_factory.git import Git, GitConfig

pytestmark = pytest.mark.integration

@pytest.fixture
def working_repo():

0 comments on commit 18aeecb

Please sign in to comment.