Skip to content

ci: add automatic unit test workflow#487

Open
gltanaka wants to merge 4 commits intomainfrom
ci/unit-tests
Open

ci: add automatic unit test workflow#487
gltanaka wants to merge 4 commits intomainfrom
ci/unit-tests

Conversation

@gltanaka
Copy link
Contributor

Summary

  • Adds a new GitHub Actions workflow that runs pytest with marker-based exclusions on PRs and pushes to main
  • Excludes tests marked integration, e2e, or real (those requiring paid API calls)
  • Skips draft PRs and docs/config-only changes via paths-ignore

Test plan

  • Verify this PR triggers the workflow and it passes
  • Confirm marker exclusions correctly skip paid-API tests

🤖 Generated with Claude Code

Runs pytest with marker-based exclusions (-m "not integration and not e2e and not real") to skip tests requiring paid API calls. Triggers on PRs to main and pushes to main (with path exclusions for docs/config-only changes).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Install pytest-timeout and use --timeout=60 to kill hanging tests
  (e.g. test_connect_defaults hangs ~15min due to unmocked cloud calls)
- Use pytest-xdist -n auto for parallel execution across CPU cores
- pytest-xdist is already in [dev] extras

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Set PDD_PATH env var pointing to pdd package directory
- Ignore test files with unmocked LLM/cloud subprocess calls that
  timeout in CI: test_connect, test_bug_to_unit_test,
  test_context_generator, test_crash_main, test_generate_test,
  test_fix_error_loop
- Deselect 2 zsh-specific tests (no zsh on ubuntu-latest)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment on lines 28 to 61
if: github.event.pull_request.draft != true
name: Run Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 30

env:
PDD_PATH: ${{ github.workspace }}/pdd

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'

- name: Install dependencies
run: pip install -e ".[dev]" pytest-timeout

- name: Run unit tests
run: >
pytest tests/
-m "not integration and not e2e and not real"
-v --tb=short --timeout=60 -n auto
--ignore=tests/commands/test_connect.py
--ignore=tests/test_bug_to_unit_test.py
--ignore=tests/test_context_generator.py
--ignore=tests/test_crash_main.py
--ignore=tests/test_generate_test.py
--ignore=tests/test_fix_error_loop.py
--deselect=tests/test_setup_tool.py::test_create_api_env_script_with_special_characters_zsh
--deselect=tests/test_setup_tool.py::test_create_api_env_script_with_common_problematic_characters

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant