From 3a6558a299ee60d19db5bde48be5d50282324a9b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 03:35:05 +0000 Subject: [PATCH 1/2] Initial plan From 7df02840ffbcc751e77f764c96ee37c3543b9dec Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 03:41:10 +0000 Subject: [PATCH 2/2] Enable parallel pytest execution with -n auto as default Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com> --- .github/workflows/test.yml | 27 +++++++++++++++++++++++++++ README.md | 32 ++++++++++++++++---------------- pyproject.toml | 3 +++ 3 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..8fff4594 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +name: Test + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Set up uv + uses: astral-sh/setup-uv@v4 + + - name: Set up Python + run: uv python install 3.13 + + - name: Install dependencies + run: uv sync --all-extras + + - name: Run tests + run: uv run pytest tests/ -n auto -v diff --git a/README.md b/README.md index 163a56ee..561911cc 100644 --- a/README.md +++ b/README.md @@ -126,41 +126,41 @@ This project includes a comprehensive test suite to ensure code quality and corr ### Running Tests -**Basic test execution:** +**Basic test execution (parallel by default):** ```bash # Install dev dependencies first -pip install pytest pytest-mock pytest-xdist +uv sync --all-extras -# Run all tests -pytest tests/ +# Run all tests (uses -n auto by default via pyproject.toml) +uv run pytest tests/ ``` -**Parallel test execution (recommended):** +**Parallel test execution:** ```bash -# Run tests in parallel using all available CPU cores -pytest tests/ -n auto +# Run tests in parallel using all available CPU cores (default via addopts) +uv run pytest tests/ -n auto # Run with specific number of workers -pytest tests/ -n 4 +uv run pytest tests/ -n 4 ``` -**Note on parallel execution:** The test suite is currently small (~78 tests, <1s execution time), so parallel execution overhead may result in longer wall-clock time compared to sequential execution. However, pytest-xdist is included for: +**Note on parallel execution:** Parallel execution is configured as the default via `addopts = "-n auto"` in `pyproject.toml`. pytest-xdist provides: - **Test isolation verification** - Ensures tests don't share state -- **Future scalability** - As the test suite grows, parallel execution will provide significant speedups -- **CI optimization** - May benefit from parallelization in CI environments with different characteristics +- **Faster CI runs** - Parallel execution reduces test suite time, especially as the suite grows +- **Scalability** - As the test suite grows, parallelization provides increasing speedups ### Development Workflow For active development with frequent test runs: ```bash -# Run tests sequentially (faster for small test suites) -pytest tests/ -v +# Run tests in parallel (default) +uv run pytest tests/ -v # Run specific test file -pytest tests/test_security.py -v +uv run pytest tests/test_security.py -v # Run tests matching pattern -pytest tests/ -k "test_validation" -v +uv run pytest tests/ -k "test_validation" -v ``` ## Release Process @@ -170,7 +170,7 @@ This project uses manual releases via GitHub Releases. To create a new release: 1. **Ensure all changes are tested and merged to `main`** ```bash # Verify tests pass - pytest tests/ + uv run pytest tests/ # Verify security scans pass bandit -r main.py -ll diff --git a/pyproject.toml b/pyproject.toml index 484682a8..66217a5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,3 +16,6 @@ dev = [ "pytest-xdist>=3.0.0", "pytest-benchmark>=4.0.0", ] + +[tool.pytest.ini_options] +addopts = "-n auto"