feat: add comprehensive test suite, CI/CD workflows, and install command

Major improvements to SuperClaude Framework infrastructure and testing:

## New Features
- Add 'superclaude install' command to install slash commands (/research, /index-repo, /agent, /recommend)
- Create comprehensive test suite with 71 tests (70 passing, 1 skipped)
- Add GitHub Actions CI/CD workflows for automated testing
- Add essential documentation files (PLANNING.md, TASK.md, KNOWLEDGE.md)

## Testing
- tests/unit/: 59 tests covering PM Agent components
  - test_confidence.py: 13 tests for ConfidenceChecker
  - test_self_check.py: 14 tests for SelfCheckProtocol
  - test_reflexion.py: 9 tests for ReflexionPattern
  - test_token_budget.py: 12 tests for TokenBudgetManager
  - test_cli_install.py: 12 tests for install command (NEW)
- tests/integration/: 11 tests for pytest plugin integration
- tests/conftest.py: Shared fixtures for all tests

## CI/CD Workflows
- .github/workflows/test.yml: Comprehensive test matrix
  - Tests on Python 3.10, 3.11, 3.12
  - Lint and format checks with ruff
  - Pytest plugin verification
  - SuperClaude doctor health checks
  - Coverage reporting with Codecov
- .github/workflows/quick-check.yml: Fast PR validation (~2-3 min)
- .github/workflows/README.md: Workflow documentation

## Documentation
- PLANNING.md: Architecture, design principles, absolute rules
- TASK.md: Current tasks, priorities, backlog
- KNOWLEDGE.md: Accumulated insights, best practices, troubleshooting

## Bug Fixes
- Fix .gitignore contradictions (remove conflicting Claude Code patterns)
- Fix TokenBudgetManager to properly validate and default invalid complexity
- Update package.json version to 4.1.6 (sync with VERSION file)

## CLI Improvements
- src/superclaude/cli/install_commands.py: Command installation logic
- src/superclaude/cli/main.py: Add 'install' command with --list and --force options
- README.md: Update installation instructions with correct commands

## Breaking Changes
None - all changes are backwards compatible

## Migration Guide
Users should run 'superclaude install' after upgrading to install slash commands

Fixes #466 (indirectly by clarifying installation process)
Refs #419 (plugin system - documentation updated)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
mithun50
2025-11-11 18:21:22 +01:00
parent bec0b0c3e3
commit 8c0559ca9a
22 changed files with 3157 additions and 9 deletions

158
.github/workflows/README.md vendored Normal file
View File

@@ -0,0 +1,158 @@
# GitHub Actions Workflows
This directory contains CI/CD workflows for SuperClaude Framework.
## Workflows
### 1. **test.yml** - Comprehensive Test Suite
**Triggers**: Push/PR to `master` or `integration`, manual dispatch
**Jobs**:
- **test**: Run tests on Python 3.10, 3.11, 3.12
- Install UV and dependencies
- Run full test suite
- Generate coverage report (Python 3.10 only)
- Upload to Codecov
- **lint**: Run ruff linter and format checker
- **plugin-check**: Verify pytest plugin loads correctly
- **doctor-check**: Run `superclaude doctor` health check
- **test-summary**: Aggregate results from all jobs
**Status Badge**:
```markdown
[![Tests](https://github.com/SuperClaude-Org/SuperClaude_Framework/actions/workflows/test.yml/badge.svg)](https://github.com/SuperClaude-Org/SuperClaude_Framework/actions/workflows/test.yml)
```
### 2. **quick-check.yml** - Fast PR Feedback
**Triggers**: Pull requests to `master` or `integration`
**Jobs**:
- **quick-test**: Fast check on Python 3.10 only
- Run unit tests only (faster)
- Run linter
- Check formatting
- Verify plugin loads
- 10 minute timeout
**Purpose**: Provide rapid feedback on PRs before running full test matrix.
### 3. **publish-pypi.yml** (Existing)
**Triggers**: Manual or release tags
**Purpose**: Publish package to PyPI
### 4. **readme-quality-check.yml** (Existing)
**Triggers**: Push/PR affecting README files
**Purpose**: Validate README quality and consistency
## Local Testing
Before pushing, run these commands locally:
```bash
# Run full test suite
uv run pytest -v
# Run with coverage
uv run pytest --cov=superclaude --cov-report=term
# Run linter
uv run ruff check src/ tests/
# Check formatting
uv run ruff format --check src/ tests/
# Auto-fix formatting
uv run ruff format src/ tests/
# Verify plugin loads
uv run pytest --trace-config | grep superclaude
# Run doctor check
uv run superclaude doctor --verbose
```
## CI/CD Pipeline
```
┌─────────────────────┐
│ Push/PR Created │
└──────────┬──────────┘
├─────────────────────────┐
│ │
┌──────▼──────┐ ┌───────▼────────┐
│ Quick Check │ │ Full Test │
│ (PR only) │ │ Matrix │
│ │ │ │
│ • Unit tests│ │ • Python 3.10 │
│ • Lint │ │ • Python 3.11 │
│ • Format │ │ • Python 3.12 │
│ │ │ • Coverage │
│ ~2-3 min │ │ • Lint │
└─────────────┘ │ • Plugin check │
│ • Doctor check │
│ │
│ ~5-8 min │
└────────────────┘
```
## Coverage Reporting
Coverage reports are generated for Python 3.10 and uploaded to Codecov.
To view coverage locally:
```bash
uv run pytest --cov=superclaude --cov-report=html
open htmlcov/index.html
```
## Troubleshooting
### Workflow fails with "UV not found"
- UV is installed in each job via `curl -LsSf https://astral.sh/uv/install.sh | sh`
- If installation fails, check UV's status page
### Tests fail locally but pass in CI (or vice versa)
- Check Python version: `python --version`
- Reinstall dependencies: `uv pip install -e ".[dev]"`
- Clear caches: `rm -rf .pytest_cache .venv`
### Plugin not loading in CI
- Verify entry point in `pyproject.toml`: `[project.entry-points.pytest11]`
- Check plugin is installed: `uv run pytest --trace-config`
### Coverage upload fails
- This is non-blocking (fail_ci_if_error: false)
- Check Codecov token in repository secrets
## Maintenance
### Adding a New Workflow
1. Create new `.yml` file in this directory
2. Follow existing structure (checkout, setup-python, install UV)
3. Add status badge to README.md if needed
4. Document in this file
### Updating Python Versions
1. Edit `matrix.python-version` in `test.yml`
2. Update `pyproject.toml` classifiers
3. Test locally with new version first
### Modifying Test Strategy
- **quick-check.yml**: For fast PR feedback (unit tests only)
- **test.yml**: For comprehensive validation (full matrix)
## Best Practices
1. **Keep workflows fast**: Use caching, parallel jobs
2. **Fail fast**: Use `-x` flag in pytest for quick-check
3. **Clear names**: Job and step names should be descriptive
4. **Version pinning**: Pin action versions (@v4, @v5)
5. **Matrix testing**: Test on multiple Python versions
6. **Non-blocking coverage**: Don't fail on coverage upload errors
7. **Manual triggers**: Add `workflow_dispatch` for debugging
## Resources
- [GitHub Actions Documentation](https://docs.github.com/en/actions)
- [UV Documentation](https://github.com/astral-sh/uv)
- [Pytest Documentation](https://docs.pytest.org/)
- [SuperClaude Testing Guide](../../docs/developer-guide/testing-debugging.md)

55
.github/workflows/quick-check.yml vendored Normal file
View File

@@ -0,0 +1,55 @@
name: Quick Check
on:
pull_request:
branches: [master, integration]
jobs:
quick-test:
name: Quick Test (Python 3.10)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
- name: Install UV
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
uv pip install -e ".[dev]"
- name: Run unit tests only
run: |
uv run pytest tests/unit/ -v --tb=short -x
- name: Run linter
run: |
uv run ruff check src/ tests/
- name: Check formatting
run: |
uv run ruff format --check src/ tests/
- name: Verify pytest plugin
run: |
uv run pytest --trace-config 2>&1 | grep -q "superclaude"
- name: Summary
if: success()
run: |
echo "✅ Quick checks passed!"
echo " - Unit tests: PASSED"
echo " - Linting: PASSED"
echo " - Formatting: PASSED"
echo " - Plugin: LOADED"

173
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,173 @@
name: Tests
on:
push:
branches: [master, integration]
pull_request:
branches: [master, integration]
workflow_dispatch:
jobs:
test:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install UV
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Verify UV installation
run: uv --version
- name: Install dependencies
run: |
uv pip install -e ".[dev]"
- name: Verify package installation
run: |
uv run python -c "import superclaude; print(f'SuperClaude {superclaude.__version__} installed')"
- name: Run tests
run: |
uv run pytest -v --tb=short --color=yes
- name: Run tests with coverage
if: matrix.python-version == '3.10'
run: |
uv run pytest --cov=superclaude --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
if: matrix.python-version == '3.10'
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
lint:
name: Lint and Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install UV
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
uv pip install -e ".[dev]"
- name: Run ruff linter
run: |
uv run ruff check src/ tests/
- name: Check ruff formatting
run: |
uv run ruff format --check src/ tests/
plugin-check:
name: Pytest Plugin Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install UV
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
uv pip install -e ".[dev]"
- name: Verify pytest plugin loaded
run: |
uv run pytest --trace-config 2>&1 | grep -q "superclaude" && echo "✅ Plugin loaded successfully" || (echo "❌ Plugin not loaded" && exit 1)
- name: Check available fixtures
run: |
uv run pytest --fixtures | grep -E "(confidence_checker|self_check_protocol|reflexion_pattern|token_budget|pm_context)"
doctor-check:
name: SuperClaude Doctor Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install UV
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
uv pip install -e ".[dev]"
- name: Run doctor command
run: |
uv run superclaude doctor --verbose
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [test, lint, plugin-check, doctor-check]
if: always()
steps:
- name: Check test results
run: |
if [ "${{ needs.test.result }}" != "success" ]; then
echo "❌ Tests failed"
exit 1
fi
if [ "${{ needs.lint.result }}" != "success" ]; then
echo "❌ Linting failed"
exit 1
fi
if [ "${{ needs.plugin-check.result }}" != "success" ]; then
echo "❌ Plugin check failed"
exit 1
fi
if [ "${{ needs.doctor-check.result }}" != "success" ]; then
echo "❌ Doctor check failed"
exit 1
fi
echo "✅ All checks passed!"