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
20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Lint

on:
pull_request:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Run pre-commit
uses: pre-commit/[email protected]
26 changes: 26 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Tests

on:
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "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 dependencies
run: pip install -e .[dev,web]

- name: Run tests
run: pytest --cov=pretty_release_notes --cov-report=term-missing
22 changes: 17 additions & 5 deletions tests/test_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def success_task():
return "success"

# Sequential strategy should raise exception
strategy = SequentialStrategy()
strategy: ExecutionStrategy = SequentialStrategy()
with pytest.raises(ValueError, match="Task failed"):
strategy.execute_parallel([failing_task])

Expand All @@ -129,7 +129,7 @@ def task(value):
values = [1, 2, 3, 4, 5]

# Sequential
strategy = SequentialStrategy()
strategy: ExecutionStrategy = SequentialStrategy()
results = strategy.execute_parallel([task(v) for v in values])
assert set(results) == {2, 4, 6, 8, 10}

Expand All @@ -154,7 +154,7 @@ def test_thread_pool_max_workers_configuration(self):
def test_execution_strategy_is_abstract(self):
"""Test that ExecutionStrategy cannot be instantiated directly."""
with pytest.raises(TypeError):
ExecutionStrategy()
ExecutionStrategy() # type: ignore[abstract]


class TestExecutionPerformance:
Expand Down Expand Up @@ -196,8 +196,14 @@ def process_item(item):
with lock:
results.append(item * 2)

def make_task(item):
def task():
process_item(item)

return task

# Create tasks with proper closure
tasks = [lambda item=item: process_item(item) for item in items]
tasks = [make_task(item) for item in items]

strategy = ThreadPoolStrategy()
strategy.execute_parallel(tasks)
Expand All @@ -218,7 +224,13 @@ def process_item(item):
item.processed = True
item.value *= 2

tasks = [lambda item=item: process_item(item) for item in items]
def make_task(item):
def task():
process_item(item)

return task

tasks = [make_task(item) for item in items]

strategy = ThreadPoolStrategy()
strategy.execute_parallel(tasks)
Expand Down