Skip to content

Conversation

@jensens
Copy link
Member

@jensens jensens commented Oct 31, 2025

Summary

Add comprehensive testing infrastructure and GitHub Actions CI workflow.

Changes

Testing Infrastructure:

  • Created comprehensive test suite with 30+ test cases
  • Tests cover all major functions: utility functions, GitHub API integration, and all perform_* commands
  • Includes pytest fixtures for mocking subprocess calls, git repositories, and API responses
  • Achieves ~80% code coverage
  • Tests use proper mocking to avoid external dependencies

CI/CD:

  • GitHub Actions workflow testing on Python 3.9, 3.10, 3.11, 3.12, 3.13, and 3.14
  • Runs on push to main and all pull requests
  • Executes ruff linting, isort checking, and pytest with coverage
  • Optional Codecov integration for coverage reporting

Code Quality Configuration:

  • Configured ruff with essential rules: E (pycodestyle), F (pyflakes), B (bugbear), UP (pyupgrade), S (bandit security)
  • Added pytest configuration in pyproject.toml
  • Updated test dependencies: pytest, pytest-cov, pytest-mock
  • Kept isort separate from ruff (uses force_alphabetical_sort which ruff doesn't support)

Housekeeping:

  • Updated .gitignore to exclude local config files

Test Coverage

The test suite covers:

  • Utility functions (listdir, hilite, get_branch)
  • GitHub API integration (query_repos with org/user fallback, pagination)
  • All perform_* functions (clone, pull, status, branch, diff, commit, push, checkout, backup)
  • Edge cases (non-git directories, files vs directories, specific vs all repos)

Add a complete testing infrastructure with GitHub Actions CI workflow.

Changes:
- Add GitHub Actions workflow testing on Python 3.9-3.14
- Configure ruff with proper linting rules (E, F, B, UP, S)
- Add pytest configuration in pyproject.toml
- Add test dependencies: pytest-cov, pytest-mock
- Create comprehensive test suite with 30+ test cases covering:
  - Utility functions (listdir, hilite, get_branch)
  - GitHub API integration (query_repos)
  - All perform_* functions with mocking
  - Edge cases (non-git directories, files vs directories)
- Add pytest fixtures for mocking subprocess, git repos, and API responses
- Update .gitignore to exclude local config files

The test suite provides ~80% code coverage and ensures code quality before
making any refactoring changes. CI runs on all supported Python versions.

Note: Kept isort separate from ruff as it uses force_alphabetical_sort
which ruff doesn't support.
@jensens
Copy link
Member Author

jensens commented Oct 31, 2025

CI Failures

The GitHub Actions CI is failing because ruff is catching code quality and security issues in the existing code:

Issues found:

  • UP031: Old-style percent formatting (should use f-strings or .format())
  • S310: Audit URL open for permitted schemes
  • S602: subprocess call with shell=True (security issue)
  • S603: subprocess call - check for execution of untrusted input

Will fix the code to pass ruff checks.

@jensens jensens marked this pull request as draft November 1, 2025 14:56
@jensens jensens force-pushed the test/add-test-suite-and-quality-config branch from 56213f9 to 53e4263 Compare November 1, 2025 14:57
- Convert percent formatting to f-strings (UP031)
- Fix shell=True vulnerability in get_branch() (S602)
- Add noqa comments for acceptable subprocess and urlopen usage
- Fix infinite loop in query_repos tests by properly simulating pagination ending

All tests now pass (30/30) with 91% code coverage.
@jensens jensens force-pushed the test/add-test-suite-and-quality-config branch from 53e4263 to 2f1fae0 Compare November 1, 2025 14:58
@jensens
Copy link
Member Author

jensens commented Nov 1, 2025

Makefile enhancements

  • mxmake update ro get latest mxmake improvements
  • uvx mxmake and enabled tests, edit mx.ini to configure tests

@jensens jensens marked this pull request as ready for review November 1, 2025 15:01
@jensens jensens requested a review from rnixx November 1, 2025 15:02
@rnixx rnixx merged commit 2a4f224 into main Nov 3, 2025
6 checks passed
@rnixx rnixx deleted the test/add-test-suite-and-quality-config branch November 3, 2025 13:02
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.

3 participants