diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..c5732fe --- /dev/null +++ b/.github/workflows/lint.yml @@ -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/action@v3.0.1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..b795e79 --- /dev/null +++ b/.github/workflows/tests.yml @@ -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 diff --git a/tests/test_execution.py b/tests/test_execution.py index f631a3b..7c9de03 100644 --- a/tests/test_execution.py +++ b/tests/test_execution.py @@ -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]) @@ -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} @@ -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: @@ -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) @@ -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)