Skip to content

Add dedicated test workflow with parallel pytest execution#405

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/create-test-workflow
Closed

Add dedicated test workflow with parallel pytest execution#405
Copilot wants to merge 2 commits intomainfrom
copilot/create-test-workflow

Conversation

Copy link

Copilot AI commented Feb 20, 2026

No CI workflow existed to run tests on PRs/pushes, leaving pytest-xdist (already a dev dependency) unused and PRs unvalidated automatically.

Changes

  • .github/workflows/test.yml (new): Runs on push to main, pull_request, and workflow_dispatch. Uses Python 3.13, pip cache keyed on pyproject.toml, installs via pip install -e ".[dev]", and executes pytest tests/ -n auto for parallel distribution across available CPU cores. Scoped to permissions: contents: read.

  • pyproject.toml: Adds [tool.pytest.ini_options] — sets testpaths, discovery patterns, and addopts = "-v --strict-markers" so verbosity and strict markers apply globally without repeating flags per invocation.

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = "test_*.py"
python_functions = "test_*"
addopts = "-v --strict-markers"
Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Create dedicated test workflow with parallel pytest execution</issue_title>
<issue_description>### Description

The project has pytest-xdist configured in pyproject.toml dev dependencies but no dedicated test workflow to run tests in CI. Currently, tests can only be run manually or through custom actions. This creates a gap where PRs aren't automatically validated with test execution.

Problem

  • No .github/workflows/test.yml workflow exists
  • pytest-xdist is installed but not utilized for parallel test execution
  • PRs lack automated test validation
  • Test execution time could be reduced by 40-60% with parallelization

Suggested Changes

  1. Create .github/workflows/test.yml:

    • Trigger on: pull_request, push to main, workflow_dispatch
    • Use Python 3.13 (matching sync.yml)
    • Enable pip caching (matching sync.yml pattern)
    • Install dev dependencies: pip install -e ".[dev]"
    • Run tests with parallel execution: pytest tests/ -n auto -v
  2. Optional: Add pytest configuration in pyproject.toml:

    [tool.pytest.ini_options]
    testpaths = ["tests"]
    python_files = "test_*.py"
    python_functions = "test_*"
    addopts = "-v --strict-markers"

Files Affected

  • .github/workflows/test.yml (new file)
  • pyproject.toml (optional pytest config)

Success Criteria

  • ✅ test.yml workflow runs on PRs and pushes to main
  • ✅ Tests execute in parallel using pytest-xdist (-n auto)
  • ✅ All 19+ test files pass successfully
  • ✅ Pip dependencies are cached for faster CI runs
  • ✅ Test execution time reduced by 40%+ compared to sequential

Priority

High - Improves CI/CD reliability and developer experience with faster feedback

Estimated Effort

1-2 hours

Source

Extracted from Daily Perf Improver discussion abhimehro/ctrld-sync#219 and Daily QA Report abhimehro/ctrld-sync#337

Performance Research Findings (Discussion #219):

Target: Speed up test execution by 40%+

Opportunities:

  • CI dependency caching (pip cache in GitHub Actions)
  • Parallel pytest execution (pytest -n auto)
  • Faster test isolation (pytest-xdist)

QA Report Findings (Discussion #337):

Test execution: Tests run via custom action but no dedicated test.yml workflow for PR validation

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent

To install this workflow, run gh aw add github/gh-aw/.github/workflows/discussion-task-miner.md@94662b1dee8ce96c876ba9f33b3ab8be32de82a4. View source at https://github.com/github/gh-aw/tree/94662b1dee8ce96c876ba9f33b3ab8be32de82a4/.github/workflows/discussion-task-miner.md.

  • expires on Feb 20, 2026, 8:57 PM UTC

Comments on the Issue (you are @copilot in this section)

Custom agent used: Development Partner
The Development Partner Protocol


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@trunk-io
Copy link

trunk-io bot commented Feb 20, 2026

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
Copilot AI changed the title [WIP] Create dedicated test workflow for parallel pytest execution Add dedicated test workflow with parallel pytest execution Feb 20, 2026
Copilot AI requested a review from abhimehro February 20, 2026 03:52
@abhimehro abhimehro marked this pull request as ready for review February 22, 2026 10:11
Copilot AI review requested due to automatic review settings February 22, 2026 10:11
@github-actions
Copy link

👋 Development Partner is reviewing this PR. Will provide feedback shortly.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR creates a dedicated test workflow to automatically run pytest tests on PRs and pushes to main, addressing a gap where the repository had pytest-xdist configured but no CI workflow to leverage it.

Changes:

  • Adds .github/workflows/test.yml to run tests automatically on push/PR with parallel execution via pytest-xdist
  • Adds pytest configuration to pyproject.toml to centralize test discovery patterns and default options

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/test.yml New CI workflow that runs pytest with parallel execution (-n auto) on push to main, pull requests, and manual dispatch
pyproject.toml Adds [tool.pytest.ini_options] section with test discovery patterns and default options (-v --strict-markers)

Comment on lines +19 to +35
# PERFORMANCE: Cache pip dependencies to speed up CI runs
# Cache key is based on pyproject.toml hash since dev deps are defined there
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
cache-dependency-path: 'pyproject.toml'

# Install the package with dev dependencies (pytest, pytest-mock, pytest-xdist)
- name: Install dependencies
run: pip install -e ".[dev]"

# PERFORMANCE: -n auto enables parallel execution via pytest-xdist,
# distributing tests across available CPU cores for 40%+ faster runs
- name: Run tests
run: pytest tests/ -n auto
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow uses pip for dependency installation, but the repository has a uv.lock file and the performance.yml workflow uses uv (astral-sh/setup-uv@v4 + uv sync --all-extras). For consistency with the existing performance workflow and to ensure deterministic builds using the lockfile, this workflow should also use uv. Replace the setup-python caching and pip install steps with uv installation and sync, similar to performance.yml lines 19-30.

Suggested change
# PERFORMANCE: Cache pip dependencies to speed up CI runs
# Cache key is based on pyproject.toml hash since dev deps are defined there
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
cache-dependency-path: 'pyproject.toml'
# Install the package with dev dependencies (pytest, pytest-mock, pytest-xdist)
- name: Install dependencies
run: pip install -e ".[dev]"
# PERFORMANCE: -n auto enables parallel execution via pytest-xdist,
# distributing tests across available CPU cores for 40%+ faster runs
- name: Run tests
run: pytest tests/ -n auto
# Set up Python and uv; uv will manage dependencies via the lockfile
- name: Set up Python with uv
uses: astral-sh/setup-uv@v4
with:
python-version: '3.13'
# Install the package and dependencies using uv and the uv.lock file
# Using --all-extras keeps behavior consistent with installing extras via pip
- name: Install dependencies
run: uv sync --all-extras
# PERFORMANCE: -n auto enables parallel execution via pytest-xdist,
# distributing tests across available CPU cores for 40%+ faster runs
- name: Run tests
run: uv run pytest tests/ -n auto

Copilot uses AI. Check for mistakes.
testpaths = ["tests"]
python_files = "test_*.py"
python_functions = "test_*"
addopts = "-v --strict-markers"
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency and to ensure all pytest invocations benefit from parallel execution (not just CI runs), consider adding "-n auto" to the addopts configuration. This ensures developers running pytest locally and other workflows also get parallel execution by default. Suggested: addopts = "-n auto -v --strict-markers". This aligns with the performance optimization goal mentioned in the PR description and follows the pattern where configuration is centralized in pyproject.toml.

Suggested change
addopts = "-v --strict-markers"
addopts = "-n auto -v --strict-markers"

Copilot uses AI. Check for mistakes.
@abhimehro
Copy link
Owner

Closing: duplicate of test workflow (#395 is superset with uv caching). Use #395 instead.

@abhimehro abhimehro closed this Feb 28, 2026
@abhimehro abhimehro deleted the copilot/create-test-workflow branch March 2, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Quality] Create dedicated test workflow with parallel pytest execution

3 participants